1 .\" $Id: mdoc.7,v 1.134 2010/07/15 23:50:15 schwarze Exp $
3 .\" Copyright (c) 2009, 2010 Kristaps Dzonsons <kristaps@bsd.lv>
4 .\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
6 .\" Permission to use, copy, modify, and distribute this software for any
7 .\" purpose with or without fee is hereby granted, provided that the above
8 .\" copyright notice and this permission notice appear in all copies.
10 .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
11 .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
12 .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
13 .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
14 .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
15 .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
16 .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
18 .Dd $Mdocdate: July 15 2010 $
23 .Nd mdoc language reference
27 language is used to format
30 manuals. In this reference document, we describe its syntax, structure,
31 and usage. Our reference implementation is mandoc; the
33 section describes compatibility with other troff \-mdoc implementations.
37 document follows simple rules: lines beginning with the control
40 are parsed for macros. Other lines are interpreted within the scope of
42 .Bd -literal -offset indent
43 \&.Sh Macro lines change control state.
44 Other lines are interpreted within the current state.
48 documents may contain only graphable 7-bit ASCII characters, the space
49 character, and, in certain circumstances, the tab character. All
56 whether in a macro or free-form text line, is ignored to the end of
57 line. A macro line with only a control character and comment escape,
59 is also ignored. Macro lines with only a control character and optionally
60 whitespace are stripped from input.
61 .Ss Reserved Characters
62 Within a macro line, the following characters are reserved:
64 .Bl -tag -width Ds -offset indent -compact
89 Use of reserved characters is described in
91 For general use in macro lines, these characters must either be escaped
92 with a non-breaking space
94 or, if applicable, an appropriate escape sequence used.
95 .Ss Special Characters
96 Special characters may occur in both macro and free-form lines.
97 Sequences begin with the escape character
99 followed by either an open-parenthesis
101 for two-character sequences; an open-bracket
103 for n-character sequences (terminated at a close-bracket
105 or a single one-character sequence.
116 Terms may be text-decorated using the
118 escape followed by an indicator: B (bold), I, (italic), R (Roman), or P
119 (revert to previous mode):
121 .D1 \efBbold\efR \efIitalic\efP
123 A numerical representation 3, 2, or 1 (bold, italic, and Roman,
124 respectively) may be used instead.
125 A text decoration is valid within
126 the current font scope only: if a macro opens a font scope alongside
127 its own scope, such as
130 in-scope invocations of
132 are only valid within the font scope of the macro.
135 is specified outside of any font scope, such as in unenclosed, free-form
136 text, it will affect the remainder of the document.
138 Text may also be sized with the
140 escape, whose syntax is one of
142 for one-digit numerals;
146 for two-digit numerals; and
152 for arbitrary-digit numerals:
155 .D1 \es[+10]much bigger\es[-10]
156 .D1 \es+(10much bigger\es-(10
157 .D1 \es+'100'much much bigger\es-'100'
163 which encourages semantic annotation.
164 .Ss Predefined Strings
167 also defined a set of package-specific
168 .Dq predefined strings ,
170 .Sx Special Characters ,
171 mark special output characters and strings by way of input codes.
172 Predefined strings are escaped with the slash-asterisk,
190 Whitespace consists of the space character.
191 In free-form lines, whitespace is preserved within a line; un-escaped
192 trailing spaces are stripped from input (unless in a literal context).
193 Blank free-form lines, which may include whitespace, are only permitted
194 within literal contexts.
196 In macro lines, whitespace delimits arguments and is discarded.
197 If arguments are quoted, whitespace within the quotes is retained.
199 Macro arguments may be quoted with a double-quote to group
200 space-delimited terms or to retain blocks of whitespace.
201 A quoted argument begins with a double-quote preceded by whitespace.
202 The next double-quote not pair-wise adjacent to another double-quote
203 terminates the literal, regardless of surrounding whitespace.
211 Note that any quoted term, be it argument or macro, is indiscriminately
212 considered literal text.
213 Thus, the following produces
215 .Bd -literal -offset indent
219 In free-form mode, quotes are regarded as opaque text.
221 There are several macros in
223 that require a date argument.
224 The canonical form for dates is the American format:
226 .D1 Cm Month Day , Year
230 value is an optionally zero-padded numeral.
233 value is the full month name.
236 value is the full four-digit year.
238 Reduced form dates are broken-down canonical form dates:
243 Some examples of valid dates follow:
245 .D1 "May, 2009" Pq reduced form
246 .D1 "2009" Pq reduced form
247 .D1 "May 20, 2009" Pq canonical form
249 Many macros support scaled widths for their arguments, such as
250 stipulating a two-inch list indentation with the following:
251 .Bd -literal -offset indent
255 The syntax for scaled widths is
256 .Sq Li [+-]?[0-9]*.[0-9]*[:unit:] ,
257 where a decimal must be preceded or proceeded by at least one digit.
258 Negative numbers, while accepted, are truncated to zero.
259 The following scaling units are accepted:
261 .Bl -tag -width Ds -offset indent -compact
274 default vertical span
286 default horizontal span
291 Using anything other than
297 is necessarily non-portable across output media.
301 When composing a manual, make sure that your sentences end at the end of
303 By doing so, front-ends will be able to apply the proper amount of
304 spacing after the end of sentence (unescaped) period, exclamation mark,
305 or question mark followed by zero or more non-sentence closing
312 The proper spacing is also intelligently preserved if a sentence ends at
313 the boundary of a macro line, e.g.,
316 .D1 \&Fl T \&Ns \&Cm ascii \.
320 document consists of a document prologue followed by one or more
323 The prologue, which consists of (in order) the
328 macros, is required for every document.
330 The first section (sections are denoted by
332 must be the NAME section, consisting of at least one
337 Following that, convention dictates specifying at least the
341 sections, although this varies between manual sections.
343 The following is a well-formed skeleton
346 .Bd -literal -offset indent
352 \&.Nd a description goes here
353 \&.\e\*q The next is for sections 2, 3, & 9 only.
362 utility processes files ...
363 \&.\e\*q .Sh IMPLEMENTATION NOTES
364 \&.\e\*q The next is for sections 2, 3, & 9 only.
365 \&.\e\*q .Sh RETURN VALUES
366 \&.\e\*q The next is for sections 1, 6, 7, & 8 only.
367 \&.\e\*q .Sh ENVIRONMENT
369 \&.\e\*q The next is for sections 1 & 8 only.
370 \&.\e\*q .Sh EXIT STATUS
371 \&.\e\*q .Sh EXAMPLES
372 \&.\e\*q The next is for sections 1, 4, 6, 7, & 8 only.
373 \&.\e\*q .Sh DIAGNOSTICS
374 \&.\e\*q The next is for sections 2, 3, & 9 only.
376 \&.\e\*q .Sh SEE ALSO
377 \&.\e\*q .Xr foobar 1
378 \&.\e\*q .Sh STANDARDS
383 \&.\e\*q .Sh SECURITY CONSIDERATIONS
388 document are conventionally ordered as they appear above.
389 Sections should be composed as follows:
390 .Bl -ohang -offset Ds
392 The name(s) and a short description of the documented material.
393 The syntax for this as follows:
394 .Bd -literal -offset indent
398 \&.Nd a short description
403 macro(s) must precede the
412 The name of the library containing the documented material, which is
413 assumed to be a function in a section 2, 3, or 9 manual.
414 The syntax for this is as follows:
415 .Bd -literal -offset indent
422 Documents the utility invocation syntax, function call syntax, or device
425 For the first, utilities (sections 1, 6, and 8), this is
426 generally structured as follows:
427 .Bd -literal -offset indent
438 For the second, function calls (sections 2, 3, 9):
439 .Bd -literal -offset indent
440 \&.Vt extern const char *global;
443 \&.Fn foo "const char *src"
445 \&.Fn bar "const char *src"
448 And for the third, configurations (section 4):
449 .Bd -literal -offset indent
450 \&.Cd \*qit* at isa? port 0x2e\*q
451 \&.Cd \*qit* at isa? port 0x4e\*q
454 Manuals not in these sections generally don't need a
457 Some macros are displayed differently in the
459 section, particularly
469 All of these macros are output on their own line. If two such
470 dissimilar macros are pair-wise invoked (except for
476 they are separated by a vertical space, unless in the case of
481 which are always separated by vertical space.
483 When text and macros following an
485 macro starting an input line span multiple output lines,
486 all output lines but the first will be indented to align
487 with the text immediately following the
489 macro, up to the next
494 macro or the end of an enclosing block, whichever comes first.
496 This expands upon the brief, one-line description in
498 It usually contains a break-down of the options (if documenting a
500 .Bd -literal -offset indent
501 The arguments are as follows:
502 \&.Bl \-tag \-width Ds
504 Print verbose information.
508 Manuals not documenting a command won't include the above fragment.
509 .It Em IMPLEMENTATION NOTES
510 Implementation-specific notes should be kept here.
511 This is useful when implementing standard functions that may have side
512 effects or notable algorithmic implications.
514 This section is the dual of
516 which is used for commands.
517 It documents the return values of functions in sections 2, 3, and 9.
522 Documents any usages of environment variables, e.g.,
528 Documents files used.
529 It's helpful to document both the file and a short description of how
530 the file is used (created, modified, etc.).
535 Command exit status for section 1, 6, and 8 manuals.
536 This section is the dual of
538 which is used for functions.
539 Historically, this information was described in
541 a practise that is now discouraged.
547 This often contains snippets of well-formed, well-tested invocations.
548 Make doubly sure that your examples work properly!
550 Documents error conditions.
551 This is most useful in section 4 manuals.
552 Historically, this section was used in place of
554 for manuals in sections 1, 6, and 8; however, this practise is
561 Documents error handling in sections 2, 3, and 9.
566 References other manuals with related topics.
567 This section should exist for most manuals.
568 Cross-references should conventionally be ordered first by section, then
574 References any standards implemented or used.
575 If not adhering to any standards, the
577 section should be used instead.
582 The history of any manual without a
584 section should be described in this section.
586 Credits to authors, if applicable, should appear in this section.
587 Authors should generally be noted by both name and an e-mail address.
592 Explanations of common misuses and misunderstandings should be explained
595 Extant bugs should be described in this section.
596 .It Em SECURITY CONSIDERATIONS
597 Documents any security precautions that operators should consider.
600 Macros are one to three three characters in length and begin with a
603 at the beginning of the line.
604 An arbitrary amount of whitespace may sit between the control character
606 Thus, the following are equivalent:
607 .Bd -literal -offset indent
612 The syntax of a macro depends on its classification.
615 refers to macro arguments, which may be followed by zero or more
619 opens the scope of a macro; and if specified,
625 column indicates that the macro may be called subsequent to the initial
627 If a macro is not callable, then its invocation after the initial line
628 macro is interpreted as opaque text, such that
635 column indicates whether the macro may be followed by further
636 (ostensibly callable) macros.
637 If a macro is not parsable, subsequent macro invocations on the line
638 will be interpreted as opaque text.
642 column, if applicable, describes closure rules.
643 .Ss Block full-explicit
644 Multi-line scope closed by an explicit closing macro.
645 All macros contains bodies; only
648 .Bd -literal -offset indent
649 \&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB
654 .Bl -column -compact -offset indent "MacroX" "CallableX" "ParsableX" "closed by XXX"
655 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Scope
656 .It Sx \&Bd Ta \&No Ta \&No Ta closed by Sx \&Ed
657 .It Sx \&Bf Ta \&No Ta \&No Ta closed by Sx \&Ef
658 .It Sx \&Bk Ta \&No Ta \&No Ta closed by Sx \&Ek
659 .It Sx \&Bl Ta \&No Ta \&No Ta closed by Sx \&El
660 .It Sx \&Ed Ta \&No Ta \&No Ta opened by Sx \&Bd
661 .It Sx \&Ef Ta \&No Ta \&No Ta opened by Sx \&Bf
662 .It Sx \&Ek Ta \&No Ta \&No Ta opened by Sx \&Bk
663 .It Sx \&El Ta \&No Ta \&No Ta opened by Sx \&Bl
665 .Ss Block full-implicit
666 Multi-line scope closed by end-of-file or implicitly by another macro.
667 All macros have bodies; some
675 don't have heads; only one
680 .Bd -literal -offset indent
681 \&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead... \(lBTa head...\(rB\(rB
685 .Bl -column -compact -offset indent "MacroX" "CallableX" "ParsableX" "closed by XXXXXXXXXXX"
686 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Scope
687 .It Sx \&It Ta \&No Ta Yes Ta closed by Sx \&It , Sx \&El
688 .It Sx \&Nd Ta \&No Ta \&No Ta closed by Sx \&Sh
689 .It Sx \&Nm Ta \&No Ta Yes Ta closed by Sx \&Nm , Sx \&Sh , Sx \&Ss
690 .It Sx \&Sh Ta \&No Ta \&No Ta closed by Sx \&Sh
691 .It Sx \&Ss Ta \&No Ta \&No Ta closed by Sx \&Sh , Sx \&Ss
697 .Sx Block full-implicit
698 macro only when invoked as the first macro
701 section line, else it is
703 .Ss Block partial-explicit
704 Like block full-explicit, but also with single-line scope.
705 Each has at least a body and, in limited circumstances, a head
712 .Bd -literal -offset indent
713 \&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB
715 \&.Yc \(lBtail...\(rB
717 \&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB \
718 \(lBbody...\(rB \&Yc \(lBtail...\(rB
721 .Bl -column "MacroX" "CallableX" "ParsableX" "closed by XXXX" -compact -offset indent
722 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Scope
723 .It Sx \&Ac Ta Yes Ta Yes Ta opened by Sx \&Ao
724 .It Sx \&Ao Ta Yes Ta Yes Ta closed by Sx \&Ac
725 .It Sx \&Bc Ta Yes Ta Yes Ta closed by Sx \&Bo
726 .It Sx \&Bo Ta Yes Ta Yes Ta opened by Sx \&Bc
727 .It Sx \&Brc Ta Yes Ta Yes Ta opened by Sx \&Bro
728 .It Sx \&Bro Ta Yes Ta Yes Ta closed by Sx \&Brc
729 .It Sx \&Dc Ta Yes Ta Yes Ta opened by Sx \&Do
730 .It Sx \&Do Ta Yes Ta Yes Ta closed by Sx \&Dc
731 .It Sx \&Ec Ta Yes Ta Yes Ta opened by Sx \&Eo
732 .It Sx \&Eo Ta Yes Ta Yes Ta closed by Sx \&Ec
733 .It Sx \&Fc Ta Yes Ta Yes Ta opened by Sx \&Fo
734 .It Sx \&Fo Ta \&No Ta \&No Ta closed by Sx \&Fc
735 .It Sx \&Oc Ta Yes Ta Yes Ta closed by Sx \&Oo
736 .It Sx \&Oo Ta Yes Ta Yes Ta opened by Sx \&Oc
737 .It Sx \&Pc Ta Yes Ta Yes Ta closed by Sx \&Po
738 .It Sx \&Po Ta Yes Ta Yes Ta opened by Sx \&Pc
739 .It Sx \&Qc Ta Yes Ta Yes Ta opened by Sx \&Oo
740 .It Sx \&Qo Ta Yes Ta Yes Ta closed by Sx \&Oc
741 .It Sx \&Re Ta \&No Ta \&No Ta opened by Sx \&Rs
742 .It Sx \&Rs Ta \&No Ta \&No Ta closed by Sx \&Re
743 .It Sx \&Sc Ta Yes Ta Yes Ta opened by Sx \&So
744 .It Sx \&So Ta Yes Ta Yes Ta closed by Sx \&Sc
745 .It Sx \&Xc Ta Yes Ta Yes Ta opened by Sx \&Xo
746 .It Sx \&Xo Ta Yes Ta Yes Ta closed by Sx \&Xc
748 .Ss Block partial-implicit
749 Like block full-implicit, but with single-line scope closed by
750 .Sx Reserved Characters
752 .Bd -literal -offset indent
753 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBbody...\(rB \(lBres...\(rB
756 .Bl -column "MacroX" "CallableX" "ParsableX" -compact -offset indent
757 .It Em Macro Ta Em Callable Ta Em Parsable
758 .It Sx \&Aq Ta Yes Ta Yes
759 .It Sx \&Bq Ta Yes Ta Yes
760 .It Sx \&Brq Ta Yes Ta Yes
761 .It Sx \&D1 Ta \&No Ta \&Yes
762 .It Sx \&Dl Ta \&No Ta Yes
763 .It Sx \&Dq Ta Yes Ta Yes
764 .It Sx \&Op Ta Yes Ta Yes
765 .It Sx \&Pq Ta Yes Ta Yes
766 .It Sx \&Ql Ta Yes Ta Yes
767 .It Sx \&Qq Ta Yes Ta Yes
768 .It Sx \&Sq Ta Yes Ta Yes
769 .It Sx \&Vt Ta Yes Ta Yes
775 .Sx Block partial-implicit
776 only when invoked as the first macro
779 section line, else it is
783 .Sx Reserved Characters ,
784 end of line, fixed argument lengths, and/or subsequent macros.
785 In-line macros have only text children.
786 If a number (or inequality) of arguments is
788 then the macro accepts an arbitrary number of arguments.
789 .Bd -literal -offset indent
790 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBargs...\(rB \(lbres...\(rb
792 \&.Yo \(lB\-arg \(lBval...\(rB\(rB \(lBargs...\(rB Yc...
794 \&.Yo \(lB\-arg \(lBval...\(rB\(rB arg0 arg1 argN
797 .Bl -column "MacroX" "CallableX" "ParsableX" "Arguments" -compact -offset indent
798 .It Em Macro Ta Em Callable Ta Em Parsable Ta Em Arguments
799 .It Sx \&%A Ta \&No Ta \&No Ta >0
800 .It Sx \&%B Ta \&No Ta \&No Ta >0
801 .It Sx \&%C Ta \&No Ta \&No Ta >0
802 .It Sx \&%D Ta \&No Ta \&No Ta >0
803 .It Sx \&%I Ta \&No Ta \&No Ta >0
804 .It Sx \&%J Ta \&No Ta \&No Ta >0
805 .It Sx \&%N Ta \&No Ta \&No Ta >0
806 .It Sx \&%O Ta \&No Ta \&No Ta >0
807 .It Sx \&%P Ta \&No Ta \&No Ta >0
808 .It Sx \&%Q Ta \&No Ta \&No Ta >0
809 .It Sx \&%R Ta \&No Ta \&No Ta >0
810 .It Sx \&%T Ta \&No Ta \&No Ta >0
811 .It Sx \&%U Ta \&No Ta \&No Ta >0
812 .It Sx \&%V Ta \&No Ta \&No Ta >0
813 .It Sx \&Ad Ta Yes Ta Yes Ta n
814 .It Sx \&An Ta Yes Ta Yes Ta n
815 .It Sx \&Ap Ta Yes Ta Yes Ta 0
816 .It Sx \&Ar Ta Yes Ta Yes Ta n
817 .It Sx \&At Ta Yes Ta Yes Ta 1
818 .It Sx \&Bsx Ta Yes Ta Yes Ta n
819 .It Sx \&Bt Ta \&No Ta \&No Ta 0
820 .It Sx \&Bx Ta Yes Ta Yes Ta n
821 .It Sx \&Cd Ta Yes Ta Yes Ta >0
822 .It Sx \&Cm Ta Yes Ta Yes Ta n
823 .It Sx \&Db Ta \&No Ta \&No Ta 1
824 .It Sx \&Dd Ta \&No Ta \&No Ta >0
825 .It Sx \&Dt Ta \&No Ta \&No Ta n
826 .It Sx \&Dv Ta Yes Ta Yes Ta n
827 .It Sx \&Dx Ta Yes Ta Yes Ta n
828 .It Sx \&Em Ta Yes Ta Yes Ta >0
829 .It Sx \&En Ta \&No Ta \&No Ta 0
830 .It Sx \&Er Ta Yes Ta Yes Ta >0
831 .It Sx \&Es Ta \&No Ta \&No Ta 0
832 .It Sx \&Ev Ta Yes Ta Yes Ta n
833 .It Sx \&Ex Ta \&No Ta \&No Ta n
834 .It Sx \&Fa Ta Yes Ta Yes Ta n
835 .It Sx \&Fd Ta \&No Ta \&No Ta >0
836 .It Sx \&Fl Ta Yes Ta Yes Ta n
837 .It Sx \&Fn Ta Yes Ta Yes Ta >0
838 .It Sx \&Fr Ta \&No Ta \&No Ta n
839 .It Sx \&Ft Ta Yes Ta Yes Ta n
840 .It Sx \&Fx Ta Yes Ta Yes Ta n
841 .It Sx \&Hf Ta \&No Ta \&No Ta n
842 .It Sx \&Ic Ta Yes Ta Yes Ta >0
843 .It Sx \&In Ta \&No Ta \&No Ta n
844 .It Sx \&Lb Ta \&No Ta \&No Ta 1
845 .It Sx \&Li Ta Yes Ta Yes Ta n
846 .It Sx \&Lk Ta Yes Ta Yes Ta n
847 .It Sx \&Lp Ta \&No Ta \&No Ta 0
848 .It Sx \&Ms Ta Yes Ta Yes Ta >0
849 .It Sx \&Mt Ta Yes Ta Yes Ta >0
850 .It Sx \&Nm Ta Yes Ta Yes Ta n
851 .It Sx \&No Ta Yes Ta Yes Ta 0
852 .It Sx \&Ns Ta Yes Ta Yes Ta 0
853 .It Sx \&Nx Ta Yes Ta Yes Ta n
854 .It Sx \&Os Ta \&No Ta \&No Ta n
855 .It Sx \&Ot Ta \&No Ta \&No Ta n
856 .It Sx \&Ox Ta Yes Ta Yes Ta n
857 .It Sx \&Pa Ta Yes Ta Yes Ta n
858 .It Sx \&Pf Ta Yes Ta Yes Ta 1
859 .It Sx \&Pp Ta \&No Ta \&No Ta 0
860 .It Sx \&Rv Ta \&No Ta \&No Ta n
861 .It Sx \&Sm Ta \&No Ta \&No Ta 1
862 .It Sx \&St Ta \&No Ta Yes Ta 1
863 .It Sx \&Sx Ta Yes Ta Yes Ta >0
864 .It Sx \&Sy Ta Yes Ta Yes Ta >0
865 .It Sx \&Tn Ta Yes Ta Yes Ta >0
866 .It Sx \&Ud Ta \&No Ta \&No Ta 0
867 .It Sx \&Ux Ta Yes Ta Yes Ta n
868 .It Sx \&Va Ta Yes Ta Yes Ta n
869 .It Sx \&Vt Ta Yes Ta Yes Ta >0
870 .It Sx \&Xr Ta Yes Ta Yes Ta >0
871 .It Sx \&br Ta \&No Ta \&No Ta 0
872 .It Sx \&sp Ta \&No Ta \&No Ta 1
875 This section is a canonical reference of all macros, arranged
877 For the scoping of individual macros, see
882 block. Multiple authors should each be accorded their own
884 line. Author names should be ordered with full or abbreviated
885 forename(s) first, then full surname.
889 block. This macro may also be used in a non-bibliographic context when
890 referring to book titles.
892 Publication city or location of an
897 this macro is not implemented in
900 Publication date of an
902 block. This should follow the reduced or canonical form syntax
906 Publisher or issuer name of an
914 Issue number (usually for journals) of an
918 Optional information of an
922 Book or journal page number of an
926 Institutional author (school, government, etc.) of an
928 block. Multiple institutional authors should each be accorded their own
932 Technical report name of an
938 block. This macro may also be used in a non-bibliographical context
939 when referring to article titles.
941 URI of reference document.
949 block. Does not have any tail arguments.
951 Address construct: usually in the context of an computational address in
952 memory, not a physical (post) address.
959 This macro may alternatively accepts the following arguments, although
960 these may not be specified along with a parameter:
961 .Bl -tag -width 12n -offset indent
963 Renders a line break before each author listing.
969 In the AUTHORS section, the default is not to split the first author
970 listing, but all subsequent author listings, whether or not they're
971 interspersed by other macros or text, are split.
974 will cause the first listing also to be split.
975 If not in the AUTHORS section, the default is not to split.
979 .D1 \&.An J. D. Ullman .
986 are re-set when entering the AUTHORS section, so if one specifies
988 in the general document body, it must be re-specified in the AUTHORS
991 Begins a block enclosed by angled brackets.
992 Does not have any head arguments.
995 .D1 \&.Fl -key= \&Ns \&Ao \&Ar val \&Ac
1000 Inserts an apostrophe without any surrounding white-space.
1001 This is generally used as a grammatical device when referring to the verb
1003 .Bd -literal -offset indent
1007 Encloses its arguments in angled brackets.
1010 .D1 \&.Fl -key= \&Ns \&Aq \&Ar val
1013 this macro is often abused for rendering URIs, which should instead use
1017 or to note pre-processor
1019 statements, which should use
1026 If an argument is not provided, the string
1028 is used as a default.
1031 .D1 \&.Fl o \&Ns \&Ar file1
1033 .D1 \&.Ar arg1 , arg2 .
1035 Formats an AT&T version.
1036 Accepts at most one parameter:
1037 .Bl -tag -width 12n -offset indent
1046 Note that these parameters do not begin with a hyphen.
1064 block. Does not have any tail arguments.
1066 Begins a display block.
1067 Its syntax is as follows:
1068 .Bd -ragged -offset indent
1071 .Op Fl offset Ar width
1075 A display is collection of macros or text which may be collectively
1076 offset or justified in a manner different from that
1077 of the enclosing context.
1078 By default, the block is preceded by a vertical space.
1080 Each display is associated with a type, which must be one of the
1081 following arguments:
1082 .Bl -tag -width 12n -offset indent
1084 Only left-justify the block.
1086 Do not justify the block at all.
1088 Left- and right-justify the block.
1093 Centre-justify each line.
1096 The type must be provided first.
1097 Secondary arguments are as follows:
1098 .Bl -tag -width 12n -offset indent
1099 .It Fl offset Ar val
1100 Offset by the value of
1102 which is interpreted as one of the following, specified in order:
1105 As one of the pre-defined strings
1107 the width of standard indentation;
1112 which has no effect;
1114 which justifies to the right margin; and
1116 which aligns around an imagined centre axis.
1118 As a precalculated width for a named macro.
1119 The most popular is the imaginary macro
1124 As a scaling unit following the syntax described in
1125 .Sx Scaling Widths .
1127 As the calculated string length of the opaque string.
1130 If not provided an argument, it will be ignored.
1132 Do not assert a vertical space before the block.
1136 .Bd -literal -offset indent
1137 \&.Bd \-unfilled \-offset two-indent \-compact
1147 Change the font mode for a scoped block of text.
1148 Its syntax is as follows:
1149 .Bd -ragged -offset indent
1152 .Fl emphasis | literal | symbolic |
1153 .Cm \&Em | \&Li | \&Sy
1161 argument are equivalent, as are
1169 Without an argument, this macro does nothing.
1170 The font mode continues until broken by a new font mode in a nested
1181 Begins a collection of macros or text not breaking the line.
1182 Its syntax is as follows:
1184 .D1 Pf \. Sx \&Bk Fl words
1186 Subsequent arguments are ignored.
1189 argument is required.
1191 Each line within a keep block is kept intact, so the following example
1192 will not break within each
1195 .Bd -literal -offset indent
1198 \&.Op Fl o Ar output
1202 Be careful in using over-long lines within a keep block!
1203 Doing so will clobber the right margin.
1205 Begins a list composed of one or more list entries.
1206 Its syntax is as follows:
1207 .Bd -ragged -offset indent
1211 .Op Fl offset Ar val
1216 A list is associated with a type, which is a required argument.
1219 defined per-type as accepting a literal or
1223 also accepting a literal or
1225 value setting the list's global offset; and
1227 suppressing the default vertical space printed before each list entry.
1228 A list entry is specified by the
1230 macro, which consists of a head and optional body (depending on the list
1232 A list must specify one of the following list types:
1233 .Bl -tag -width 12n -offset indent
1235 A list offset by a bullet.
1236 The head of list entries must be empty.
1237 List entry bodies are positioned after the bullet.
1240 argument varies the width of list bodies' left-margins.
1245 argument has no effect.
1246 The number of columns is specified as parameters to the
1249 These dictate the width of columns either as
1252 If the initial macro of a
1258 context spanning each line is implied until an
1260 line macro is encountered, at which point list bodies are interpreted as
1265 A list offset by a dash (hyphen).
1266 The head of list entries must be empty.
1267 List entry bodies are positioned past the dash.
1270 argument varies the width of list bodies' left-margins.
1274 but with additional formatting to the head.
1277 argument varies the width of list bodies' left-margins.
1279 An enumerated list offset by the enumeration from 1.
1280 The head of list entries must be empty.
1281 List entry bodies are positioned after the enumeration.
1284 argument varies the width of list bodies' left-margins.
1288 but instead of list bodies positioned after the head, they trail the
1292 argument varies the width of list bodies' left-margins.
1297 List bodies follow the list head.
1300 argument is ignored.
1302 This produces blocks of text.
1303 The head of list entries must be empty.
1306 argument is ignored.
1308 List bodies are positioned on the line following the head.
1311 argument is ignored.
1313 A list offset by list entry heads. List entry bodies are positioned
1314 after the head as specified by the
1322 Begins a block enclosed by square brackets.
1323 Does not have any head arguments.
1326 .Bd -literal -offset indent
1334 Encloses its arguments in square brackets.
1337 .D1 \&.Bq 1 , \&Dv BUFSIZ
1340 this macro is sometimes abused to emulate optional arguments for
1341 commands; the correct macros to use for this purpose are
1352 block. Does not have any tail arguments.
1354 Begins a block enclosed by curly braces.
1355 Does not have any head arguments.
1358 .Bd -literal -offset indent
1366 Encloses its arguments in curly braces.
1369 .D1 \&.Brq 1 , ... , \&Va n
1374 Format the BSD/OS version provided as an argument, or a default value if
1375 no argument is provided.
1392 .Dq is currently in beta test.
1394 Format the BSD version provided as an argument, or a default value if no
1395 argument is provided.
1411 Configuration declaration.
1412 This denotes strings accepted by
1416 .D1 \&.Cd device le0 at scode?
1419 this macro is commonly abused by using quoted literals to retain
1420 white-space and align consecutive
1423 This practise is discouraged.
1426 Useful when specifying configuration options or keys.
1429 .D1 \&.Cm ControlPath
1430 .D1 \&.Cm ControlMaster
1435 One-line indented display.
1436 This is formatted by the default rules and is useful for simple indented
1438 It is followed by a newline.
1441 .D1 \&.D1 \&Fl abcdefgh
1448 Start a debugging context.
1449 This macro is parsed, but generally ignored.
1450 Its syntax is as follows:
1452 .D1 Pf \. Sx \&Db Cm on | off
1456 block. Does not have any tail arguments.
1459 This is the mandatory first macro of any
1462 Its syntax is as follows:
1464 .D1 Pf \. Sx \&Dd Cm date
1470 which signifies the current manual revision date dictated by
1472 or instead a valid canonical date as specified by
1474 If a date does not conform, the current date is used instead.
1477 .D1 \&.Dd $\&Mdocdate$
1478 .D1 \&.Dd $\&Mdocdate: July 21 2007$
1479 .D1 \&.Dd July 21, 2007
1486 One-line intended display.
1487 This is formatted as literal text and is useful for commands and
1489 It is followed by a newline.
1492 .D1 \&.Dl % mandoc mdoc.7 | less
1499 Begins a block enclosed by double quotes. Does not have any head
1503 .D1 \&.D1 \&Do April is the cruellest month \&Dc \e(em T.S. Eliot
1508 Encloses its arguments in double quotes.
1511 .Bd -literal -offset indent -compact
1512 \&.Dq April is the cruellest month
1520 This is the mandatory second macro of any
1523 Its syntax is as follows:
1524 .Bd -ragged -offset indent
1530 .Op Cm volume | arch
1535 Its arguments are as follows:
1536 .Bl -tag -width Ds -offset Ds
1538 The document's title (name), defaulting to
1541 It should be capitalised.
1552 .Pq Perl libraries ,
1562 .Pq system utilities ,
1564 .Pq kernel functions ,
1566 .Pq X Window System ,
1568 .Pq X Window System ,
1578 It should correspond to the manual's filename suffix and defaults to
1582 This overrides the volume inferred from
1584 This field is optional, and if specified, must be one of
1586 .Pq users' supplementary documents ,
1588 .Pq programmers' supplementary documents ,
1590 .Pq administrators' supplementary documents ,
1592 .Pq system managers' manuals ,
1594 .Pq users' reference manuals ,
1596 .Pq programmers' reference manuals ,
1598 .Pq kernel manuals ,
1609 .Pq contributed manuals .
1611 This specifies a specific relevant architecture.
1614 is not provided, it may be used in its place, else it may be used
1616 It, too, is optional.
1651 .D1 \&.Dt FOO 9 i386
1658 Defined variables such as preprocessor constants.
1662 .D1 \&.Dv STDOUT_FILENO
1667 Format the DragonFly BSD version provided as an argument, or a default
1668 value if no argument is provided.
1684 Close a scope started by
1686 Its syntax is as follows:
1688 .D1 Pf \. Sx \&Ec Op Cm TERM
1692 argument is used as the enclosure tail, for example, specifying \e(rq
1696 End a display context started by
1699 Ends a font mode context started by
1702 Ends a keep context started by
1705 Ends a list context started by
1713 Denotes text that should be emphasised.
1714 Note that this is a presentation term and should not be used for
1715 stylistically decorating technical terms.
1721 This macro is obsolete and not implemented.
1723 An arbitrary enclosure.
1724 Its syntax is as follows:
1726 .D1 Pf \. Sx \&Eo Op Cm TERM
1730 argument is used as the enclosure head, for example, specifying \e(lq
1734 Display error constants.
1743 This macro is obsolete and not implemented.
1745 Environmental variables such as those specified in
1752 Inserts text regarding a utility's exit values.
1753 This macro must have first the
1755 argument specified, then an optional
1759 is not provided, the document's name as stipulated in
1764 Its syntax is as follows:
1765 .Bd -ragged -offset indent
1771 This may be invoked for names with or without the corresponding type.
1772 It is also used to specify the field name of a structure.
1775 macro is used in the
1779 section when documenting multi-line function prototypes.
1780 If invoked with multiple arguments, the arguments are separated by a
1782 Furthermore, if the following macro is another
1784 the last argument will also have a trailing comma.
1787 .D1 \&.Fa \(dqconst char *p\(dq
1788 .D1 \&.Fa \(dqint a\(dq \(dqint b\(dq \(dqint c\(dq
1794 Ends a function context started by
1797 Historically used to document include files.
1798 This usage has been deprecated in favour of
1800 Do not use this macro.
1803 .Sx MANUAL STRUCTURE
1808 Used when listing arguments to command-line utilities.
1809 Prints a fixed-width hyphen
1811 directly followed by each argument.
1812 If no arguments are provided, a hyphen is printed followed by a space.
1813 If the argument is a macro, a hyphen is prefixed to the subsequent macro
1820 .D1 \&.Op \&Fl o \&Ns \&Ar file
1826 Its syntax is as follows:
1827 .Bd -ragged -offset indent
1831 .Op Oo Cm argtype Oc Cm argname
1834 Function arguments are surrounded in parenthesis and
1835 are delimited by commas.
1836 If no arguments are specified, blank parenthesis are output.
1839 .D1 \&.Fn "int funcname" "int arg0" "int arg1"
1840 .D1 \&.Fn funcname "int arg0"
1841 .D1 \&.Fn funcname arg0
1842 .Bd -literal -offset indent -compact
1848 .Sx MANUAL STRUCTURE
1852 Begin a function block.
1853 This is a multi-line version of
1855 Its syntax is as follows:
1857 .D1 Pf \. Sx \&Fo Cm funcname
1859 Invocations usually occur in the following context:
1860 .Bd -ragged -offset indent
1861 .Pf \. Sx \&Ft Cm functype
1863 .Pf \. Sx \&Fo Cm funcname
1865 .Pf \. Sx \&Fa Oo Cm argtype Oc Cm argname
1877 .Sx MANUAL STRUCTURE ,
1883 Its syntax is as follows:
1885 .D1 Pf \. Sx \&Ft Cm functype
1889 .Bd -literal -offset indent -compact
1895 .Sx MANUAL STRUCTURE ,
1900 Format the FreeBSD version provided as an argument, or a default value
1901 if no argument is provided.
1917 This macro is obsolete and not implemented.
1919 Designate an internal or interactive command.
1922 but used for instructions rather than values.
1929 .Sx \&Bd No Fl literal
1932 is preferred for displaying code; the
1934 macro is used when referring to specific instructions.
1941 section (only if invoked as the line macro), the first argument is
1944 the arguments is enclosed in angled braces.
1950 .Sx MANUAL STRUCTURE .
1953 The syntax of this macro depends on the list type.
1962 have the following syntax:
1964 .D1 Pf \. Sx \&It Cm args
1973 have the following syntax:
1977 with subsequent lines interpreted within the scope of the
1979 until either a closing
1986 list has the following syntax:
1988 .D1 Pf \. Sx \&It Op Cm args
1990 Subsequent lines are interpreted as with
1993 The line arguments correspond to the list's left-hand side; body
1994 arguments correspond to the list's contents.
1998 list is the most complicated.
1999 Its syntax is as follows:
2001 .D1 Pf \. Sx \&It Op Cm args
2005 are phrases, a mix of macros and text corresponding to a line column,
2006 delimited by tabs or the special
2009 Lines subsequent the
2011 are interpreted within the scope of the last phrase.
2012 Calling the pseudo-macro
2014 will open a new phrase scope (this must occur on a macro line to be
2015 interpreted as a macro). Note that the tab phrase delimiter may only be
2019 Subsequent this, only the
2021 pseudo-macro may be used to delimit phrases.
2022 Furthermore, note that quoted sections propagate over tab-delimited
2027 .D1 .It \(dqcol1 ; <TAB> col2 ;\(dq \&;
2029 will preserve the semicolon whitespace except for the last.
2035 The syntax is as follows:
2037 .D1 Pf \. Sx \&Lb Cm library
2041 parameter may be a system library, such as
2045 in which case a small library description is printed next to the linker
2046 invocation; or a custom library, in which case the library name is
2048 This is most commonly used in the
2050 section as described in
2051 .Sx MANUAL STRUCTURE .
2057 Denotes text that should be in a literal font mode.
2058 Note that this is a presentation term and should not be used for
2059 stylistically decorating technical terms.
2062 Its syntax is as follows:
2064 .D1 Pf \. Sx \&Lk Cm uri Op Cm name
2067 .D1 \&.Lk http://bsd.lv "The BSD.lv Project"
2068 .D1 \&.Lk http://bsd.lv
2080 Its syntax is as follows:
2082 .D1 Pf \. Sx \&Mt Cm address
2085 .D1 \&.Mt discuss@manpages.bsd.lv
2087 A one-line description of the manual's content.
2088 This may only be invoked in the
2090 section subsequent the
2095 .D1 \&.Sx \&Nd mdoc language reference
2096 .D1 \&.Sx \&Nd format and display UNIX manuals
2100 macro technically accepts child macros and terminates with a subsequent
2103 Do not assume this behaviour: some
2105 database generators are not smart enough to parse more than the line
2106 arguments and will display macros verbatim.
2111 The name of the manual page, or \(em in particular in section 1, 6,
2112 and 8 pages \(em of an additional command or feature documented in
2114 When first invoked, the
2116 macro expects a single argument, the name of the manual page.
2117 Usually, the first invocation happens in the
2119 section of the page.
2120 The specified name will be remembered and used whenever the macro is
2121 called again without arguments later in the page.
2125 .Sx Block full-implicit
2126 semantics when invoked as the first macro on an input line in the
2128 section; otherwise, it uses ordinary
2133 .Bd -literal -offset indent
2142 of section 2, 3 and 9 manual pages, use the
2146 to mark up the name of the manual page.
2150 macro used to terminate prior macro contexts.
2153 .D1 \&.Sx \&Fl ab \&No cd \&Fl ef
2156 Format the NetBSD version provided as an argument, or a default value if
2157 no argument is provided.
2177 Multi-line version of
2181 .Bd -literal -offset indent
2183 \&.Op Fl flag Ns Ar value
2187 Command-line option.
2188 Used when listing options to command-line utilities.
2189 Prints the argument(s) in brackets.
2192 .D1 \&.Op \&Fl a \&Ar b
2193 .D1 \&.Op \&Ar a | b
2198 Document operating system version.
2199 This is the mandatory third macro of
2203 Its syntax is as follows:
2205 .D1 Pf \. Sx \&Os Op Cm system
2209 parameter specifies the relevant operating system or environment.
2210 Left unspecified, it defaults to the local operating system version.
2211 This is the suggested form.
2215 .D1 \&.Os KTH/CSC/TCS
2226 this macro has been deprecated.
2228 Format the OpenBSD version provided as an argument, or a default value
2229 if no argument is provided.
2248 .D1 \&.Pa /usr/bin/mandoc
2249 .D1 \&.Pa /usr/share/man/man7/mdoc.7
2254 Close parenthesised context opened by
2259 between its arguments.
2260 Its syntax is as follows:
2262 .D1 Pf \. \&Pf Cm prefix suffix
2266 argument may be a macro.
2269 .D1 \&.Pf \e. \&Sx \&Pf \&Cm prefix suffix
2271 Multi-line version of
2275 This will assert vertical space between prior and subsequent macros
2278 Parenthesised enclosure.
2290 Does not have any tail arguments.
2292 Begins a bibliographic
2295 Does not have any head arguments.
2296 The block macro may only contain
2312 child macros (at least one must be specified).
2315 .Bd -literal -offset indent -compact
2317 \&.%A J. E. Hopcroft
2319 \&.%B Introduction to Automata Theory, Languages, and Computation
2320 \&.%I Addison-Wesley
2321 \&.%C Reading, Massachusettes
2328 block is used within a SEE ALSO section, a vertical space is asserted
2329 before the rendered output, else the block continues on the current
2335 Switches the spacing mode for output generated from macros.
2336 Its syntax is as follows:
2338 .D1 Pf \. Sx \&Sm Cm on | off
2340 By default, spacing is
2344 no white space is inserted between macro arguments and between the
2345 output generated from adjacent macros, but free-form text lines
2346 still get normal spacing between words and sentences.
2356 .Dq currently under development.
2358 Format the UNIX name.
2359 Accepts no argument.
2378 .D1 \&.Va const char *bar ;
2381 This is also used for indicating global variables in the
2383 section, in which case a variable name is also specified.
2384 Note that it accepts
2385 .Sx Block partial-implicit
2386 syntax when invoked as the first macro in the
2388 section, else it accepts ordinary
2392 Note that this should not be confused with
2394 which is used for function return types.
2397 .D1 \&.Vt unsigned char
2398 .D1 \&.Vt extern const char * const sys_signame[] \&;
2401 .Sx MANUAL STRUCTURE
2405 Close a scope opened by
2408 Open an extension scope.
2409 This macro originally existed to extend the 9-argument limit of troff;
2410 since this limit has been lifted, the macro has been deprecated.
2412 Link to another manual
2413 .Pq Qq cross-reference .
2414 Its syntax is as follows:
2416 .D1 Pf \. Sx \&Xr Cm name section
2422 are the name and section of the linked manual.
2425 is followed by non-punctuation, an
2427 is inserted into the token stream.
2428 This behaviour is for compatibility with
2433 .D1 \&.Xr mandoc 1 \&;
2434 .D1 \&.Xr mandoc 1 \&Ns s behaviour
2438 This section documents compatibility between mandoc and other other
2439 troff implementations, at this time limited to GNU troff
2443 refers to groff versions before the
2446 .Pq somewhere between 1.15 and 1.19 .
2448 Heirloom troff, the other significant troff implementation accepting
2449 \-mdoc, is similar to historic groff.
2453 Old groff fails to assert a newline before
2454 .Sx \&Bd Fl ragged compact .
2456 groff behaves inconsistently when encountering
2460 regarding spacing between arguments.
2461 In mandoc, this is not the case: each argument is consistently followed
2462 by a single space and the trailing
2464 suppresses prior spacing.
2466 groff behaves inconsistently when encountering
2472 at times newline(s) are suppressed depending on whether a prior
2475 In mandoc, this is not the case.
2480 for the normalised behaviour.
2482 Historic groff does not break before an
2484 when not invoked as the line macro in the
2488 Historic groff formats the
2490 badly: trailing arguments are trashed and
2492 is not specially treated.
2494 groff does not accept the
2496 pseudo-macro as a line macro.
2501 is no longer accepted.
2505 macro does not format its arguments when used in the FILES section under
2509 Historic groff does not print a dash for empty
2512 mandoc and newer groff implementations do.
2514 groff behaves irregularly when specifying
2517 within line-macro scopes.
2518 mandoc follows a consistent system.
2520 In mandoc, negative scaling units are truncated to zero; groff would
2521 move to prior lines.
2524 scaling unit, while accepted, is rendered as the default unit.
2526 In quoted literals, groff allowed pair-wise double-quotes to produce a
2527 standalone double-quote in formatted output.
2528 This idiosyncratic behaviour is not applicable in mandoc.
2532 .Fl offset Ar center
2535 are disregarded in mandoc.
2536 Furthermore, troff specifies a
2538 argument that is not supported in mandoc.
2539 Lastly, since text is not right-justified in mandoc (or even groff),
2548 Historic groff has many un-callable macros.
2549 Most of these (excluding some block-level macros) are now callable.
2555 but has been a proper delimiter since then.
2558 is assumed for all lists (it wasn't in historic groff): any list may be
2561 lists will restart the sequence only for the sub-list.
2565 incorrectly by following it with a reserved character and expecting the
2566 delimiter to render.
2567 This is not supported in mandoc.
2575 macros were stipulated only to occur in certain manual sections.
2576 mandoc does not have these restrictions.
2578 Newer groff and mandoc print
2580 prior to unknown arguments of
2582 older groff did nothing.
2590 reference was written by
2591 .An Kristaps Dzonsons Aq kristaps@bsd.lv .
2593 .\" XXX: this really isn't the place for these caveats.
2597 .\" There are many ambiguous parts of mdoc.
2600 .\" .Bl -dash -compact
2605 .\" as function arguments are variables.
2610 .\" as function return types are still types. Furthermore, the
2612 .\" should be removed and
2614 .\" which ostensibly follows it, should follow the same convention as
2618 .\" should formalise that only one or two arguments are acceptable: a
2619 .\" variable name and optional, preceding type.
2622 .\" is ambiguous. It's commonly used to indicate an include file in the
2623 .\" synopsis section.
2625 .\" should be used, instead.
2631 .\" makes sense. The remaining ones should be removed.
2637 .\" macros should be deprecated.
2641 .\" macro lacks clarity. It should be absolutely clear which title will
2642 .\" render when formatting the manual page.
2646 .\" should be provided for Linux (\(`a la
2651 .\" There's no way to refer to references in
2655 .\" The \-split and \-nosplit dictates via
2657 .\" are re-set when entering and leaving the AUTHORS section.