📄 mdoc.samples.7
字号:
.Pp.Dl \&.Os BSD 4.3.Ppor for a locally produced set.Pp.Dl \&.Os CS Department.PpThe Berkeley default,.Ql \&.Oswithout an argument, has been defined as.Tn BSDExperimental in thesite specific file.Pa /usr/src/share/tmac/doc-common .It really should default to.Tn LOCAL .Note, if the.Ql \&.Osmacro is not present, the bottom left corner of the pagewill be ugly..It Li \&.Dd month day, yearThe date should be written formally:.Pp.ne 5.Dl January 25, 1989.El.Sh MANUAL DOMAIN.Ss What's in a name...The manual domain macro names are derived from the day to dayinformal language used to describe commands, subroutines and relatedfiles.Slightlydifferent variations of this language are used to describethe three different aspects of writing a man page.First, there is the description of.Nm \-mdocmacro request usage.Second is the description of a.Uxcommand.Em with.Nm \-mdocmacros and third,thedescription of a command to a user in the verbal sense;that is, discussion of a command in the text of a man page..PpIn the first case,.Xr troff 1macros are themselves a type of command;the general syntax for a troff command is:.Bd -filled -offset indent\&.Va argument1 argument2 ... argument9.Ed.PpThe.Ql \&.Vais a macro command or request, and anything following it is an argument tobe processed.In the second case,the description of a.Uxcommand using the content macros is abit more involved;a typical.Sx SYNOPSIScommand line might be displayed as:.Bd -filled -offset indent.Nm filter.Op Fl flag.Ar infile outfile.Ed.PpHere,.Nm filteris the command name and thebracketed string.Fl flagis a.Em flagargument designated as optional by the option brackets.In.Nm \-mdocterms,.Ar infileand.Ar outfilearecalled.Em arguments .The macros which formatted the above example:.Bd -literal -offset indent\&.Nm filter\&.Op \&Fl flag\&.Ar infile outfile.Ed.PpIn the third case, discussion of commands and command syntaxincludes both examples above, but may add more detail.Thearguments.Ar infileand.Ar outfilefrom the example above might be referred to as.Em operandsor.Em file arguments .Some command line argument lists are quite long:.Bl -tag -width make -offset indent.It Nm make.Op Fl eiknqrstv.Op Fl D Ar variable.Op Fl d Ar flags.Op Fl f Ar makefile.Bk -words.Op Fl I Ar directory.Ek.Op Fl j Ar max_jobs.Op Ar variable=value.Bk -words.Op Ar target ....Ek.El.PpHere one might talk about the command.Nm makeand qualify the argument.Ar makefile ,as an argument to the flag,.Fl f ,or discuss the optionalfileoperand.Ar target .In the verbal context, such detail can prevent confusion,however the.Nm \-mdocpackagedoes not have a macro for an argument.Em toa flag.Instead the.Ql \&Arargument macro is used for an operand or file argument like.Ar targetas well as an argument to a flag like.Ar variable .The make command line was produced from:.Bd -literal -offset indent\&.Nm make\&.Op Fl eiknqrstv\&.Op Fl D Ar variable\&.Op Fl d Ar flags\&.Op Fl f Ar makefile\&.Op Fl I Ar directory\&.Op Fl j Ar max_jobs\&.Op Ar variable=value\&.Bk -words\&.Op Ar target ...\&.Ek.Ed.PpThe.Ql \&.Bkand.Ql \&.Ekmacros are explained in.Sx Keeps ..Ss General SyntaxThe manual domain and general text domain macros share a similarsyntax with a few minor deviations:.Ql \&.Ar ,.Ql \&.Fl ,.Ql \&.Nm ,and.Ql \&.Padiffer only when called without arguments;.Ql \&.Fnand.Ql \&.Xrimpose an order on their argument listsand the.Ql \&.Opand.Ql \&.Fnmacroshave nesting limitations.All content macrosare capable of recognizing and properly handling punctuation,provided each punctuation character is separated by a leading space.If an request is given:.Pp.Dl \&.Li sptr, ptr),.PpThe result is:.Pp.Dl Li sptr, ptr),.PpThe punctuation is not recognized and all is output in theliteral font. If the punctuation is separated by a leadingwhite space:.Pp.Dl \&.Li "sptr , ptr ) ,".PpThe result is:.Pp.Dl Li sptr , ptr ) ,.PpThe punctuation is now recognized and is output in thedefault font distinguishing it from the strings in literal font..PpTo remove the special meaning from a punctuation characterescape it with.Ql \e& ..Xr Troffis limited as a macro language, and has difficultywhen presented with a string containinga member of the mathematical, logical orquotation set:.Bd -literal -offset indent-two\&{+,\-,/,*,\&%,<,>,<=,>=,=,==,&,`,',"}.Ed.PpThe problem is that.Xr troffmay assume it is supposed to actually perform the operationor evaluation suggested by the characters. To preventthe accidental evaluation of these characters,escape them with.Ql \e& .Typical syntax is shown in the first content macro displayedbelow,.Ql \&.Ad ..Ss Address MacroThe address macro identifies an address constructof the form addr1[,addr2[,addr3]]..Pp.Dl Usage: .Ad address ... \*(Pu.Bl -tag -width ".Ad f1 , f2 , f3 :" -compact -offset 14n.It Li \&.Ad addr1.Ad addr1.It Li \&.Ad addr1\ ..Ad addr1 ..It Li \&.Ad addr1\ , file2.Ad addr1 , file2.It Li \&.Ad f1\ , f2\ , f3\ :.Ad f1 , f2 , f3 :.It Li \&.Ad addr\ )\ )\ ,.Ad addr ) ) ,.El.PpIt is an error to call.Li \&.Adwithout arguments..Li \&.Adis callable by other macros and is parsed..Ss Argument MacroThe.Li \&.Arargument macro may be used whenevera command line argument is referenced..Pp.Dl Usage: .Ar argument ... \*(Pu.Bl -tag -width ".Ar file1 file2" -compact -offset 15n.It Li \&.Ar.Ar.It Li \&.Ar file1.Ar file1.It Li \&.Ar file1\ ..Ar file1 ..It Li \&.Ar file1 file2.Ar file1 file2.It Li \&.Ar f1 f2 f3\ :.Ar f1 f2 f3 :.It Li \&.Ar file\ )\ )\ ,.Ar file ) ) ,.El.PpIf.Li \&.Aris called without arguments.Ql Aris assumed.The.Li \&.Armacro is parsed and is callable..Ss Configuration Declaration (section four only)The.Ql \&.Cdmacro is used to demonstrate a.Xr config 8declaration for a device interface in a section four manual.This macro accepts quoted arguments (double quotes only)..Pp.Bl -tag -width "device le0 at scode?" -offset indent.It Cd "device le0 at scode?"produced by:.Ql ".Cd device le0 at scode?" ..El.Ss Command ModifierThe command modifier is identical to the.Ql \&.Fl(flag) command with the exceptionthe.Ql \&.Cmmacro does not assert a dashin front of every argument.Traditionally flags are marked by thepreceding dash, some commands or subsets of commands do not use them.Command modifiers may also be specified in conjunction with interactivecommands such as editor commands.See.Sx Flags ..Ss Defined VariablesA variable which is defined in an include file is specifiedby the macro.Ql \&.Dv ..Pp.Dl Usage: .Dv defined_variable ... \*(Pu.Bl -tag -width ".Dv MAXHOSTNAMELEN" -compact -offset 14n.It Li ".Dv MAXHOSTNAMELEN".Dv MAXHOSTNAMELEN.It Li ".Dv TIOCGPGRP )".Dv TIOCGPGRP ).El.PpIt is an error to call.Ql \&.Dvwithout arguments..Ql \&.Dvis parsed and is callable..Ss Errno's (Section two only)The.Ql \&.Ererrno macro specifies the error return valuefor section two library routines.The second examplebelow shows.Ql \&.Erused with the.Ql \&.Bqgeneral text domain macro, as it would be used ina section two manual page..Pp.Dl Usage: .Er ERRNOTYPE ... \*(Pu.Bl -tag -width ".Bq Er ENOTDIR" -compact -offset 14n.It Li \&.Er ENOENT.Er ENOENT.It Li \&.Er ENOENT\ )\ ;.Er ENOENT ) ;.It Li \&.Bq \&Er ENOTDIR.Bq Er ENOTDIR.El.PpIt is an error to call.Ql \&.Erwithout arguments.The.Ql \&.Ermacro is parsed and is callable..Ss Environment VariablesThe.Ql \&.Evmacro specifies an environment variable..Pp.Dl Usage: .Ev argument ... \*(Pu.Bl -tag -width ".Ev PRINTER ) ) ," -compact -offset 14n.It Li \&.Ev DISPLAY.Ev DISPLAY.It Li \&.Ev PATH\ ..Ev PATH ..It Li \&.Ev PRINTER\ )\ )\ ,.Ev PRINTER ) ) ,.El.PpIt is an error to call.Ql \&.Evwithout arguments.The.Ql \&.Evmacro is parsed and is callable..Ss Function ArgumentThe.Ql \&.Famacro is used to refer to function arguments (parameters)outside of the.Sx SYNOPSISsection of the manual or insidethe.Sx SYNOPSISsection should a parameter list be toolong for the.Ql \&.Fnmacro and the enclosure macros.Ql \&.Foand.Ql \&.Fcmust be used..Ql \&.Famay also be used to refer to structure members..Pp.Dl Usage: .Fa function_argument ... \*(Pu.Bl -tag -width ".Fa d_namlen\ )\ )\ ," -compact -offset 14n.It Li \&.Fa d_namlen\ )\ )\ ,.Fa d_namlen ) ) ,.It Li \&.Fa iov_len.Fa iov_len.El.PpIt is an error to call.Ql \&.Fawithout arguments..Ql \&.Fais parsed and is callable..Ss Function DeclarationThe.Ql \&.Fdmacro is used in the.Sx SYNOPSISsection with section two or threefunctions.The.Ql \&.Fdmacro does not call other macros and is not callable by othermacros..Pp.Dl Usage: .Fd include_file (or defined variable).PpIn the.Sx SYNOPSISsection a.Ql \&.Fdrequest causes a line break if a function has already been presentedand a break has not occurred.This leaves a nice vertical spacein between the previous function call and the declaration for thenext function..Ss FlagsThe.Ql \&.Flmacro handles command line flags.It prependsa dash,.Ql \- ,to the flag.For interactive command flags, whichare not prepended with a dash, the.Ql \&.Cm(command modifier)macro is identical, but without the dash..Pp.Dl Usage: .Fl argument ... \*(Pu.Bl -tag -width ".Fl \-s \-t \-v" -compact -offset 14n.It Li \&.Fl.Fl.It Li \&.Fl cfv.Fl cfv.It Li \&.Fl cfv\ ..Fl cfv ..It Li \&.Fl s v t.Fl s v t.It Li \&.Fl -\ ,.Fl - ,.It Li \&.Fl xyz\ )\ ,.Fl xyz ) ,.El.PpThe.Ql \&.Flmacro without any arguments resultsin a dash representing stdin/stdout.Note that giving.Ql \&.Fla single dash, will result in two dashes.The.Ql \&.Flmacro is parsed and is callable..Ss Functions (library routines)The .Fn macro is modeled on ANSI C conventions..Bd -literalUsage: .Fn [type] function [[type] parameters ... \*(Pu].Ed.Bl -tag -width ".Fn .int align. .const * char *sptrsxx" -compact.It Li "\&.Fn getchar".Fn getchar.It Li "\&.Fn strlen ) ,".Fn strlen ) ,.It Li \&.Fn "\\*qint align\\*q" "\\*qconst * char *sptrs\\*q" ,.Fn "int align" "const * char *sptrs" ,.El.PpIt is an error to call.Ql \&.Fnwithout any arguments.The.Ql \&.Fnmacrois parsed and is callable,note that any call to another macro signals the end ofthe.Ql \&.Fncall (it will close-parenthesis at that point)..PpFor functions that have more than eight parameters (and thisis rare), themacros.Ql \&.Fo(function open)and.Ql \&.Fc(function close)may be used with.Ql \&.Fa(function argument)to get around the limitation. For example:.Bd -literal -offset indent\&.Fo "int res_mkquery"\&.Fa "int op"\&.Fa "char *dname"\&.Fa "int class"\&.Fa "int type"\&.Fa "char *data"\&.Fa "int datalen"\&.Fa "struct rrec *newrr"\&.Fa "char *buf"\&.Fa "int buflen"\&.Fc.Ed.PpProduces:.Bd -filled -offset indent.Fo "int res_mkquery".Fa "int op".Fa "char *dname".Fa "int class".Fa "int type".Fa "char *data".Fa "int datalen".Fa "struct rrec *newrr".Fa "char *buf".Fa "int buflen".Fc.Ed.PpThe.Ql \&.Foand.Ql \&.Fcmacros are parsed and are callable.In the.Sx SYNOPSISsection, the function will always begin atthe beginning of line.If there is more than one functionpresented in the.Sx SYNOPSISsection and a function type has not been
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -