-.\" $Id: mdoc.7,v 1.183 2011/04/01 19:47:33 kristaps Exp $
+.\" $Id: mdoc.7,v 1.191 2011/07/18 10:23:02 kristaps Exp $
.\"
.\" Copyright (c) 2009, 2010, 2011 Kristaps Dzonsons <kristaps@bsd.lv>
.\" Copyright (c) 2010 Ingo Schwarze <schwarze@openbsd.org>
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: April 1 2011 $
+.Dd $Mdocdate: July 18 2011 $
.Dt MDOC 7
.Os
.Sh NAME
.Nm
document follows simple rules: lines beginning with the control
character
-.Sq \.
+.Sq \&.
are parsed for macros.
-Other lines are interpreted within the scope of
-prior macros:
+Text lines, those not beginning with the control character, are
+interpreted within the scope of prior macros:
.Bd -literal -offset indent
\&.Sh Macro lines change control state.
-Other lines are interpreted within the current state.
+Text lines are interpreted within the current state.
.Ed
.Sh LANGUAGE SYNTAX
.Nm
documents may contain only graphable 7-bit ASCII characters, the space
character, and, in certain circumstances, the tab character.
.Pp
-If the first character of a line is a space, that line is printed
+If the first character of a text line is a space, that line is printed
with a leading newline.
.Ss Comments
Text following a
.Sq \e\*q ,
-whether in a macro or free-form text line, is ignored to the end of
+whether in a macro or text line, is ignored to the end of
line.
A macro line with only a control character and comment escape,
.Sq \&.\e\*q ,
.Pq reserved-word vertical bar
.El
.Pp
-Use of reserved terms is described in
-.Sx MACRO SYNTAX .
For general use in macro lines, these can be escaped with a non-breaking
space
.Pq Sq \e& .
+In text lines, these may be used as normal punctuation.
.Ss Special Characters
-Special characters may occur in both macro and free-form lines.
+Special characters may occur in both macro and text lines.
Sequences begin with the escape character
.Sq \e
followed by either an open-parenthesis
.Pp
A numerical representation 3, 2, or 1 (bold, italic, and Roman,
respectively) may be used instead.
-A text decoration is valid within
-the current font scope only: if a macro opens a font scope alongside
-its own scope, such as
-.Sx \&Bf
-.Cm \&Sy ,
-in-scope invocations of
-.Sq \ef
-are only valid within the font scope of the macro.
-If
+If a macro opens a font scope after calling
+.Sq \ef ,
+such as with
+.Sx \&Bf ,
+the
.Sq \ef
-is specified outside of any font scope, such as in unenclosed, free-form
-text, it will affect the remainder of the document.
+mode will be restored upon exiting the
+.Sx \&Bf
+scope.
.Pp
Note this form is
.Em not
.Pq vertical bar .
.Ss Whitespace
Whitespace consists of the space character.
-In free-form lines, whitespace is preserved within a line; unescaped
+In text lines, whitespace is preserved within a line; unescaped
trailing spaces are stripped from input (unless in a literal context).
-Blank free-form lines, which may include whitespace, are only permitted
+Blank text lines, which may include whitespace, are only permitted
within literal contexts.
.Pp
In macro lines, whitespace delimits arguments and is discarded.
\&.Op "Fl a"
.Ed
.Pp
-In free-form mode, quotes are regarded as opaque text.
+In text lines, quotes are regarded as opaque text.
.Ss Scaling Widths
Many macros support scaled widths for their arguments, such as
stipulating a two-inch list indentation with the following:
the boundary of a macro line.
For example:
.Pp
-.Dl \&Xr mandoc 1 \.
-.Dl \&Fl T \&Ns \&Cm ascii \.
+.Dl \&.Xr mandoc 1 \&.
+.Dl \&.Fl T \&Ns \&Cm ascii \&.
.Sh MANUAL STRUCTURE
A well-formed
.Nm
.Pp
The following is a well-formed skeleton
.Nm
-file:
+file for a utility
+.Qq progname :
.Bd -literal -offset indent
\&.Dd $\&Mdocdate$
-\&.Dt mdoc 7
+\&.Dt PROGNAME section
\&.Os
\&.Sh NAME
-\&.Nm foo
+\&.Nm progname
\&.Nd a description goes here
\&.\e\*q .Sh LIBRARY
\&.\e\*q For sections 2, 3, & 9 only.
\&.\e\*q Not used in OpenBSD.
\&.Sh SYNOPSIS
-\&.Nm foo
+\&.Nm progname
\&.Op Fl options
\&.Ar
\&.Sh DESCRIPTION
\&.Nd a one line description
.Ed
.Pp
+Multiple
+.Sq \&Nm
+names should be separated by commas.
+.Pp
The
.Sx \&Nm
macro(s) must precede the
For the first, utilities (sections 1, 6, and 8), this is
generally structured as follows:
.Bd -literal -offset indent
-\&.Nm foo
+\&.Nm bar
\&.Op Fl v
\&.Op Fl o Ar file
\&.Op Ar
-\&.Nm bar
+\&.Nm foo
\&.Op Fl v
\&.Op Fl o Ar file
\&.Op Ar
.Ed
.Pp
+Commands should be ordered alphabetically.
+.Pp
For the second, function calls (sections 2, 3, 9):
.Bd -literal -offset indent
\&.In header.h
\&.Fn bar "const char *src"
.Ed
.Pp
+Ordering of
+.Sx \&In ,
+.Sx \&Vt ,
+.Sx \&Fn ,
+and
+.Sx \&Fo
+macros should follow C header-file conventions.
+.Pp
And for the third, configurations (section 4):
.Bd -literal -offset indent
\&.Cd \*qit* at isa? port 0x2e\*q
.Sx \&Ss
macro or the end of an enclosing block, whichever comes first.
.It Em DESCRIPTION
-This expands upon the brief, one line description in
-.Em NAME .
-It usually contains a breakdown of the options (if documenting a
+This begins with an expansion of the brief, one line description in
+.Em NAME :
+.Bd -literal -offset indent
+The
+\&.Nm
+utility does this, that, and the other.
+.Ed
+.Pp
+It usually follows with a breakdown of the options (if documenting a
command), such as:
.Bd -literal -offset indent
The arguments are as follows:
Multi-line scope closed by an explicit closing macro.
All macros contains bodies; only
.Sx \&Bf
-contains a head.
+and
+.Pq optionally
+.Sx \&Bl
+contain a head.
.Bd -literal -offset indent
\&.Yo \(lB\-arg \(lBparm...\(rB\(rB \(lBhead...\(rB
\(lBbody...\(rB
.Em SYNOPSIS
section line, else it is
.Sx In-line .
+.Ss Special block macro
+The
+.Sx \&Ta
+macro can only be used below
+.Sx \&It
+in
+.Sx \&Bl Fl column
+lists.
+It delimits blocks representing table cells;
+these blocks have bodies, but no heads.
+.Pp
+.Bl -column "MacroX" "CallableX" "ParsedX" "closed by XXXX" -compact -offset indent
+.It Em Macro Ta Em Callable Ta Em Parsed Ta Em Scope
+.It Sx \&Ta Ta Yes Ta Yes Ta closed by Sx \&Ta , Sx \&It
+.El
.Ss In-line
Closed by
.Sx Reserved Terms ,
.It Sx \&Fx Ta Yes Ta Yes Ta n
.It Sx \&Hf Ta \&No Ta \&No Ta n
.It Sx \&Ic Ta Yes Ta Yes Ta >0
-.It Sx \&In Ta \&No Ta \&No Ta n
+.It Sx \&In Ta \&No Ta \&No Ta 1
.It Sx \&Lb Ta \&No Ta \&No Ta 1
.It Sx \&Li Ta Yes Ta Yes Ta >0
.It Sx \&Lk Ta Yes Ta Yes Ta >0
.Pp
Display blocks are used to select a different indentation and
justification than the one used by the surrounding text.
-They may contain both macro lines and free-form text lines.
+They may contain both macro lines and text lines.
By default, a display block is preceded by a vertical space.
.Pp
The
and
.Sx \&Sy .
.Ss \&Bk
-Keep the output generated from each macro input line together
-on one single output line.
-Line breaks in free-form text lines are unaffected.
+For each macro, keep its output together on the same output line,
+until the end of the macro or the end of the input line is reached,
+whichever comes first.
+Line breaks in text lines are unaffected.
The syntax is as follows:
.Pp
.D1 Pf \. Sx \&Bk Fl words
and
.Sx \&Os .
.Ss \&Dv
-Defined variables such as preprocessor constants.
+Defined variables such as preprocessor constants, constant symbols,
+enumeration values, and so on.
.Pp
Examples:
+.Dl \&.Dv NULL
.Dl \&.Dv BUFSIZ
.Dl \&.Dv STDOUT_FILENO
.Pp
See also
-.Sx \&Er .
+.Sx \&Er
+and
+.Sx \&Ev
+for special-purpose constants and
+.Sx \&Va
+for variable symbols.
.Ss \&Dx
Format the DragonFly BSD version provided as an argument, or a default
value if no argument is provided.
will emulate
.Sx \&Do .
.Ss \&Er
-Display error constants.
+Error constants for definitions of the
+.Va errno
+libc global variable.
.Pp
Examples:
.Dl \&.Er EPERM
.Dl \&.Er ENOENT
.Pp
See also
-.Sx \&Dv .
+.Sx \&Dv
+for general constants.
.Ss \&Es
This macro is obsolete and not implemented.
.Ss \&Ev
Examples:
.Dl \&.Ev DISPLAY
.Dl \&.Ev PATH
+.Pp
+See also
+.Sx \&Dv
+for general constants.
.Ss \&Ex
-Insert a standard sentence regarding exit values.
+Insert a standard sentence regarding command exit values of 0 on success
+and >0 on failure.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Ex Fl std Op Ar utility
+.D1 Pf \. Sx \&Ex Fl std Op Ar utility...
.Pp
-When
+If
.Ar utility
is not specified, the document's name set by
.Sx \&Nm
is used.
+Multiple
+.Ar utility
+arguments are treated as separate utilities.
.Pp
See also
.Sx \&Rv .
Its syntax is as follows:
.Bd -ragged -offset indent
.Pf \. Ns Sx \&Fn
-.Op Cm functype
-.Cm funcname
-.Op Oo Cm argtype Oc Cm argname
+.Op Ar functype
+.Ar funcname
+.Op Oo Ar argtype Oc Ar argname
.Ed
.Pp
Function arguments are surrounded in parenthesis and
.Sx \&Fn .
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Fo Cm funcname
+.D1 Pf \. Sx \&Fo Ar funcname
.Pp
Invocations usually occur in the following context:
.Bd -ragged -offset indent
-.Pf \. Sx \&Ft Cm functype
+.Pf \. Sx \&Ft Ar functype
.br
-.Pf \. Sx \&Fo Cm funcname
+.Pf \. Sx \&Fo Ar funcname
.br
-.Pf \. Sx \&Fa Oo Cm argtype Oc Cm argname
+.Pf \. Sx \&Fa Oo Ar argtype Oc Ar argname
.br
\&.\.\.
.br
.Sx \&Fc ,
and
.Sx \&Ft .
+.Ss \&Fr
+This macro is obsolete and not implemented.
.Ss \&Ft
A function type.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Ft Cm functype
+.D1 Pf \. Sx \&Ft Ar functype
.Pp
Examples:
.Dl \&.Ft int
.Fl diag
have the following syntax:
.Pp
-.D1 Pf \. Sx \&It Cm args
+.D1 Pf \. Sx \&It Ar args
.Pp
Lists of type
.Fl bullet ,
list is the most complicated.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&It Op Cm args
+.D1 Pf \. Sx \&It Ar cell Op <TAB> Ar cell ...
+.D1 Pf \. Sx \&It Ar cell Op Sx \&Ta Ar cell ...
.Pp
-The
-.Cm args
-are phrases, a mix of macros and text corresponding to a line column,
-delimited by tabs or the special
-.Sq \&Ta
-pseudo-macro.
-Lines subsequent the
+The arguments consist of one or more lines of text and macros
+representing a complete table line.
+Cells within the line are delimited by tabs or by the special
+.Sx \&Ta
+block macro.
+The tab cell delimiter may only be used within the
.Sx \&It
-are interpreted within the scope of the last phrase.
-Calling the pseudo-macro
-.Sq \&Ta
-will open a new phrase scope (this must occur on a macro line to be
-interpreted as a macro).
-Note that the tab phrase delimiter may only be used within the
+line itself; on following lines, only the
+.Sx \&Ta
+macro can be used to delimit cells, and
+.Sx \&Ta
+is only recognized as a macro when called by other macros,
+not as the first macro on a line.
+.Pp
+Note that quoted strings may span tab-delimited cells on an
.Sx \&It
-line itself.
-Subsequent this, only the
-.Sq \&Ta
-pseudo-macro may be used to delimit phrases.
-Furthermore, note that quoted sections propagate over tab-delimited
-phrases on an
-.Sx \&It ,
-for example,
+line.
+For example,
.Pp
.Dl .It \(dqcol1 ; <TAB> col2 ;\(dq \&;
.Pp
Specify a library.
The syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Lb Cm library
+.D1 Pf \. Sx \&Lb Ar library
.Pp
The
-.Cm library
+.Ar library
parameter may be a system library, such as
-.Cm libz
+.Ar libz
or
-.Cm libpam ,
+.Ar libpam ,
in which case a small library description is printed next to the linker
invocation; or a custom library, in which case the library name is
printed in quotes.
Format a hyperlink.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Lk Cm uri Op Cm name
+.D1 Pf \. Sx \&Lk Ar uri Op Ar name
.Pp
Examples:
.Dl \&.Lk http://bsd.lv \*qThe BSD.lv Project\*q
Display a mathematical symbol.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Ms Cm symbol
+.D1 Pf \. Sx \&Ms Ar symbol
.Pp
Examples:
.Dl \&.Ms sigma
hyperlink.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Mt Cm address
+.D1 Pf \. Sx \&Mt Ar address
.Pp
Examples:
.Dl \&.Mt discuss@manpages.bsd.lv
file.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Os Op Cm system Op Cm version
+.D1 Pf \. Sx \&Os Op Ar system Op Ar version
.Pp
The optional
-.Cm system
+.Ar system
parameter specifies the relevant operating system or environment.
Left unspecified, it defaults to the local operating system version.
This is the suggested form.
between its arguments.
Its syntax is as follows:
.Pp
-.D1 Pf \. \&Pf Cm prefix suffix
+.D1 Pf \. \&Pf Ar prefix suffix
.Pp
The
-.Cm suffix
+.Ar suffix
argument may be a macro.
.Pp
Examples:
-.Dl \&.Pf \e. \&Sx \&Pf \&Cm prefix suffix
+.Dl \&.Pf \e. \&Sx \&Pf \&Ar prefix suffix
.Ss \&Po
Multi-line version of
.Sx \&Pq .
before the rendered output, else the block continues on the current
line.
.Ss \&Rv
-Inserts text regarding a function call's return value.
-This macro must consist of the
-.Fl std
-argument followed by an optional
-.Ar function .
+Insert a standard sentence regarding a system call's return value of 0
+on success and \-1 on error, with the
+.Va errno
+libc global variable set on error.
+Its syntax is as follows:
+.Pp
+.D1 Pf \. Sx \&Rv Fl std Op Ar function...
+.Pp
If
.Ar function
-is not provided, the document's name as stipulated by the first
+is not specified, the document's name set by
.Sx \&Nm
-is provided.
+is used.
+Multiple
+.Ar function
+arguments are treated as separate functions.
.Pp
See also
.Sx \&Ex .
.D1 Pf \. Sx \&Sm Cm on | off
.Pp
By default, spacing is
-.Cm on .
+.Ar on .
When switched
-.Cm off ,
+.Ar off ,
no white space is inserted between macro arguments and between the
-output generated from adjacent macros, but free-form text lines
+output generated from adjacent macros, but text lines
still get normal spacing between words and sentences.
.Ss \&So
Multi-line version of
.Sx \&Li ,
and
.Sx \&Em .
+.Ss \&Ta
+Table cell separator in
+.Sx \&Bl Fl column
+lists; can only be used below
+.Sx \&It .
.Ss \&Tn
Format a tradename.
.Pp
.Pq Qq cross-reference .
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&Xr Cm name section
+.D1 Pf \. Sx \&Xr Ar name section
.Pp
The
-.Cm name
+.Ar name
and
-.Cm section
+.Ar section
are the name and section of the linked manual.
If
-.Cm section
+.Ar section
is followed by non-punctuation, an
.Sx \&Ns
is inserted into the token stream.
historical manuals.
Its syntax is as follows:
.Pp
-.D1 Pf \. Sx \&sp Op Cm height
+.D1 Pf \. Sx \&sp Op Ar height
.Pp
The
-.Cm height
+.Ar height
argument must be formatted as described in
.Sx Scaling Widths .
If unspecified,
.Qq AT&T UNIX
and the arguments.
.It
-.Sx \&Bd Fl column
+.Sx \&Bl Fl column
does not recognize trailing punctuation characters when they immediately
precede tabulator characters, but treats them as normal text and
outputs a space before them.