⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mdoc.samples.7

📁 早期freebsd实现
💻 7
📖 第 1 页 / 共 5 页
字号:
.\" Copyright (c) 1990, 1993.\"	The Regents of the University of California.  All rights reserved..\".\" Redistribution and use in source and binary forms, with or without.\" modification, are permitted provided that the following conditions.\" are met:.\" 1. Redistributions of source code must retain the above copyright.\"    notice, this list of conditions and the following disclaimer..\" 2. Redistributions in binary form must reproduce the above copyright.\"    notice, this list of conditions and the following disclaimer in the.\"    documentation and/or other materials provided with the distribution..\" 3. All advertising materials mentioning features or use of this software.\"    must display the following acknowledgement:.\"	This product includes software developed by the University of.\"	California, Berkeley and its contributors..\" 4. Neither the name of the University nor the names of its contributors.\"    may be used to endorse or promote products derived from this software.\"    without specific prior written permission..\".\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION).\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF.\" SUCH DAMAGE..\".\"     @(#)mdoc.samples.7	8.2 (Berkeley) 12/30/93.\".\" This tutorial sampler invokes every macro in the package several.\" times and is guaranteed to give a worst case performance.\" for an already extremely slow package..\".Dd December 30, 1993.Os.Dt MDOC.SAMPLES 7.Sh NAME.Nm mdoc.samples.Nd tutorial sampler for writing.Bxmanuals with.Nm \-mdoc.Sh SYNOPSIS.Nm man mdoc.samples.Sh DESCRIPTIONA tutorial sampler for writing.Bxmanual pages with the.Nm \-mdocmacro package, a.Em content Ns \-basedand.Em domain Ns \-basedformattingpackage for.Xr troff 1 .Its predecessor, the.Xr \-man 7package,addressed page layout leaving themanipulation of fonts and othertypesetting details to the individual author.In.Nm \-mdoc ,page layout macrosmake up the.Em "page structure domain"which consists of macros for titles, section headers, displaysand lists. Essentially items which affect the physical positionof text on a formatted page.In addition to the page structure domain, there are two more domains,the manual domain and the general text domain.The general text domain is defined as macros whichperform tasks such as quoting or emphasizing pieces of text.The manual domain is defined as macros that are a subset of theday to day informal language used to describe commands, routinesand related.Bxfiles.Macros in the manual domain handlecommand names, command line arguments and options, function names,function parameters, pathnames, variables, crossreferences to other manual pages, and so on.These domainitems have valuefor both the author and the future user of the manual page.It is hoped the consistency gainedacross the manual set will provide easiertranslation to future documentation tools..PpThroughout the.Uxmanual pages, a manual entryis simply referredto as a man page, regardless of actual length and withoutsexist intention..Sh GETTING STARTEDSince a tutorial document is normally read when a persondesires to use the material immediately, the assumption hasbeen made that the user of this document may be impatient.The material presented in the remained of this document isoutlined as follows:.Bl -enum -offset indent.It.Tn "TROFF IDIOSYNCRASIES".Bl -tag -width flag -compact -offset indent.It "Macro Usage" ..It "Passing Space Characters in an Argument" ..It "Trailing Blank Space Characters (a warning)" ..It "Escaping Special Characters" ..El.It.Tn "THE ANATOMY OF A MAN PAGE".Bl -tag -width flag -compact -offset indent.It "A manual page template" ..El.It.Tn "INTRODUCTION OF TITLE MACROS" ..It.Tn "INTRODUCTION OF MANUAL AND GENERAL TEXT DOMAINS" ..Bl -tag -width flag -compact -offset indent.It "What's in a name..." ..It "General Syntax" ..El.It.Tn "MANUAL DOMAIN".Bl -tag -width flag -compact -offset indent.It "Addresses" ..It "Arguments" ..It "Configuration Declarations (section four only)" ..It "Command Modifier ..It "Defined Variables" ..It "Errno's (Section two only)" ..It "Environment Variables" ..It "Function Argument" ..It "Function Declaration" ..It "Flags" ..It "Functions (library routines)" ..It "Function Types" ..\" .It "Header File (including source code)" ..It "Interactive Commands" ..It "Literals" ..It "Names" ..It "Options" ..It "Pathnames" ..It "Variables" ..It "Cross References" ..El.It.Tn "GENERAL TEXT DOMAIN".Bl -tag -width flag -compact -offset indent.It "AT&T Macro" ..It "BSD Macro" ..It "UNIX Macro" ..It "Emphasis Macro" ..It "Enclosure/Quoting Macros".Bl -tag -width flag -compact -offset indent.It "Angle Bracket Quote/Enclosure" ..It "Bracket Quotes/Enclosure" ..It "Double Quote macro/Enclosure" ..It "Parenthesis Quote/Enclosure" ..It "Single Quotes/Enclosure" ..It "Prefix Macro" ..El.It "Extended  Arguments" ..It "No\-Op or Normal Text Macro" ..It "No Space Macro" ..It "Section Cross References" ..It "Symbolic Macro" ..It "References and Citations" ..It "Trade Names (Acronyms and Type Names)" ..El.It.Tn "PAGE STRUCTURE DOMAIN".Bl -tag -width flag -compact -offset indent.It "Section Headers" ..It "Paragraphs and Line Spacing" ..It "Keeps" ..It "Displays" ..It "Lists and Columns" ..El.It.Tn "PREDEFINED STRINGS".It.Tn "DIAGNOSTICS".It.Tn "FORMATTING WITH GROFF, TROFF AND NROFF".It.Tn "BUGS".El.ne 7.Sh TROFF IDIOSYNCRASIESThe.Nm \-mdocpackage attempts to simplify the process of writing a man page.Theoretically, one should not have to learn the dirty details of.Xr troff 1to use.Nm \-mdoc ;however, there are a fewlimitations which are unavoidable and best gotten outof the way.And, too, be forewarned, this package is.Em notfast..Ss Macro UsageAs in.Xr troff 1 ,a macro is called by placing a.Ql \&\.(dot character)at the beginning ofa line followed by the two character name for the macro.Arguments may follow the macro separated by spaces.It is the dot character at the beginning of the line which causes.Xr troff 1to interpret the next two characters as a macro name.To place a.Ql \&\.(dot character)at the beginning of a line in some context other thana macro invocation, precede the.Ql \&\.(dot) with the.Ql \e&escape sequence.The.Ql \e&translates literally to a zero width space, and is never displayed in theoutput..PpIn general,.Xr troff 1macros accept up to nine arguments, anyextra arguments are ignored.Most macros in.Nm \-mdocaccept nine arguments and,in limited cases, arguments may be continued or extendedon thenext line (See.Sx Extensions ) .A few macros handle quoted arguments (see.Sx Passing Space Characters in an Argumentbelow)..PpMost of the.Nm \-mdocgeneral text domain and manual domain macros are specialin that their argument lists are.Em parsedfor callable macro names.This means an argument on the argument list which matchesa general text or manual domain macro name and is determinedto be callable will be executedor called when it is processed.In this casethe argument, although the name of a macro,is not preceded by a.Ql \&\.(dot).It is in this manner that many macros are nested; forexamplethe option macro,.Ql \&.Op ,may.Em callthe flag and argument macros,.Ql \&Fland.Ql \&Ar ,to specify an optional flag with an argument:.Bl -tag -width "\&.Op \&Fl s \&Ar bytes" -offset indent.It Op Fl s Ar bytesis produced by.Li \&.Op \&Fl s \&Ar bytes.El.PpTo prevent a two characterstring from being interpreted as a macro name, precedethe string with theescape sequence.Ql \e& :.Bl -tag -width "\&.Op \&Fl s \&Ar bytes" -offset indent.It Op \&Fl s \&Ar bytesis produced by.Li \&.Op \e&Fl s \e&Ar bytes.El.PpHere the strings.Ql \&Fland.Ql \&Arare not interpreted as macros.Macros whose argument lists are parsed for callable argumentsare referred toas parsed and macros which may be called from an argumentlist are referred to as callablethroughout this document and in the companion quick referencemanual.Xr mdoc 7 .This is a technical.Em faux pasas almost all of the macros in .Nm \-mdocare parsed, but as it was cumbersome to constantly refer to macrosas being callable and being able to call other macros,the term parsed has been used..Ss Passing Space Characters in an ArgumentSometimes it is desirable to give as one argument a stringcontaining one or more blank space characters.This may be necessaryto defeat the nine argument limit or to specify arguments to macroswhich expect particular arrangement of items in the argument list.For example,the function macro.Ql \&.Fnexpects the first argument to be the name of a function and anyremaining arguments to be function parameters.As.Tn "ANSI C"stipulates the declaration of function parameters in theparenthesized parameter list, each parameter is guaranteedto be at minimum a two word string.For example,.Fa int foo ..PpThere are two possible ways to pass an argument which containsan embedded space..Em Implementation note :Unfortunately, the most convenient wayof passing spaces in between quotes by reassigning individualarguments before parsing was fairly expensive speed wiseand space wise to implement in all the macros for.Tn AT&T.Xr troff .It is not expensive for.Xr groffbut for the sake of portability, has been limitedto the following macros which needit the most:.Pp.Bl -tag -width 4n -offset indent -compact.It Li \&CdConfiguration declaration (section 4.Sx SYNOPSIS ).It Li \&BlBegin list (for the width specifier)..It Li \&EmEmphasized text..It Li \&FnFunctions (sections two and four)..It Li \&ItList items..It Li \&LiLiteral text..It Li \&SySymbolic text..It Li \&%BBook titles..It Li \&%JJournal names..It Li \&%OOptional notes for a reference..It Li \&%RReport title (in a reference)..It Li \&%TTitle of article in a book or journal..El.PpOne way of passing a stringcontaining blank spaces is to use the hard or unpaddable space character.Ql \e\  ,that is, a blank space preceded by the escape character.Ql \e .This method may be used with any macro but has the side effectof interfering with the adjustment of textover the length of a line..Xr Troffsees the hard space as if it were any other printable character andcannot split the string into blank or newline separated pieces as onewould expect.The method is useful for strings which are not expectedto overlap a line boundary.For example:.Bl -tag -width "fetch(char *str)" -offset indent.It Fn fetch char\ *stris created by.Ql \&.Fn fetch char\e *str.It Fn fetch "char *str"can also be created by.Ql \&.Fn fetch "\\*q*char *str\\*q".El.PpIf the.Ql \eor quoteswere omitted,.Ql \&.Fnwould see three arguments andthe result would be:.Pp.Dl Fn fetch char *str.PpFor an example of what happens when the parameter list overlapsa newline boundary, see the.Sx BUGSsection..Ss Trailing Blank Space Characters.Xr Troffcan be confused by blank space characters at the end of a line.Itis a wise preventive measure to globally remove all blank spacesfrom <blank-space><end-of-line> character sequences.Should the needarise to force a blank character at the end of a line,it may be forced with an unpaddable space and the.Ql \e&escape character.For example,.Ql string\e\ \e& ..Ss Escaping Special CharactersSpecial characterslike the newline character.Ql \en ,are handled by replacing the.Ql \ewith.Ql \ee(e.g..Ql \een )to preservethe backslash..Sh THE ANATOMY OF A MAN PAGEThe body of a man page is easily constructed from a basictemplate found in the file:.Bd -literal -offset indent\&.\e" /usr/share/misc/man.template:\&.\e" The following six lines are required.\&.Dd Month day, year\&.Os OPERATING_SYSTEM [version/release]\&.Dt DOCUMENT_TITLE [section number] [volume]\&.Sh NAME\&.Sh SYNOPSIS\&.Sh DESCRIPTION\&.\e" The following requests should be uncommented and\&.\e" used where appropriate.  This next request is\&.\e" for sections 2 and 3 function return values only.\&.\e" .Sh RETURN VALUES\&.\e" This next request is for sections 1, 6, 7 & 8 only\&.\e" .Sh ENVIRONMENT\&.\e" .Sh FILES\&.\e" .Sh EXAMPLES\&.\e" This next request is for sections 1, 6, 7 & 8 only\&.\e"     (command return values (to shell) and\&.\e"	  fprintf/stderr type diagnostics)\&.\e" .Sh DIAGNOSTICS\&.\e" The next request is for sections 2 and 3 error\&.\e" and signal handling only.\&.\e" .Sh ERRORS\&.\e" .Sh SEE ALSO\&.\e" .Sh STANDARDS\&.\e" .Sh HISTORY\&.\e" .Sh AUTHORS\&.\e" .Sh BUGS.Ed.PpThe first items in the template are the macros.Pq Li \&.Dd , \&.Os , \&.Dt ;the document date,the operating system the man page or subject source is developedor modified for,and the man page title.Pq Em in upper casealong with the section of the manual the pagebelongs in.These macros identify the page,and are discussed below in.Sx TITLE MACROS ..PpThe remaining items in the template are section headers.Pq Li \&.Sh ;of which.Sx NAME ,.Sx SYNOPSISand.Sx DESCRIPTIONare mandatory.Theheaders arediscussed in.Sx PAGE STRUCTURE DOMAIN ,afterpresentation of.Sx MANUAL DOMAIN .Several content macros are used to demonstrate page layout macros;reading about content macros before page layout macros isrecommended..Sh TITLE MACROSThe title macros are the first portion of the page structuredomain, but are presented first and separate for someone whowishes to start writing a man page yesterday.Three header macros designate the document title or manual page title,the operating system,and the date of authorship.These macros are one called once at the very beginning of the documentand are used to construct the headers and footers only..Bl -tag -width 6n.It Li \&.Dt DOCUMENT_TITLE section# [volume]The document title is thesubject of the man page and must be in.Tn CAPITALSdue to trofflimitations.The section number may be 1,\ ...,\ 8,and if it is specified,the volume title may be omitted.A volume title may be arbitrary or one of the following:.\" .Cl.\" USD	UNIX User's Supplementary Documents.\" .Cl.\" PS1	UNIX Programmer's Supplementary Documents.Pp.Bl -column SMM -offset indent -compact.It Li AMD	UNIX Ancestral Manual Documents.It Li SMM	UNIX System Manager's Manual.It Li URM	UNIX Reference Manual.It Li PRM	UNIX Programmer's Manual.El.PpThe default volume labeling is.Li URMfor sections 1, 6, and 7;.Li SMMfor section 8;.Li PRMfor sections 2, 3, 4, and 5..\" .Cl.\" MMI	UNIX Manual Master Index.\" .Cl.\" CON	UNIX Contributed Software Manual.\" .Cl.\" LOC	UNIX Local Manual.It Li \&.Os operating_system release#The name of the operating systemshould be the common acronym, e.g..Tn BSDor.Tn ATT .The release should be the standard releasenomenclature for the system specified, e.g. 4.3, 4.3+Tahoe, V.3,V.4.Unrecognized arguments are displayed as given in the page footer.For instance, a typical footer might be:

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -