groff_mdoc(7) Miscellaneous Information Manual groff_mdoc(7) Name groff_mdoc - compose BSD-style manual (man) pages with GNU roff Synopsis groff -mdoc file ... Description The GNU implementation of the mdoc macro package is part of the groff(1) document formatting system. mdoc is a structurally- and semantically- oriented package for writing UNIX manual pages with troff(1). Its predecessor, the man(7) package, primarily addressed page layout and presentational concerns, leaving the selection of fonts and other typesetting details to the individual author. This discretion has led to divergent styling practices among authors using it. mdoc organizes its macros into domains. The page structure domain lays out the page and comprises titles, section headings, displays, and lists. The general text domain supplies macros to quote or style text, or to interpolate common noun phrases. The manual domain offers semantic macros corresponding to the terminology used by practitioners in discussion of UNIX commands, routines, and files. Manual domain macros distinguish command-line arguments and options, function names, function parameters, pathnames, variables, cross references to other manual pages, and so on. These terms are meaningful both to the author and the readers of a manual page. It is hoped that the resulting increased consistency of the man page corpus will enable easier translation to future documentation tools. Throughout UNIX documentation, a manual entry is referred to simply as a "man page", regardless of its length, without gendered implication, and irrespective of the macro package selected for its composition. Getting started The mdoc package attempts to simplify man page authorship and maintenance without requiring mastery of the roff language. This document presents only essential facts about roff. For further background, including a discussion of basic typographical concepts like "breaking", "filling", and "adjustment", see roff(7). Specialized units of measurement also arise, namely ens, vees, inches, and points, abbreviated "n", "v", "i", and "p", respectively; see section Measurements of groff(7). For brief examples, we employ an arrow notation illustrating a transformation of input on the left to rendered output on the right. Consider the .Dq macro, which double-quotes its arguments. .Dq man page -> "man page" Usage An mdoc macro is called by placing the roff control character, `.' (dot) at the beginning of a line followed by its name. In this document, we often discuss a macro name with this leading dot to identify it clearly, but the dot is not part of its name. Space or tab characters can separate the dot from the macro name. Arguments may follow, separated from the macro name and each other by spaces, but not tabs. The dot at the beginning of the line prepares the formatter to expect a macro name. A dot followed immediately by a newline is ignored; this is called the empty request. To begin an input line with a dot (or a neutral apostrophe `'') in some context other than a macro call, precede it with the `\&' escape sequence; this is a dummy character, not formatted for output. The backslash is the roff escape character; it can appear anywhere and it always followed by at least one more character. If followed by a newline, the backslash escapes the input line break; you can thus keep input lines to a reasonable length without affecting their interpretation. Macros in GNU troff accept an unlimited number of arguments, in contrast to other troffs that often can't handle more than nine. In limited cases, arguments may be continued or extended on the next input line without resort to the `\newline' escape sequence; see subsection Extended arguments below. Neutral double quotes " can be used to group multiple words into an argument; see subsection Passing space characters in an argument below. Most of mdoc's general text and manual domain macros parse their argument lists for callable macro names. This means that an argument in the list matching a general text or manual domain macro name (and defined to be callable) will be called with the remaining arguments when it is encountered. In such cases, the argument, although the name of a macro, is not preceded by a dot. Macro calls can thus be nested. This approach to macro argument processing is a unique characteristic of the mdoc package, not a general feature of roff syntax. For example, the option macro, .Op, may call the flag and argument macros, .Fl and .Ar, to specify an optional flag with an argument. .Op Fl s Ar bytes -> [-s bytes] To prevent a word from being interpreted as a macro name, precede it with the dummy character. .Op \&Fl s \&Ar bytes -> [Fl s Ar bytes] In this document, macros whose argument lists are parsed for callable arguments are referred to as parsed, and those that may be called from an argument list are referred to as callable. This usage is a technical faux pas, since all mdoc macros are in fact interpreted (unless prevented with `\&'), but as it is cumbersome to constantly refer to macros as "being able to call other macros", we employ the term "parsed" instead. Except where explicitly stated, all mdoc macros are parsed and callable. In the following, we term an mdoc macro that starts a line (with a leading dot) a command if a distinction from those appearing as arguments of other macros is necessary. Passing space characters in an argument Sometimes it is desirable to give a macro an argument containing one or more space characters, for instance to specify a particular arrangement of arguments demanded by the macro. Additionally, quoting multi-word arguments that are to be treated the same makes mdoc work faster; macros that parse arguments do so once (at most) for each. For example, the function command .Fn expects its first argument to be the name of a function and any remaining arguments to be function parameters. Because C language standards mandate the inclusion of types and identifiers in the parameter lists of function definitions, each `Fn' parameter after the first will be at least two words in length, as in "int foo". There are a few ways to embed a space in a macro argument. One is to use the unadjustable space escape sequence \space. The formatter treats this escape sequence as if it were any other printable character, and will not break a line there as it would a word space when the output line is full. This method is useful for macro arguments that are not expected to straddle an output line boundary, but has a drawback: this space does not adjust as others do when the output line is formatted. An alternative is to use the unbreakable space escape sequence, `\~', which cannot break but does adjust. This groff extension is widely but not perfectly portable. Another method is to enclose the string in double quotes. .Fn fetch char\ *str -> fetch(char *str) .Fn fetch char\~*str -> fetch(char *str) .Fn fetch "char *str" -> fetch(char *str) If the `\' before the space in the first example or the double quotes in the third example were omitted, `.Fn' would see three arguments, and the result would contain an undesired comma. .Fn fetch char *str -> fetch(char, *str) Trailing space characters It is wise to remove trailing spaces from the ends of input lines. Should the need arise to put a formattable space at the end of a line, do so with the unadjustable or unbreakable space escape sequences. Formatting the backslash glyph When you need the roff escape character `\' to appear in the output, use `\e' or `\(rs' instead. Technically, `\e' formats the current escape character; it works reliably as long as no roff request is used to change it, which should never happen in man pages. `\(rs' is a groff special character escape sequence that explicitly formats the "reverse solidus" (backslash) glyph. Other possible pitfalls groff mdoc warns when an empty input line is found outside of a display, a topic presented in subsection Examples and displays below. Use empty requests to space the source document for maintenance. Leading spaces cause a break and are formatted. Avoid this behaviour if possible. Similarly, do not put more than one space between words in an ordinary text line; they are not "normalized" to a single space as other text formatters might do. Don't try to use the neutral double quote character `"' to represent itself in an argument. Use the special character escape sequence `\(dq' to format it. Further, this glyph should not be used for conventional quotation; mdoc offers several quotation macros. See subsection Enclosure and quoting macros below. The formatter attempts to detect the ends of sentences and by default puts the equivalent of two spaces between sentences on the same output line; see roff(7). To defeat this detection in a parsed list of macro arguments, put `\&' before the punctuation mark. Thus, The .Ql . character. .Pp The .Ql \&. character. .Pp .No test . test .Pp .No test. test gives The `'. character The `.' character. test. test test. test as output. As can be seen in the first and third output lines, mdoc handles punctuation characters specially in macro arguments. This will be explained in section General syntax below. A comment in the source file of a man page can begin with `.\"' at the start of an input line, `\"' after other input, or `\#' anywhere (the last is a groff extension); the remainder of any such line is ignored. A man page template Use mdoc to construct a man page from the following template. .\" The following three macro calls are required. .Dd date .Dt topic [section-identifier [section-keyword-or-title]] .Os [package-or-operating system [version-or-release]] .Sh Name .Nm topic .Nd summary-description .\" The next heading is used in sections 2 and 3. .\" .Sh Library .\" The next heading is used in sections 1-4, 6, 8, and 9. .Sh Synopsis .Sh Description .\" Uncomment and populate the following sections as needed. .\" .Sh "Implementation notes" .\" The next heading is used in sections 2, 3, and 9. .\" .Sh "Return values" .\" The next heading is used in sections 1, 3, 6, and 8. .\" .Sh Environment .\" .Sh Files .\" The next heading is used in sections 1, 6, and 8. .\" .Sh "Exit status" .\" .Sh Examples .\" The next heading is used in sections 1, 4, 6, 8, and 9. .\" .Sh Diagnostics .\" .Sh Compatibility .\" The next heading is used in sections 2, 3, 4, and 9. .\" .Sh Errors .\" .Sh "See also" .\" .Sh Standards .\" .Sh History .\" .Sh Authors .\" .Sh Caveats .\" .Sh Bugs The first items in the template are the commands .Dd, .Dt, and .Os. They identify the page and are discussed below in section Title macros. The remaining items in the template are section headings (.Sh); of which Name and Description are mandatory. These headings are discussed in section Page structure domain, which follows section Manual domain. Familiarize yourself with manual domain macros first; we use them to illustrate the use of page structure domain macros. Conventions In the descriptions of macros below, square brackets surround optional arguments. An ellipsis (`...') represents repetition of the preceding argument zero or more times. Alternative values of a parameter are separated with `|'. If a mandatory parameter can take one of several alternative values, use braces to enclose the set, with spaces and `|' separating the items. ztar {c | x} [-w [-y | -z]] [-f archive] member ... An alternative to using braces is to separately synopsize distinct operation modes, particularly if the list of valid optional arguments is dependent on the user's choice of a mandatory parameter. ztar c [-w [-y | -z]] [-f archive] member ... ztar x [-w [-y | -z]] [-f archive] member ... Most macros affect subsequent arguments until another macro or a newline is encountered. For example, `.Li ls Bq Ar file' doesn't produce `ls [file]', but `ls [file]'. Consequently, a warning message is emitted for many commands if the first argument is itself a macro, since it cancels the effect of the preceding one. On rare occasions, you might want to format a word along with surrounding brackets as a literal. .Li "ls [file]" -> ls [file] # list any files named e, f, i, or l Many macros possess an implicit width, used when they are contained in lists and displays. If you avoid relying on these default measurements, you escape potential conflicts with site-local modifications of the mdoc package. Explicit -width and -offset arguments to the .Bl and .Bd macros are preferable. Title macros We present the mandatory title macros first due to their importance even though they formally belong to the page structure domain macros. They designate the topic, date of last revision, and the operating system or software project associated with the page. Call each once at the beginning of the document. They populate the page headers and footers, which are in roff parlance termed "titles". .Dd date This first macro of any mdoc manual records the last modification date of the document source. Arguments are concatenated and separated with space characters. Historically, date was written in U.S. traditional format, "Month day , year" where Month is the full month name in English, day an integer without a leading zero, and year the four-digit year. This localism is not enforced, however. You may prefer ISO 8601 format, YYYY-MM-DD. A date of the form `$Mdocdate: Month day year $' is also recognized. It is used in OpenBSD manuals to automatically insert the current date when committing. This macro is neither callable nor parsed. .Dt topic [section-identifier [section-keyword-or-title]] topic is the subject of the man page. A section-identifier that begins with an integer in the range 1-9 or is one of the words `unass', `draft', or `paper' selects a predefined section title. This use of "section" has nothing to do with the section headings otherwise discussed in this page; it arises from the organizational scheme of printed and bound Unix manuals. In this implementation, the following titles are defined for integral section numbers. 1 2 3 4 5 6 7 8 9 A section title may be arbitrary or one of the following abbreviations. USD PS1 AMD SMM URM PRM KM IND LOCAL CON For compatibility, `MMI' can be used for `IND', and `LOC' for `LOCAL'. Values from the previous table will specify a new section title. If section-keyword-or-title designates a computer architecture recognized by groff mdoc, its value is prepended to the default section title as specified by the second parameter. By default, the following architecture keywords are defined. acorn26, acorn32, algor, alpha, amd64, amiga, amigappc, arc, arm, arm26, arm32, armish, atari, aviion, beagle, bebox, cats, cesfic, cobalt, dreamcast, emips, evbarm, evbmips, evbppc, evbsh3, ews4800mips, hp300, hp700, hpcarm, hpcmips, hpcsh, hppa, hppa64, i386, ia64, ibmnws, iyonix, landisk, loongson, luna68k, luna88k, m68k, mac68k, macppc, mips, mips64, mipsco, mmeye, mvme68k, mvme88k, mvmeppc, netwinder, news68k, newsmips, next68k, ofppc, palm, pc532, playstation2, pmax, pmppc, powerpc, prep, rs6000, sandpoint, sbmips, sgi, sgimips, sh3, shark, socppc, solbourne, sparc, sparc64, sun2, sun3, tahoe, vax, x68k, x86_64, xen, zaurus If a section title is not determined after the above matches have been attempted, section-keyword-or-title is used. The effects of varying `.Dt' arguments on the page header content are shown below. Observe how `\&' prevents the numeral 2 from being used to look up a predefined section title. .Dt foo 2 -> foo(2) System Calls Manual foo(2) .Dt foo 2 m68k -> foo(2) m68k System Calls Manual foo(2) .Dt foo 2 baz -> foo(2) System Calls Manual foo(2) .Dt foo \&2 baz -> foo(2) baz foo(2) .Dt foo "" baz -> foo baz foo .Dt foo M Z80 -> foo(M) Z80 foo(M) roff strings define section titles and architecture identifiers. Site-specific additions might be found in the file mdoc.local; see section Files below. This macro is neither callable nor parsed. .Os [operating-system-or-package-name [version-or-release]] This macro associates the document with a software distribution. When composing a man page to be included in the base installation of an operating system, do not provide an argument; mdoc will supply it. In this implementation, that default is "". It may be overridden in the site configuration file, mdoc.local; see section Files below. A portable software package maintaining its own man pages can supply its name and version number or release identifier as optional arguments. A version-or-release argument should use the standard nomenclature for the software specified. In the following table, recognized version-or-release arguments for some predefined operating systems are listed. As with .Dt, site additions might be defined in mdoc.local. ATT 7th, 7, III, 3, V, V.2, V.3, V.4 BSD 3, 4, 4.1, 4.2, 4.3, 4.3t, 4.3T, 4.3r, 4.3R, 4.4 NetBSD 0.8, 0.8a, 0.9, 0.9a, 1.0, 1.0a, 1.1, 1.2, 1.2a, 1.2b, 1.2c, 1.2d, 1.2e, 1.3, 1.3a, 1.4, 1.4.1, 1.4.2, 1.4.3, 1.5, 1.5.1, 1.5.2, 1.5.3, 1.6, 1.6.1, 1.6.2, 1.6.3, 2.0, 2.0.1, 2.0.2, 2.0.3, 2.1, 3.0, 3.0.1, 3.0.2, 3.0.3, 3.1, 3.1.1, 4.0, 4.0.1, 5.0, 5.0.1, 5.0.2, 5.1, 5.1.2, 5.1.3, 5.1.4, 5.2, 5.2.1, 5.2.2, 6.0, 6.0.1, 6.0.2, 6.0.3, 6.0.4, 6.0.5, 6.0.6, 6.1, 6.1.1, 6.1.2, 6.1.3, 6.1.4, 6.1.5, 7.0, 7.0.1, 7.0.2, 7.1, 7.1.1, 7.1.2, 7.2, 8.0, 8.1 FreeBSD 1.0, 1.1, 1.1.5, 1.1.5.1, 2.0, 2.0.5, 2.1, 2.1.5, 2.1.6, 2.1.7, 2.2, 2.2.1, 2.2.2, 2.2.5, 2.2.6, 2.2.7, 2.2.8, 2.2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 4.0, 4.1, 4.1.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.6.2, 4.7, 4.8, 4.9, 4.10, 4.11, 5.0, 5.1, 5.2, 5.2.1, 5.3, 5.4, 5.5, 6.0, 6.1, 6.2, 6.3, 6.4, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0, 8.1, 8.2, 8.3, 8.4, 9.0, 9.1, 9.2, 9.3, 10.0, 10.1, 10.2, 10.3, 10.4, 11.0, 11.1, 11.2, 11.3, 12.0, 12.1 OpenBSD 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 3.0, 3.1, 3.2, 3.3, 3.4, 3.5, 3.6, 3.7, 3.8, 3.9, 4.0, 4.1, 4.2, 4.3, 4.4, 4.5, 4.6, 4.7, 4.8, 4.9, 5.0, 5.1, 5.2, 5.3, 5.4, 5.5, 5.6, 5.7, 5.8, 5.9, 6.0, 6.1, 6.2, 6.3, 6.4, 6.5, 6.6 DragonFly 1.0, 1.1, 1.2, 1.3, 1.4, 1.5, 1.6, 1.7, 1.8, 1.8.1, 1.9, 1.10, 1.11, 1.12, 1.12.2, 1.13, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.9.1, 2.10, 2.10.1, 2.11, 2.12, 2.13, 3.0, 3.0.1, 3.0.2, 3.1, 3.2, 3.2.1, 3.2.2, 3.3, 3.4, 3.4.1, 3.4.2, 3.4.3, 3.5, 3.6, 3.6.1, 3.6.2, 3.7, 3.8, 3.8.1, 3.8.2, 4.0, 4.0.1, 4.0.2, 4.0.3, 4.0.4, 4.0.5, 4.0.6, 4.1, 4.2, 4.2.1, 4.2.2, 4.2.3, 4.2.4, 4.3, 4.4, 4.4.1, 4.4.2, 4.4.3, 4.5, 4.6, 4.6.1, 4.6.2, 4.7, 4.8, 4.8.1, 4.9, 5.0, 5.0.1, 5.0.2, 5.1, 5.2, 5.2.1, 5.2.2, 5.3, 5.4, 5.4.1, 5.4.2, 5.4.3, 5.5, 5.6, 5.6.1, 5.6.2 Darwin 8.0.0, 8.1.0, 8.2.0, 8.3.0, 8.4.0, 8.5.0, 8.6.0, 8.7.0, 8.8.0, 8.9.0, 8.10.0, 8.11.0, 9.0.0, 9.1.0, 9.2.0, 9.3.0, 9.4.0, 9.5.0, 9.6.0, 9.7.0, 9.8.0, 10.0.0, 10.1.0, 10.2.0, 10.3.0, 10.4.0, 10.5.0, 10.6.0, 10.7.0, 10.8.0, 11.0.0, 11.1.0, 11.2.0, 11.3.0, 11.4.0, 11.5.0, 12.0.0, 12.1.0, 12.2.0, 13.0.0, 13.1.0, 13.2.0, 13.3.0, 13.4.0, 14.0.0, 14.1.0, 14.2.0, 14.3.0, 14.4.0, 14.5.0, 15.0.0, 15.1.0, 15.2.0, 15.3.0, 15.4.0, 15.5.0, 15.6.0, 16.0.0, 16.1.0, 16.2.0, 16.3.0, 16.4.0, 16.5.0, 16.6.0, 17.0.0, 17.1.0, 17.2.0, 17.3.0, 17.4.0, 17.5.0, 17.6.0, 17.7.0, 18.0.0, 18.1.0, 18.2.0, 18.3.0, 18.4.0, 18.5.0, 18.6.0, 18.7.0, 19.0.0, 19.1.0, 19.2.0 Historically, the first argument used with .Dt was BSD or ATT. An unrecognized version argument after ATT is replaced with "UNIX"; for other predefined abbreviations, it is ignored and a warning diagnostic emitted. Otherwise, unrecognized arguments are displayed verbatim in the page footer. For instance, this page uses ".Os groff 1.23.0" whereas a locally produced page might employ ".Os "UXYZ CS Department"", omitting versioning. This macro is neither callable nor parsed. Introduction to manual and general text domains What's in a Name... The manual domain macro names are derived from the day to day informal language used to describe commands, subroutines and related files. Slightly different variations of this language are used to describe the three different aspects of writing a man page. First, there is the description of mdoc macro command usage. Second is the description of a UNIX command with mdoc macros, and third, the description of a command to a user in the verbal sense; that is, discussion of a command in the text of a man page. In the first case, troff macros are themselves a type of command; the general syntax for a troff command is: .Xx argument1 argument2 ... `.Xx' is a macro command, and anything following it are arguments to be processed. In the second case, the description of a UNIX command using the manual domain macros is a bit more involved; a typical Synopsis command line might be displayed as: filter [-flag] Here, filter is the command name and the bracketed string -flag is a flag argument designated as optional by the option brackets. In mdoc terms, and are called meta arguments; in this example, the user has to replace the meta expressions given in angle brackets with real file names. Note that in this document meta arguments are used to describe mdoc commands; in most man pages, meta variables are not specifically written with angle brackets. The macros that formatted the above example: .Nm filter .Op Fl flag .Ao Ar infile Ac Ao Ar outfile Ac In the third case, discussion of commands and command syntax includes both examples above, but may add more detail. The arguments and from the example above might be referred to as operands or file arguments. Some command-line argument lists are quite long: make [-eiknqrstv] [-D variable] [-d flags] [-f makefile] [-I directory] [-j max_jobs] [variable=value] [target ...] Here one might talk about the command make and qualify the argument, makefile, as an argument to the flag, -f, or discuss the optional file operand target. In the verbal context, such detail can prevent confusion, however the mdoc package does not have a macro for an argument to a flag. Instead the `Ar' argument macro is used for an operand or file argument like target as well as an argument to a flag like variable. The make command line was produced from: .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 Ns = Ns Ar value .Bk .Op Ar target ... .Ek The `.Bk' and `.Ek' macros are explained in Keeps. General Syntax The manual domain and general text domain macros share a similar syntax with a few minor deviations; most notably, `.Ar', `.Fl', `.Nm', and `.Pa' differ only when called without arguments; and `.Fn' and `.Xr' impose an order on their argument lists. All manual domain macros are capable of recognizing and properly handling punctuation, provided each punctuation character is separated by a leading space. If a command is given: .Ar sptr, ptr), The result is: sptr, ptr), The punctuation is not recognized and all is output in the font used by `.Ar'. If the punctuation is separated by a leading white space: .Ar sptr , ptr ) , The result is: sptr, ptr), The punctuation is now recognized and output in the default font distinguishing it from the argument strings. To remove the special meaning from a punctuation character, escape it with `\&'. The following punctuation characters are recognized by mdoc: . , : ; ( ) [ ] ? ! troff is limited as a macro language, and has difficulty when presented with a string containing certain mathematical, logical, or quotation character sequences: {+,-,/,*,%,<,>,<=,>=,=,==,&,`,',"} The problem is that troff may assume it is supposed to actually perform the operation or evaluation suggested by the characters. To prevent the accidental evaluation of these characters, escape them with `\&'. Typical syntax is shown in the first manual domain macro displayed below, `.Ad'. Manual domain Addresses The address macro identifies an address construct. Usage: .Ad
... .Ad addr1 addr1 .Ad addr1 . addr1. .Ad addr1 , file2 addr1, file2 .Ad f1 , f2 , f3 : f1, f2, f3: .Ad addr ) ) , addr)), The default width is 12n. Author Name The `.An' macro is used to specify the name of the author of the item being documented, or the name of the author of the actual manual page. Usage: .An ... .An "Joe Author" Joe Author .An "Joe Author" , Joe Author, .An "Joe Author" Aq nobody@FreeBSD.org Joe Author .An "Joe Author" ) ) , Joe Author)), The default width is 12n. In a section titled "Authors", `An' causes a break, allowing each new name to appear on its own line. If this is not desirable, .An -nosplit call will turn this off. To turn splitting back on, write .An -split Arguments The .Ar argument macro may be used whenever an argument is referenced. If called without arguments, `file ...' is output. This places the ellipsis in italics, which is ugly and incorrect, and will be noticed on terminals that underline text instead of using an oblique typeface. We recommend using `.Ar file No ...' instead. Usage: .Ar [] ... .Ar file ... .Ar file No ... file ... .Ar file1 file1 .Ar file1 . file1. .Ar file1 file2 file1 file2 .Ar f1 f2 f3 : f1 f2 f3: .Ar file ) ) , file)), The default width is 12n. Configuration Declaration (Section Four Only) The `.Cd' macro is used to demonstrate a config(8) declaration for a device interface in a section four manual. Usage: .Cd ... .Cd "device le0 at scode?" device le0 at scode? In a section titled "Synopsis", `Cd' causes a break before and after its arguments. The default width is 12n. Command Modifiers The command modifier is identical to the `.Fl' (flag) command with the exception that the `.Cm' macro does not assert a dash in front of every argument. Traditionally flags are marked by the preceding dash, however, some commands or subsets of commands do not use them. Command modifiers may also be specified in conjunction with interactive commands such as editor commands. See Flags. The default width is 10n. Defined Variables A variable (or constant) that is defined in an include file is specified by the macro `.Dv'. Usage: .Dv ... .Dv MAXHOSTNAMELEN MAXHOSTNAMELEN .Dv TIOCGPGRP ) TIOCGPGRP) The default width is 12n. Errnos The `.Er' errno macro specifies the error return value for section 2, 3, and 9 library routines. The second example below shows `.Er' used with the `.Bq' general text domain macro, as it would be used in a section two manual page. Usage: .Er ... .Er ENOENT ENOENT .Er ENOENT ) ; ENOENT); .Bq Er ENOTDIR [ENOTDIR] The default width is 17n. Environment Variables The `.Ev' macro specifies an environment variable. Usage: .Ev ... .Ev DISPLAY DISPLAY .Ev PATH . PATH. .Ev PRINTER ) ) , PRINTER)), The default width is 15n. Flags The `.Fl' macro handles command-line flags. It prepends a dash, `-', to the flag. For interactive command flags that are not prepended with a dash, the `.Cm' (command modifier) macro is identical, but without the dash. Usage: .Fl ... .Fl - .Fl cfv -cfv .Fl cfv . -cfv. .Cm cfv . cfv. .Fl s v t -s -v -t .Fl - , --, .Fl xyz ) , -xyz), .Fl | - | The `.Fl' macro without any arguments results in a dash representing stdin/stdout. Note that giving `.Fl' a single dash will result in two dashes. The default width is 12n. Function Declarations The `.Fd' macro is used in the Synopsis section with section two or three functions. It is neither callable nor parsed. Usage: .Fd ... .Fd "#include " #include In a section titled "Synopsis", `Fd' causes a break if a function has already been presented and a break has not occurred, leaving vertical space between one function declaration and the next. In a section titled "Synopsis", the `In' macro represents the #include statement, and is the short form of the above example. It specifies the C header file as being included in a C program. It also causes a break. While not in the "Synopsis" section, it represents the header file enclosed in angle brackets. Usage: .In
.In stdio.h .In stdio.h Function Types This macro is intended for the "Synopsis" section. It may be used anywhere else in the man page without problems, but its main purpose is to present the function type (in BSD kernel normal form) for the "Synopsis" of sections two and three. (It causes a break, allowing the function name to appear on the next line.) Usage: .Ft ... .Ft struct stat struct stat Functions (Library Routines) The `.Fn' macro is modeled on ANSI C conventions. Usage: .Fn [] ... .Fn getchar getchar() .Fn strlen ) , strlen()), .Fn align "char *ptr" , align(char *ptr), Note that any call to another macro signals the end of the `.Fn' call (it will insert a closing parenthesis at that point). For functions with many parameters (which is rare), the macros `.Fo' (function open) and `.Fc' (function close) may be used with `.Fa' (function argument). Example: .Ft int .Fo 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 Produces: int res_mkquery(int op, char *dname, int class, int type, char *data, int datalen, struct rrec *newrr, char *buf, int buflen) Typically, in a "Synopsis" section, the function delcaration will begin the line. If more than one function is presented in the "Synopsis" section and a function type has not been given, a break will occur, leaving vertical space between the current and prior function names. The default width values of `.Fn' and `.Fo' are 12n and 16n, respectively. Function Arguments The `.Fa' macro is used to refer to function arguments (parameters) outside of the Synopsis section of the manual or inside the Synopsis section if the enclosure macros `.Fo' and `.Fc' instead of `.Fn' are used. `.Fa' may also be used to refer to structure members. Usage: .Fa ... .Fa d_namlen ) ) , d_namlen)), .Fa iov_len iov_len The default width is 12n. Return Values The `.Rv' macro generates text for use in the Return values section. Usage: .Rv [-std] [ ...] For example, `.Rv -std atexit' produces: The atexit() function returns the value 0 if successful; otherwise the value -1 is returned and the global variable errno is set to indicate the error. The -std option is valid only for manual page sections 2 and 3. Currently, this macro does nothing if used without the -std flag. Exit Status The `.Ex' macro generates text for use in the Diagnostics section. Usage: .Ex [-std] [ ...] For example, `.Ex -std cat' produces: The cat utility exits 0 on success, and >0 if an error occurs. The -std option is valid only for manual page sections 1, 6 and 8. Currently, this macro does nothing if used without the -std flag. Interactive Commands The `.Ic' macro designates an interactive or internal command. Usage: .Ic ... .Ic :wq :wq .Ic "do while {...}" do while {...} .Ic setenv , unsetenv setenv, unsetenv The default width is 12n. Library Names The `.Lb' macro is used to specify the library where a particular function is compiled in. Usage: .Lb ... Available arguments to `.Lb' and their results are: libarchive Streaming Archive Library (libarchive, -larchive) libarm ARM Architecture Library (libarm, -larm) libarm32 ARM32 Architecture Library (libarm32, -larm32) libbluetooth Bluetooth Library (libbluetooth, -lbluetooth) libbsm Basic Security Module Library (libbsm, -lbsm) libc Standard C Library (libc, -lc) libc_r Reentrant C Library (libc_r, -lc_r) libcalendar Calendar Arithmetic Library (libcalendar, -lcalendar) libcam Common Access Method User Library (libcam, -lcam) libcdk Curses Development Kit Library (libcdk, -lcdk) libcipher FreeSec Crypt Library (libcipher, -lcipher) libcompat Compatibility Library (libcompat, -lcompat) libcrypt Crypt Library (libcrypt, -lcrypt) libcurses Curses Library (libcurses, -lcurses) libdevinfo Device and Resource Information Utility Library (libdevinfo, -ldevinfo) libdevstat Device Statistics Library (libdevstat, -ldevstat) libdisk Interface to Slice and Partition Labels Library (libdisk, -ldisk) libdwarf DWARF Access Library (libdwarf, -ldwarf) libedit Command Line Editor Library (libedit, -ledit) libelf ELF Access Library (libelf, -lelf) libevent Event Notification Library (libevent, -levent) libfetch File Transfer Library (libfetch, -lfetch) libform Curses Form Library (libform, -lform) libgeom Userland API Library for Kernel GEOM subsystem (libgeom, -lgeom) libgpib library "libgpib" libi386 i386 Architecture Library (libi386, -li386) libintl Internationalized Message Handling Library (libintl, -lintl) libipsec IPsec Policy Control Library (libipsec, -lipsec) libipx library "libipx" libiscsi iSCSI protocol library (libiscsi, -liscsi) libjail Jail Library (libjail, -ljail) libkiconv Kernel-side iconv Library (libkiconv, -lkiconv) libkse N:M Threading Library (libkse, -lkse) libkvm Kernel Data Access Library (libkvm, -lkvm) libm Math Library (libm, -lm) libm68k m68k Architecture Library (libm68k, -lm68k) libmagic Magic Number Recognition Library (libmagic, -lmagic) libmd Message Digest (MD4, MD5, etc.) Support Library (libmd, -lmd) libmemstat Kernel Memory Allocator Statistics Library (libmemstat, -lmemstat) libmenu Curses Menu Library (libmenu, -lmenu) libnetgraph Netgraph User Library (libnetgraph, -lnetgraph) libnetpgp Netpgp Signing, Verification, Encryption and Decryption (libnetpgp, -lnetpgp) libossaudio OSS Audio Emulation Library (libossaudio, -lossaudio) libpam Pluggable Authentication Module Library (libpam, -lpam) libpcap Packet capture Library (libpcap, -lpcap) libpci PCI Bus Access Library (libpci, -lpci) libpmc Performance Counters Library (libpmc, -lpmc) libposix POSIX Compatibility Library (libposix, -lposix) libprop Property Container Object Library (libprop, -lprop) libpthread POSIX Threads Library (libpthread, -lpthread) libpuffs puffs Convenience Library (libpuffs, -lpuffs) librefuse File System in Userspace Convenience Library (librefuse, -lrefuse) libresolv DNS Resolver Library (libresolv, -lresolv) librpcsec_gss RPC GSS-API Authentication Library (librpcsec_gss, -lrpcsec_gss) librpcsvc RPC Service Library (librpcsvc, -lrpcsvc) librt POSIX Real-time Library (librt, -lrt) libsdp Bluetooth Service Discovery Protocol User Library (libsdp, -lsdp) libssp Buffer Overflow Protection Library (libssp, -lssp) libSystem System Library (libSystem, -lSystem) libtermcap Termcap Access Library (libtermcap, -ltermcap) libterminfo Terminal Information Library (libterminfo, -lterminfo) libthr 1:1 Threading Library (libthr, -lthr) libufs UFS File System Access Library (libufs, -lufs) libugidfw File System Firewall Interface Library (libugidfw, -lugidfw) libulog User Login Record Library (libulog, -lulog) libusbhid USB Human Interface Devices Library (libusbhid, -lusbhid) libutil System Utilities Library (libutil, -lutil) libvgl Video Graphics Library (libvgl, -lvgl) libx86_64 x86_64 Architecture Library (libx86_64, -lx86_64) libz Compression Library (libz, -lz) Site-specific additions might be found in the file mdoc.local; see section Files below. In a section titled "Library", `Lb' causes a break before and after its arguments. Literals The `Li' literal macro may be used for special characters, symbolic constants, and other syntactical items that should be typed exactly as displayed. Usage: .Li ... .Li \en \n .Li M1 M2 M3 ; M1 M2 M3; .Li cntrl-D ) , cntrl-D), .Li 1024 ... 1024 ... The default width is 16n. Names The `Nm' macro is used for the document title or page topic. Upon its first call, it has the peculiarity of remembering its argument, which should always be the topic of the man page. When subsequently called without arguments, `Nm' regurgitates this initial name for the sole purpose of making less work for the author. Use of `Nm' is also appropriate when presenting a command synopsis for the topic of a man page in section 1, 6, or 8. Its behavior changes when presented with arguments of various forms. .Nm groff_mdoc groff_mdoc .Nm groff_mdoc .Nm \-mdoc -mdoc .Nm foo ) ) , foo)), .Nm : groff_mdoc: By default, the topic is set in boldface to reflect its prime importance in the discussion. Cross references to other man page topics should use `Xr'; including a second argument for the section number enables them to be hyperlinked. By default, cross-referenced topics are set in italics to avoid cluttering the page with boldface. The default width is 10n. Options The `.Op' macro places option brackets around any remaining arguments on the command line, and places any trailing punctuation outside the brackets. The macros `.Oo' and `.Oc' (which produce an opening and a closing option bracket, respectively) may be used across one or more lines or to specify the exact position of the closing parenthesis. Usage: .Op [