]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man7/mdoc.samples.7
random.7: srcfix
[thirdparty/man-pages.git] / man7 / mdoc.samples.7
CommitLineData
fea681da
MK
1.\" Copyright (c) 1990, 1993
2.\" The Regents of the University of California. All rights reserved.
3.\"
a9cd9cb7 4.\" %%%LICENSE_START(BSD_4_CLAUSE_UCB)
fea681da
MK
5.\" Redistribution and use in source and binary forms, with or without
6.\" modification, are permitted provided that the following conditions
7.\" are met:
8.\" 1. Redistributions of source code must retain the above copyright
9.\" notice, this list of conditions and the following disclaimer.
10.\" 2. Redistributions in binary form must reproduce the above copyright
11.\" notice, this list of conditions and the following disclaimer in the
12.\" documentation and/or other materials provided with the distribution.
13.\" 3. All advertising materials mentioning features or use of this software
14.\" must display the following acknowledgement:
15.\" This product includes software developed by the University of
16.\" California, Berkeley and its contributors.
17.\" 4. Neither the name of the University nor the names of its contributors
18.\" may be used to endorse or promote products derived from this software
19.\" without specific prior written permission.
20.\"
21.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31.\" SUCH DAMAGE.
8c9302dc 32.\" %%%LICENSE_END
fea681da
MK
33.\"
34.\" @(#)mdoc.samples.7 8.2 (Berkeley) 12/30/93
35.\" $Id: mdoc.samples.7,v 1.17 1998/12/03 03:38:45 jkoshy Exp $
36.\"
37.\" This tutorial sampler invokes every macro in the package several
38.\" times and is guaranteed to give a worst case performance
39.\" for an already extremely slow package.
40.\"
15a12343
BIG
41.\" String \*(Pu was not defined, probably means punctuation
42.ds Pu "[ .,:;()[]?! ]
fea681da
MK
43.Dd December 30, 1993
44.Os
45.Dt MDOC.SAMPLES 7
46.Sh NAME
47.Nm mdoc.samples
48.Nd tutorial sampler for writing
49.Bx
50manuals with
51.Nm \-mdoc
52.Sh SYNOPSIS
53.Nm man mdoc.samples
54.Sh DESCRIPTION
55A tutorial sampler for writing
56.Bx
57manual pages with the
58.Nm \-mdoc
59macro package, a
60.Em content Ns \-based
61and
62.Em domain Ns \-based
63formatting
64package for
65.Xr troff 1 .
66Its predecessor, the
67.Xr \-man 7
68package,
69addressed page layout leaving the
70manipulation of fonts and other
71typesetting details to the individual author.
72In
73.Nm \-mdoc ,
74page layout macros
75make up the
76.Em "page structure domain"
77which consists of macros for titles, section headers, displays
4175f999
MK
78and lists.
79Essentially items which affect the physical position
fea681da
MK
80of text on a formatted page.
81In addition to the page structure domain, there are two more domains,
82the manual domain and the general text domain.
83The general text domain is defined as macros which
84perform tasks such as quoting or emphasizing pieces of text.
85The manual domain is defined as macros that are a subset of the
86day to day informal language used to describe commands, routines
87and related
88.Bx
89files.
90Macros in the manual domain handle
76c44d83 91command names, command-line arguments and options, function names,
fea681da
MK
92function parameters, pathnames, variables, cross
93references to other manual pages, and so on.
94These domain
95items have value
96for both the author and the future user of the manual page.
97It is hoped the consistency gained
98across the manual set will provide easier
99translation to future documentation tools.
100.Pp
101Throughout the
102.Ux
103manual pages, a manual entry
104is simply referred
105to as a man page, regardless of actual length and without
106sexist intention.
107.Sh GETTING STARTED
108Since a tutorial document is normally read when a person
109desires to use the material immediately, the assumption has
110been made that the user of this document may be impatient.
111The material presented in the remained of this document is
112outlined as follows:
113.Bl -enum -offset indent
114.It
115.Tn "TROFF IDIOSYNCRASIES"
116.Bl -tag -width flag -compact -offset indent
117.It "Macro Usage" .
118.It "Passing Space Characters in an Argument" .
119.It "Trailing Blank Space Characters (a warning)" .
120.It "Escaping Special Characters" .
121.El
122.It
123.Tn "THE ANATOMY OF A MAN PAGE"
124.Bl -tag -width flag -compact -offset indent
125.It "A manual page template" .
126.El
127.It
128.Tn "TITLE MACROS" .
129.It
130.Tn "INTRODUCTION OF MANUAL AND GENERAL TEXT DOMAINS" .
131.Bl -tag -width flag -compact -offset indent
132.It "What's in a name..." .
133.It "General Syntax" .
134.El
135.It
136.Tn "MANUAL DOMAIN"
137.Bl -tag -width flag -compact -offset indent
138.It "Addresses" .
139.It "Author name" .
140.It "Arguments" .
141.It "Configuration Declarations (section four only)" .
142.It "Command Modifier" .
143.It "Defined Variables" .
144.It "Errno's (Section two only)" .
145.It "Environment Variables" .
146.It "Function Argument" .
147.It "Function Declaration" .
148.It "Flags" .
149.It "Functions (library routines)" .
150.It "Function Types" .
151.\" .It "Header File (including source code)" .
152.It "Interactive Commands" .
153.It "Names" .
154.It "Options" .
155.It "Pathnames" .
156.It "Variables" .
157.It "Cross References" .
158.El
159.It
160.Tn "GENERAL TEXT DOMAIN"
161.Bl -tag -width flag -compact -offset indent
162.It "AT&T Macro" .
163.It "BSD Macro" .
164.It "FreeBSD Macro" .
165.It "UNIX Macro" .
166.It "Enclosure/Quoting Macros"
167.Bl -tag -width flag -compact -offset indent
168.It "Angle Bracket Quote/Enclosure" .
169.It "Bracket Quotes/Enclosure" .
170.It "Double Quote macro/Enclosure" .
171.It "Parenthesis Quote/Enclosure" .
172.It "Single Quotes/Enclosure" .
173.It "Prefix Macro" .
174.El
175.It "No\-Op or Normal Text Macro" .
176.It "No Space Macro" .
177.It "Section Cross References" .
178.It "References and Citations" .
179.It "Return Values (sections two and three only)"
180.It "Trade Names (Acronyms and Type Names)" .
181.It "Extended Arguments" .
182.El
183.It
184.Tn "PAGE STRUCTURE DOMAIN"
185.Bl -tag -width flag -compact -offset indent
186.It "Section Headers" .
187.It "Paragraphs and Line Spacing" .
188.It "Keeps" .
189.It "Displays" .
190.It "Font Modes (Emphasis, Literal, and Symbolic)" .
191.It "Lists and Columns" .
192.El
193.It
194.Tn "PREDEFINED STRINGS"
195.It
196.Tn "DIAGNOSTICS"
197.It
198.Tn "FORMATTING WITH GROFF, TROFF AND NROFF"
199.It
200.Tn "BUGS"
201.El
202.ne 7
203.Sh TROFF IDIOSYNCRASIES
204The
205.Nm \-mdoc
206package attempts to simplify the process of writing a man page.
207Theoretically, one should not have to learn the dirty details of
208.Xr troff 1
209to use
210.Nm \-mdoc ;
211however, there are a few
212limitations which are unavoidable and best gotten out
213of the way.
214And, too, be forewarned, this package is
215.Em not
216fast.
217.Ss Macro Usage
218As in
219.Xr troff 1 ,
220a macro is called by placing a
221.Ql \&\.
222(dot character)
223at the beginning of
224a line followed by the two character name for the macro.
225Arguments may follow the macro separated by spaces.
226It is the dot character at the beginning of the line which causes
227.Xr troff 1
228to interpret the next two characters as a macro name.
229To place a
230.Ql \&\.
231(dot character)
232at the beginning of a line in some context other than
233a macro invocation, precede the
234.Ql \&\.
235(dot) with the
31a6818e 236.Ql \e&
fea681da
MK
237escape sequence.
238The
31a6818e 239.Ql \e&
fea681da
MK
240translates literally to a zero width space, and is never displayed in the
241output.
242.Pp
243In general,
244.Xr troff 1
245macros accept up to nine arguments, any
246extra arguments are ignored.
247Most macros in
248.Nm \-mdoc
249accept nine arguments and,
250in limited cases, arguments may be continued or extended
251on the
252next line (See
253.Sx Extensions ) .
254A few macros handle quoted arguments (see
255.Sx Passing Space Characters in an Argument
256below).
257.Pp
258Most of the
259.Nm \-mdoc
260general text domain and manual domain macros are special
261in that their argument lists are
262.Em parsed
263for callable macro names.
264This means an argument on the argument list which matches
265a general text or manual domain macro name and is determined
266to be callable will be executed
267or called when it is processed.
a7dc2c80 268In this case,
fea681da
MK
269the argument, although the name of a macro,
270is not preceded by a
271.Ql \&\.
272(dot).
273It is in this manner that many macros are nested; for
274example
275the option macro,
276.Ql \&.Op ,
277may
278.Em call
279the flag and argument macros,
280.Ql \&Fl
281and
282.Ql \&Ar ,
283to specify an optional flag with an argument:
284.Bl -tag -width "\&.Op \&Fl s \&Ar bytes" -offset indent
285.It Op Fl s Ar bytes
286is produced by
287.Li \&.Op \&Fl s \&Ar bytes
288.El
289.Pp
290To prevent a two character
291string from being interpreted as a macro name, precede
292the string with the
293escape sequence
31a6818e 294.Ql \e& :
fea681da
MK
295.Bl -tag -width "\&.Op \&Fl s \&Ar bytes" -offset indent
296.It Op \&Fl s \&Ar bytes
297is produced by
31a6818e 298.Li \&.Op \e&Fl s \e&Ar bytes
fea681da
MK
299.El
300.Pp
301Here the strings
302.Ql \&Fl
303and
304.Ql \&Ar
305are not interpreted as macros.
306Macros whose argument lists are parsed for callable arguments
307are referred to
308as parsed and macros which may be called from an argument
309list are referred to as callable
310throughout this document and in the companion quick reference
311manual
312.Xr mdoc 7 .
313This is a technical
314.Em faux pas
c13182ef 315as almost all of the macros in
fea681da
MK
316.Nm \-mdoc
317are parsed, but as it was cumbersome to constantly refer to macros
318as being callable and being able to call other macros,
319the term parsed has been used.
320.Ss Passing Space Characters in an Argument
321Sometimes it is desirable to give as one argument a string
322containing one or more blank space characters.
323This may be necessary
324to defeat the nine argument limit or to specify arguments to macros
325which expect particular arrangement of items in the argument list.
326For example,
327the function macro
328.Ql \&.Fn
329expects the first argument to be the name of a function and any
330remaining arguments to be function parameters.
331As
332.Tn "ANSI C"
333stipulates the declaration of function parameters in the
334parenthesized parameter list, each parameter is guaranteed
335to be at minimum a two word string.
336For example,
337.Fa int foo .
338.Pp
339There are two possible ways to pass an argument which contains
340an embedded space.
341.Em Implementation note :
342Unfortunately, the most convenient way
343of passing spaces in between quotes by reassigning individual
344arguments before parsing was fairly expensive speed wise
345and space wise to implement in all the macros for
346.Tn AT&T
347.Xr troff .
348It is not expensive for
349.Xr groff
350but for the sake of portability, has been limited
351to the following macros which need
352it the most:
353.Pp
354.Bl -tag -width 4n -offset indent -compact
355.It Li \&Cd
356Configuration declaration (section 4
357.Sx SYNOPSIS )
358.It Li \&Bl
359Begin list (for the width specifier).
360.It Li \&Em
361Emphasized text.
362.It Li \&Fn
363Functions (sections two and four).
364.It Li \&It
365List items.
366.It Li \&Li
367Literal text.
368.It Li \&Sy
369Symbolic text.
370.It Li \&%B
371Book titles.
372.It Li \&%J
373Journal names.
374.It Li \&%O
375Optional notes for a reference.
376.It Li \&%R
377Report title (in a reference).
378.It Li \&%T
379Title of article in a book or journal.
380.El
381.Pp
382One way of passing a string
383containing blank spaces is to use the hard or unpaddable space character
31a6818e 384.Ql \e\ ,
fea681da 385that is, a blank space preceded by the escape character
31a6818e 386.Ql \e .
fea681da
MK
387This method may be used with any macro but has the side effect
388of interfering with the adjustment of text
389over the length of a line.
390.Xr Troff
391sees the hard space as if it were any other printable character and
392cannot split the string into blank or newline separated pieces as one
393would expect.
394The method is useful for strings which are not expected
395to overlap a line boundary.
396For example:
397.Bl -tag -width "fetch(char *str)" -offset indent
398.It Fn fetch char\ *str
399is created by
31a6818e 400.Ql \&.Fn fetch char\e *str
fea681da
MK
401.It Fn fetch "char *str"
402can also be created by
403.Ql \&.Fn fetch "\\*qchar *str\\*q"
404.El
405.Pp
406If the
31a6818e 407.Ql \e
fea681da
MK
408or quotes
409were omitted,
410.Ql \&.Fn
411would see three arguments and
412the result would be:
413.Pp
414.Dl Fn fetch char *str
415.Pp
416For an example of what happens when the parameter list overlaps
417a newline boundary, see the
418.Sx BUGS
419section.
420.Ss Trailing Blank Space Characters
421.Xr Troff
422can be confused by blank space characters at the end of a line.
423It
424is a wise preventive measure to globally remove all blank spaces
425from <blank-space><end-of-line> character sequences.
426Should the need
427arise to force a blank character at the end of a line,
428it may be forced with an unpaddable space and the
31a6818e 429.Ql \e&
fea681da
MK
430escape character.
431For example,
31a6818e 432.Ql string\e\ \e& .
fea681da
MK
433.Ss Escaping Special Characters
434Special characters
435like the newline character
31a6818e 436.Ql \en ,
fea681da 437are handled by replacing the
31a6818e 438.Ql \e
fea681da 439with
31a6818e 440.Ql \ee
15079abb 441(e.g.,
31a6818e 442.Ql \een )
fea681da
MK
443to preserve
444the backslash.
445.Sh THE ANATOMY OF A MAN PAGE
446The body of a man page is easily constructed from a basic
447template found in the file
448.Pa /usr/share/misc/mdoc.template .
449Several example man pages can also be found
c13182ef 450in
fea681da
MK
451.Pa /usr/share/examples/mdoc .
452.Pp
453.Ss A manual page template
454.Bd -literal -offset indent
31a6818e 455\&.\e" The following requests are required for all man pages.
fea681da
MK
456\&.Dd Month day, year
457\&.Os OPERATING_SYSTEM [version/release]
458\&.Dt DOCUMENT_TITLE [section number] [volume]
459\&.Sh NAME
460\&.Nm name
461\&.Nd one line description of name
462\&.Sh SYNOPSIS
463\&.Sh DESCRIPTION
31a6818e
MK
464\&.\e" The following requests should be uncommented and
465\&.\e" used where appropriate. This next request is
466\&.\e" for sections 2 and 3 function return values only.
467\&.\e" .Sh RETURN VALUE
468\&.\e" This next request is for sections 1, 6, 7 & 8 only
469\&.\e" .Sh ENVIRONMENT
470\&.\e" .Sh FILES
471\&.\e" .Sh EXAMPLES
472\&.\e" This next request is for sections 1, 6, 7 & 8 only
473\&.\e" (command return values (to shell) and
474\&.\e" fprintf/stderr type diagnostics)
475\&.\e" .Sh DIAGNOSTICS
476\&.\e" The next request is for sections 2 and 3 error
477\&.\e" and signal handling only.
478\&.\e" .Sh ERRORS
479\&.\e" .Sh SEE ALSO
480\&.\e" .Sh CONFORMING TO
481\&.\e" .Sh HISTORY
482\&.\e" .Sh AUTHORS
483\&.\e" .Sh BUGS
fea681da
MK
484.Ed
485.Pp
486The first items in the template are the macros
487.Pq Li \&.Dd , \&.Os , \&.Dt ;
488the document date,
489the operating system the man page or subject source is developed
490or modified for,
491and the man page title
efaef3da 492.Pq Em in uppercase
fea681da
MK
493along with the section of the manual the page
494belongs in.
495These macros identify the page,
496and are discussed below in
497.Sx TITLE MACROS .
498.Pp
499The remaining items in the template are section headers
500.Pq Li \&.Sh ;
501of which
502.Sx NAME ,
503.Sx SYNOPSIS
504and
505.Sx DESCRIPTION
506are mandatory.
507The
508headers are
509discussed in
510.Sx PAGE STRUCTURE DOMAIN ,
511after
512presentation of
513.Sx MANUAL DOMAIN .
514Several content macros are used to demonstrate page layout macros;
515reading about content macros before page layout macros is
516recommended.
517.Sh TITLE MACROS
518The title macros are the first portion of the page structure
519domain, but are presented first and separate for someone who
520wishes to start writing a man page yesterday.
521Three header macros designate the document title or manual page title,
522the operating system,
523and the date of authorship.
524These macros are one called once at the very beginning of the document
525and are used to construct the headers and footers only.
526.Bl -tag -width 6n
527.It Li \&.Dt DOCUMENT_TITLE section# [volume]
528The document title is the
529subject of the man page and must be in
530.Tn CAPITALS
531due to troff
532limitations.
533The section number may be 1,\ ...,\ 8,
534and if it is specified,
535the volume title may be omitted.
536A volume title may be arbitrary or one of the following:
537.\" .Cl
538.\" USD UNIX User's Supplementary Documents
539.\" .Cl
540.\" PS1 UNIX Programmer's Supplementary Documents
541.Pp
542.Bl -column SMM -offset indent -compact
15a12343
BIG
543.It Li "AMD UNIX Ancestral Manual Documents"
544.It Li "SMM UNIX System Manager's Manual"
545.It Li "URM UNIX Reference Manual"
546.It Li "PRM UNIX Programmer's Manual"
fea681da
MK
547.El
548.Pp
549The default volume labeling is
550.Li URM
551for sections 1, 6, and 7;
552.Li SMM
553for section 8;
554.Li PRM
555for sections 2, 3, 4, and 5.
556.\" .Cl
557.\" MMI UNIX Manual Master Index
558.\" .Cl
559.\" CON UNIX Contributed Software Manual
560.\" .Cl
561.\" LOC UNIX Local Manual
562.It Li \&.Os operating_system release#
563The name of the operating system
75b94dc3 564should be the common acronym, for example,
fea681da
MK
565.Tn BSD
566or
567.Tn FreeBSD
568or
569.Tn ATT .
570The release should be the standard release
75b94dc3 571nomenclature for the system specified, for example, 4.3, 4.3+Tahoe, V.3,
fea681da
MK
572V.4.
573Unrecognized arguments are displayed as given in the page footer.
574For instance, a typical footer might be:
575.Pp
b14d4aa5 576.Dl \&.Os 4.3BSD
fea681da
MK
577.Pp
578or
579.Dl \&.Os FreeBSD 2.2
580.Pp
581or for a locally produced set
582.Pp
583.Dl \&.Os CS Department
584.Pp
585The Berkeley default,
586.Ql \&.Os
587without an argument, has been defined as
588.Tn BSD
589in the
e2badfdf 590site-specific file
fea681da
MK
591.Pa /usr/share/tmac/mdoc/doc-common .
592It really should default to
593.Tn LOCAL .
594Note, if the
595.Ql \&.Os
596macro is not present, the bottom left corner of the page
597will be ugly.
598.It Li \&.Dd month day, year
599The date should be written formally:
600.Pp
601.ne 5
602.Dl January 25, 1989
603.El
604.Sh INTRODUCTION OF MANUAL AND GENERAL TEXT DOMAINS
605.Ss What's in a name...
606The manual domain macro names are derived from the day to day
607informal language used to describe commands, subroutines and related
608files.
609Slightly different variations of this language are used to describe
610the three different aspects of writing a man page.
611First, there is the description of
612.Nm \-mdoc
613macro request usage.
614Second is the description of a
615.Ux
616command
617.Em with
618.Nm \-mdoc
619macros and third,
620the description of a command to a user in the verbal sense;
621that is, discussion of a command in the text of a man page.
622.Pp
623In the first case,
624.Xr troff 1
625macros are themselves a type of command;
626the general syntax for a troff command is:
627.Bd -filled -offset indent
628\&.Va argument1 argument2 ... argument9
629.Ed
630.Pp
631The
632.Ql \&.Va
633is a macro command or request, and anything following it is an argument to
634be processed.
635In the second case,
636the description of a
637.Ux
638command using the content macros is a
639bit more involved;
640a typical
641.Sx SYNOPSIS
642command line might be displayed as:
643.Bd -filled -offset indent
644.Nm filter
645.Op Fl flag
646.Ar infile outfile
647.Ed
648.Pp
649Here,
650.Nm filter
651is the command name and the
652bracketed string
653.Fl flag
654is a
655.Em flag
656argument designated as optional by the option brackets.
657In
658.Nm \-mdoc
659terms,
660.Ar infile
661and
662.Ar outfile
663are
664called
665.Em arguments .
666The macros which formatted the above example:
667.Bd -literal -offset indent
668\&.Nm filter
669\&.Op \&Fl flag
670\&.Ar infile outfile
671.Ed
672.Pp
673In the third case, discussion of commands and command syntax
674includes both examples above, but may add more detail.
675The
676arguments
677.Ar infile
678and
679.Ar outfile
680from the example above might be referred to as
681.Em operands
682or
683.Em file arguments .
76c44d83 684Some command-line argument lists are quite long:
fea681da
MK
685.Bl -tag -width make -offset indent
686.It Nm make
687.Op Fl eiknqrstv
688.Op Fl D Ar variable
689.Op Fl d Ar flags
690.Op Fl f Ar makefile
691.Bk -words
692.Op Fl I Ar directory
693.Ek
694.Op Fl j Ar max_jobs
695.Op Ar variable=value
696.Bk -words
697.Op Ar target ...
698.Ek
699.El
700.Pp
701Here one might talk about the command
702.Nm make
703and qualify the argument
704.Ar makefile ,
705as an argument to the flag,
706.Fl f ,
707or discuss the optional
708file
709operand
710.Ar target .
711In the verbal context, such detail can prevent confusion,
712however the
713.Nm \-mdoc
714package
715does not have a macro for an argument
716.Em to
717a flag.
718Instead the
719.Ql \&Ar
720argument macro is used for an operand or file argument like
721.Ar target
722as well as an argument to a flag like
723.Ar variable .
724The make command line was produced from:
725.Bd -literal -offset indent
726\&.Nm make
727\&.Op Fl eiknqrstv
728\&.Op Fl D Ar variable
729\&.Op Fl d Ar flags
730\&.Op Fl f Ar makefile
731\&.Op Fl I Ar directory
732\&.Op Fl j Ar max_jobs
733\&.Op Ar variable=value
734\&.Bk -words
735\&.Op Ar target ...
736\&.Ek
737.Ed
738.Pp
739The
740.Ql \&.Bk
741and
742.Ql \&.Ek
743macros are explained in
744.Sx Keeps .
745.Ss General Syntax
746The manual domain and general text domain macros share a similar
747syntax with a few minor deviations:
748.Ql \&.Ar ,
749.Ql \&.Fl ,
750.Ql \&.Nm ,
751and
752.Ql \&.Pa
753differ only when called without arguments;
754.Ql \&.Fn
755and
756.Ql \&.Xr
757impose an order on their argument lists
758and the
759.Ql \&.Op
760and
761.Ql \&.Fn
762macros
763have nesting limitations.
764All content macros
765are capable of recognizing and properly handling punctuation,
766provided each punctuation character is separated by a leading space.
69afed51 767If a request is given:
fea681da
MK
768.Pp
769.Dl \&.Li sptr, ptr),
770.Pp
771The result is:
772.Pp
773.Dl Li sptr, ptr),
774.Pp
775The punctuation is not recognized and all is output in the
776literal font. If the punctuation is separated by a leading
777white space:
778.Pp
779.Dl \&.Li "sptr , ptr ) ,"
780.Pp
781The result is:
782.Pp
783.Dl Li sptr , ptr ) ,
784.Pp
785The punctuation is now recognized and is output in the
786default font distinguishing it from the strings in literal font.
787.Pp
788To remove the special meaning from a punctuation character
789escape it with
31a6818e 790.Ql \e& .
fea681da
MK
791.Xr Troff
792is limited as a macro language, and has difficulty
793when presented with a string containing
794a member of the mathematical, logical or
795quotation set:
796.Bd -literal -offset indent-two
797\&{+,\-,/,*,\&%,<,>,<=,>=,=,==,&,`,',"}
798.Ed
799.Pp
800The problem is that
801.Xr troff
802may assume it is supposed to actually perform the operation
e0ec3e20
MK
803or evaluation suggested by the characters.
804To prevent the accidental evaluation of these characters,
fea681da 805escape them with
31a6818e 806.Ql \e& .
fea681da
MK
807Typical syntax is shown in the first content macro displayed
808below,
809.Ql \&.Ad .
810.Sh MANUAL DOMAIN
811.Ss Address Macro
812The address macro identifies an address construct
813of the form addr1[,addr2[,addr3]].
814.Pp
815.Dl Usage: .Ad address ... \*(Pu
15a12343 816.Bl -tag -width "\&.Ad f1 , f2 , f3 :" -compact -offset 14n
fea681da
MK
817.It Li \&.Ad addr1
818.Ad addr1
819.It Li \&.Ad addr1\ .
820.Ad addr1 .
821.It Li \&.Ad addr1\ , file2
822.Ad addr1 , file2
823.It Li \&.Ad f1\ , f2\ , f3\ :
824.Ad f1 , f2 , f3 :
825.It Li \&.Ad addr\ )\ )\ ,
826.Ad addr ) ) ,
827.El
828.Pp
829It is an error to call
830.Ql \&.Ad
831without arguments.
832.Ql \&.Ad
833is callable by other macros and is parsed.
834.Ss Author Name
835The
836.Ql \&.An
837macro is used to specify the name of the author of the item being
838documented, or the name of the author of the actual manual page.
c13182ef 839Any remaining arguments after the name information are assumed
fea681da
MK
840to be punctuation.
841.Pp
842.Dl Usage: .An author_name \*(Pu
15a12343 843.Bl -tag -width "\&.An Joe Author ) ) ," -compact -offset 14n
fea681da
MK
844.It Li \&.An Joe\ Author
845.An Joe Author
846.It Li \&.An Joe\ Author\ ,
847.An Joe\ Author ,
848.It Li \&.An Joe\ Author\ \&Aq\ nobody@FreeBSD.ORG
849.An Joe Author Aq nobody@FreeBSD.ORG
850.It Li \&.An Joe\ Author\ )\ )\ ,
851.An Joe Author ) ) ,
852.El
853.Pp
854The
855.Ql \&.An
856macro is parsed and is callable.
857It is an error to call
858.Ql \&.An
859without
860any arguments.
861.Ss Argument Macro
862The
863.Ql \&.Ar
864argument macro may be used whenever
76c44d83 865a command-line argument is referenced.
fea681da
MK
866.Pp
867.Dl Usage: .Ar argument ... \*(Pu
15a12343 868.Bl -tag -width "\&.Ar file1 file2" -compact -offset 15n
fea681da
MK
869.It Li \&.Ar
870.Ar
871.It Li \&.Ar file1
872.Ar file1
873.It Li \&.Ar file1\ .
874.Ar file1 .
875.It Li \&.Ar file1 file2
876.Ar file1 file2
877.It Li \&.Ar f1 f2 f3\ :
878.Ar f1 f2 f3 :
879.It Li \&.Ar file\ )\ )\ ,
880.Ar file ) ) ,
881.El
882.Pp
883If
884.Ql \&.Ar
075972df 885is called without arguments,
15a12343 886.Ql \&Ar
fea681da
MK
887is assumed.
888The
889.Ql \&.Ar
890macro is parsed and is callable.
891.Ss Configuration Declaration (section four only)
892The
893.Ql \&.Cd
894macro is used to demonstrate a
895.Xr config 8
896declaration for a device interface in a section four manual.
897This macro accepts quoted arguments (double quotes only).
898.Pp
899.Bl -tag -width "device le0 at scode?" -offset indent
900.It Cd "device le0 at scode?"
901produced by:
902.Ql ".Cd device le0 at scode?" .
903.El
904.Ss Command Modifier
905The command modifier is identical to the
906.Ql \&.Fl
907(flag) command with the exception
908the
909.Ql \&.Cm
910macro does not assert a dash
911in front of every argument.
912Traditionally flags are marked by the
913preceding dash, some commands or subsets of commands do not use them.
914Command modifiers may also be specified in conjunction with interactive
915commands such as editor commands.
916See
917.Sx Flags .
918.Ss Defined Variables
919A variable which is defined in an include file is specified
920by the macro
921.Ql \&.Dv .
922.Pp
923.Dl Usage: .Dv defined_variable ... \*(Pu
15a12343 924.Bl -tag -width "\&.Dv MAXHOSTNAMELEN" -compact -offset 14n
fea681da
MK
925.It Li ".Dv MAXHOSTNAMELEN"
926.Dv MAXHOSTNAMELEN
927.It Li ".Dv TIOCGPGRP )"
928.Dv TIOCGPGRP )
929.El
930.Pp
931It is an error to call
932.Ql \&.Dv
933without arguments.
934.Ql \&.Dv
935is parsed and is callable.
936.Ss Errno's (Section two only)
937The
938.Ql \&.Er
939errno macro specifies the error return value
940for section two library routines.
941The second example
942below shows
943.Ql \&.Er
944used with the
945.Ql \&.Bq
946general text domain macro, as it would be used in
947a section two manual page.
948.Pp
949.Dl Usage: .Er ERRNOTYPE ... \*(Pu
15a12343 950.Bl -tag -width "\&.Bq Er ENOTDIR" -compact -offset 14n
fea681da
MK
951.It Li \&.Er ENOENT
952.Er ENOENT
953.It Li \&.Er ENOENT\ )\ ;
954.Er ENOENT ) ;
955.It Li \&.Bq \&Er ENOTDIR
956.Bq Er ENOTDIR
957.El
958.Pp
959It is an error to call
960.Ql \&.Er
961without arguments.
962The
963.Ql \&.Er
964macro is parsed and is callable.
965.Ss Environment Variables
966The
967.Ql \&.Ev
968macro specifies an environment variable.
969.Pp
970.Dl Usage: .Ev argument ... \*(Pu
15a12343 971.Bl -tag -width "\&.Ev PRINTER ) ) ," -compact -offset 14n
fea681da
MK
972.It Li \&.Ev DISPLAY
973.Ev DISPLAY
974.It Li \&.Ev PATH\ .
975.Ev PATH .
976.It Li \&.Ev PRINTER\ )\ )\ ,
977.Ev PRINTER ) ) ,
978.El
979.Pp
980It is an error to call
981.Ql \&.Ev
982without arguments.
983The
984.Ql \&.Ev
985macro is parsed and is callable.
986.Ss Function Argument
987The
988.Ql \&.Fa
989macro is used to refer to function arguments (parameters)
990outside of the
991.Sx SYNOPSIS
992section of the manual or inside
993the
994.Sx SYNOPSIS
995section should a parameter list be too
996long for the
997.Ql \&.Fn
998macro and the enclosure macros
999.Ql \&.Fo
1000and
1001.Ql \&.Fc
1002must be used.
1003.Ql \&.Fa
1004may also be used to refer to structure members.
1005.Pp
1006.Dl Usage: .Fa function_argument ... \*(Pu
15a12343 1007.Bl -tag -width "\&.Fa d_namlen\ )\ )\ ," -compact -offset 14n
fea681da
MK
1008.It Li \&.Fa d_namlen\ )\ )\ ,
1009.Fa d_namlen ) ) ,
1010.It Li \&.Fa iov_len
1011.Fa iov_len
1012.El
1013.Pp
1014It is an error to call
1015.Ql \&.Fa
1016without arguments.
1017.Ql \&.Fa
1018is parsed and is callable.
1019.Ss Function Declaration
1020The
1021.Ql \&.Fd
1022macro is used in the
1023.Sx SYNOPSIS
1024section with section two or three
1025functions.
1026The
1027.Ql \&.Fd
1028macro does not call other macros and is not callable by other
1029macros.
1030.Pp
1031.Dl Usage: .Fd include_file (or defined variable)
1032.Pp
1033In the
1034.Sx SYNOPSIS
1035section a
1036.Ql \&.Fd
1037request causes a line break if a function has already been presented
1038and a break has not occurred.
1039This leaves a nice vertical space
1040in between the previous function call and the declaration for the
1041next function.
1042.Ss Flags
1043The
1044.Ql \&.Fl
76c44d83 1045macro handles command-line flags.
fea681da
MK
1046It prepends
1047a dash,
1048.Ql \- ,
1049to the flag.
1050For interactive command flags, which
1051are not prepended with a dash, the
1052.Ql \&.Cm
1053(command modifier)
1054macro is identical, but without the dash.
1055.Pp
1056.Dl Usage: .Fl argument ... \*(Pu
15a12343 1057.Bl -tag -width "\&.Fl \-s \-t \-v" -compact -offset 14n
fea681da
MK
1058.It Li \&.Fl
1059.Fl
1060.It Li \&.Fl cfv
1061.Fl cfv
1062.It Li \&.Fl cfv\ .
1063.Fl cfv .
1064.It Li \&.Fl s v t
1065.Fl s v t
1066.It Li \&.Fl -\ ,
1067.Fl - ,
1068.It Li \&.Fl xyz\ )\ ,
1069.Fl xyz ) ,
1070.El
1071.Pp
1072The
1073.Ql \&.Fl
1074macro without any arguments results
9bef72b5 1075in a dash representing \fIstdin\fP/\fIstdout\fP.
fea681da
MK
1076Note that giving
1077.Ql \&.Fl
1078a single dash, will result in two dashes.
1079The
1080.Ql \&.Fl
1081macro is parsed and is callable.
1082.Ss Functions (library routines)
1083The .Fn macro is modeled on ANSI C conventions.
1084.Bd -literal
1085Usage: .Fn [type] function [[type] parameters ... \*(Pu]
1086.Ed
15a12343 1087.Bl -tag -width "\&.Fn _int align_ _const * char *sptrsxx" -compact
fea681da
MK
1088.It Li "\&.Fn getchar"
1089.Fn getchar
1090.It Li "\&.Fn strlen ) ,"
1091.Fn strlen ) ,
1092.It Li \&.Fn "\\*qint align\\*q" "\\*qconst * char *sptrs\\*q" ,
1093.Fn "int align" "const * char *sptrs" ,
1094.El
1095.Pp
1096It is an error to call
1097.Ql \&.Fn
1098without any arguments.
1099The
1100.Ql \&.Fn
1101macro
1102is parsed and is callable,
1103note that any call to another macro signals the end of
1104the
1105.Ql \&.Fn
1106call (it will close-parenthesis at that point).
1107.Pp
1108For functions that have more than eight parameters (and this
1109is rare), the
1110macros
1111.Ql \&.Fo
1112(function open)
1113and
1114.Ql \&.Fc
1115(function close)
1116may be used with
1117.Ql \&.Fa
1118(function argument)
ca7b3c18
MK
1119to get around the limitation.
1120For example:
fea681da
MK
1121.Bd -literal -offset indent
1122\&.Fo "int res_mkquery"
1123\&.Fa "int op"
1124\&.Fa "char *dname"
1125\&.Fa "int class"
1126\&.Fa "int type"
1127\&.Fa "char *data"
1128\&.Fa "int datalen"
1129\&.Fa "struct rrec *newrr"
1130\&.Fa "char *buf"
1131\&.Fa "int buflen"
1132\&.Fc
1133.Ed
1134.Pp
1135Produces:
1136.Bd -filled -offset indent
1137.Fo "int res_mkquery"
1138.Fa "int op"
1139.Fa "char *dname"
1140.Fa "int class"
1141.Fa "int type"
1142.Fa "char *data"
1143.Fa "int datalen"
1144.Fa "struct rrec *newrr"
1145.Fa "char *buf"
1146.Fa "int buflen"
1147.Fc
1148.Ed
1149.Pp
1150The
1151.Ql \&.Fo
1152and
1153.Ql \&.Fc
1154macros are parsed and are callable.
1155In the
1156.Sx SYNOPSIS
1157section, the function will always begin at
1158the beginning of line.
1159If there is more than one function
1160presented in the
1161.Sx SYNOPSIS
1162section and a function type has not been
1163given, a line break will occur, leaving a nice vertical space
1164between the current function name and the one prior.
1165At the moment,
1166.Ql \&.Fn
1167does not check its word boundaries
1168against troff line lengths and may split across a newline
1169ungracefully.
1170This will be fixed in the near future.
1171.Ss Function Type
1172This macro is intended for the
1173.Sx SYNOPSIS
1174section.
1175It may be used
1176anywhere else in the man page without problems, but its main purpose
1177is to present the function type in kernel normal form for the
1178.Sx SYNOPSIS
1179of sections two and three
1180(it causes a line break allowing the function name to appear
1181on the next line).
1182.Pp
1183.Dl Usage: .Ft type ... \*(Pu
1184.Bl -tag -width "\&.Ft struct stat" -offset 14n -compact
1185.It Li \&.Ft struct stat
1186.Ft struct stat
1187.El
1188.Pp
1189The
1190.Ql \&.Ft
1191request is not callable by other macros.
1192.Ss Interactive Commands
1193The
1194.Ql \&.Ic
1195macro designates an interactive or internal command.
1196.Pp
1197.Dl Usage: .Ic argument ... \*(Pu
15a12343 1198.Bl -tag -width "\&.Ic setenv , unsetenvxx" -compact -offset 14n
fea681da
MK
1199.It Li \&.Ic :wq
1200.Ic :wq
1201.It Li \&.Ic do while {...}
1202.Ic do while {...}
1203.It Li \&.Ic setenv\ , unsetenv
1204.Ic setenv , unsetenv
1205.El
1206.Pp
1207It is an error to call
1208.Ql \&.Ic
1209without arguments.
1210The
1211.Ql \&.Ic
1212macro is parsed and is callable.
1213.Ss Name Macro
1214The
1215.Ql \&.Nm
1216macro is used for the document title or subject name.
1217It has the peculiarity of remembering the first
1218argument it was called with, which should
1219always be the subject name of the page.
1220When called without
1221arguments,
1222.Ql \&.Nm
1223regurgitates this initial name for the sole purpose
1224of making less work for the author.
1225Note:
1226a section two
1227or three document function name is addressed with the
1228.Ql \&.Nm
1229in the
1230.Sx NAME
1231section, and with
1232.Ql \&.Fn
1233in the
1234.Sx SYNOPSIS
1235and remaining sections.
1236For interactive commands, such as the
1237.Ql while
1238command keyword in
1239.Xr csh 1 ,
1240the
1241.Ql \&.Ic
1242macro should be used.
1243While the
1244.Ql \&.Ic
1245is nearly identical
1246to
1247.Ql \&.Nm ,
1248it can not recall the first argument it was invoked with.
1249.Pp
1250.Dl Usage: .Nm argument ... \*(Pu
15a12343 1251.Bl -tag -width "\&.Nm mdoc.sample" -compact -offset 14n
fea681da 1252.It Li \&.Nm mdoc.sample
0425de01 1253.Nm mdoc.sample
31a6818e 1254.It Li \&.Nm \e-mdoc
fea681da
MK
1255.Nm \-mdoc .
1256.It Li \&.Nm foo\ )\ )\ ,
1257.Nm foo ) ) ,
1258.It Li \&.Nm
1259.Nm
1260.El
1261.Pp
1262The
1263.Ql \&.Nm
1264macro is parsed and is callable.
1265.Ss Options
1266The
1267.Ql \&.Op
1268macro
1269places option brackets around the any remaining arguments on the command
1270line, and places any
1271trailing punctuation outside the brackets.
1272The macros
1273.Ql \&.Oc
1274and
1275.Ql \&.Oo
1276may be used across one or more lines.
1277.Pp
1278.Dl Usage: .Op options ... \*(Pu
15a12343 1279.Bl -tag -width "\&.Op Fl c Ar objfil Op Ar corfil ," -compact -offset indent
fea681da
MK
1280.It Li \&.Op
1281.Op
1282.It Li ".Op Fl k"
1283.Op Fl k
1284.It Li ".Op Fl k ) ."
1285.Op Fl k ) .
1286.It Li ".Op Fl k Ar kookfile"
1287.Op Fl k Ar kookfile
1288.It Li ".Op Fl k Ar kookfile ,"
1289.Op Fl k Ar kookfile ,
1290.It Li ".Op Ar objfil Op Ar corfil"
1291.Op Ar objfil Op Ar corfil
1292.It Li ".Op Fl c Ar objfil Op Ar corfil ,"
1293.Op Fl c Ar objfil Op Ar corfil ,
1294.It Li \&.Op word1 word2
1295.Op word1 word2
1296.El
1297.Pp
1298The
1299.Ql \&.Oc
1300and
1301.Ql \&.Oo
1302macros:
1303.Bd -literal -offset indent
1304\&.Oo
1305\&.Op \&Fl k \&Ar kilobytes
1306\&.Op \&Fl i \&Ar interval
1307\&.Op \&Fl c \&Ar count
1308\&.Oc
1309.Ed
1310.Pp
1311Produce:
1312.Oo
1313.Op Fl k Ar kilobytes
1314.Op Fl i Ar interval
1315.Op Fl c Ar count
1316.Oc
1317.Pp
1318The macros
1319.Ql \&.Op ,
1320.Ql \&.Oc
1321and
1322.Ql \&.Oo
1323are parsed and are callable.
1324.Ss Pathnames
1325The
1326.Ql \&.Pa
ef50679c 1327macro formats pathnames or filenames.
fea681da
MK
1328.Pp
1329.Dl Usage: .Pa pathname \*(Pu
15a12343 1330.Bl -tag -width "\&.Pa /tmp/fooXXXXX ) ." -compact -offset 14n
fea681da
MK
1331.It Li \&.Pa /usr/share
1332.Pa /usr/share
1333.It Li \&.Pa /tmp/fooXXXXX\ )\ .
1334.Pa /tmp/fooXXXXX ) .
1335.El
1336.Pp
1337The
1338.Ql \&.Pa
1339macro is parsed and is callable.
1340.Ss Variables
1341Generic variable reference:
1342.Pp
1343.Dl Usage: .Va variable ... \*(Pu
15a12343 1344.Bl -tag -width "\&.Va char s ] ) ) ," -compact -offset 14n
fea681da
MK
1345.It Li \&.Va count
1346.Va count
1347.It Li \&.Va settimer ,
1348.Va settimer ,
1349.It Li \&.Va int\ *prt\ )\ :
1350.Va int\ *prt ) :
1351.It Li \&.Va char\ s\ ]\ )\ )\ ,
1352.Va char\ s ] ) ) ,
1353.El
1354.Pp
1355It is an error to call
1356.Ql \&.Va
1357without any arguments.
1358The
1359.Ql \&.Va
1360macro is parsed and is callable.
1361.Ss Manual Page Cross References
1362The
1363.Ql \&.Xr
1364macro expects the first argument to be
1365a manual page name, and the second argument, if it exists,
1366to be either a section page number or punctuation.
1367Any
1368remaining arguments are assumed to be punctuation.
1369.Pp
1370.Dl Usage: .Xr man_page [1,...,8] \*(Pu
15a12343 1371.Bl -tag -width "\&.Xr mdoc 7 ) ) ," -compact -offset 14n
fea681da
MK
1372.It Li \&.Xr mdoc
1373.Xr mdoc
1374.It Li \&.Xr mdoc\ ,
1375.Xr mdoc ,
1376.It Li \&.Xr mdoc 7
1377.Xr mdoc 7
1378.It Li \&.Xr mdoc 7\ )\ )\ ,
1379.Xr mdoc 7 ) ) ,
1380.El
1381.Pp
1382The
1383.Ql \&.Xr
1384macro is parsed and is callable.
1385It is an error to call
1386.Ql \&.Xr
1387without
1388any arguments.
1389.Sh GENERAL TEXT DOMAIN
1390.Ss AT&T Macro
1391.Bd -literal -offset indent -compact
1392Usage: .At [v6 | v7 | 32v | V.1 | V.4] ... \*(Pu
1393.Ed
15a12343 1394.Bl -tag -width "\&.At v6 ) ," -compact -offset 14n
fea681da
MK
1395.It Li ".At"
1396.At
1397.It Li ".At v6 ."
1398.At v6 .
1399.El
1400.Pp
1401The
1402.Ql \&.At
1403macro is
1404.Em not
1405parsed and
1406.Em not
ca7b3c18
MK
1407callable
1408It accepts at most two arguments.
fea681da
MK
1409.Ss BSD Macro
1410.Dl Usage: .Bx [Version/release] ... \*(Pu
15a12343 1411.Bl -tag -width "\&.Bx 4.3 ) ," -compact -offset 14n
fea681da
MK
1412.It Li ".Bx"
1413.Bx
1414.It Li ".Bx 4.3 ."
1415.Bx 4.3 .
1416.El
1417.Pp
1418The
1419.Ql \&.Bx
1420macro is parsed and is callable.
1421.Ss FreeBSD Macro
1422.Bd -literal -offset indent -compact
1423Usage: .Fx Version.release ... \*(Pu
1424.Ed
15a12343 1425.Bl -tag -width "\&.Fx 2.2 ) ," -compact -offset 14n
fea681da
MK
1426.It Li ".Fx 2.2 ."
1427.Fx 2.2 .
1428.El
1429.Pp
1430The
1431.Ql \&.Fx
1432macro is
1433.Em not
1434parsed and
1435.Em not
ca7b3c18
MK
1436callable
1437It accepts at most two arguments.
fea681da
MK
1438.Ss UNIX Macro
1439.Dl Usage: .Ux ... \*(Pu
15a12343 1440.Bl -tag -width "\&.Ux 4.3 ) ," -compact -offset 14n
fea681da
MK
1441.It Li ".Ux"
1442.Ux
1443.El
1444.Pp
1445The
1446.Ql \&.Ux
1447macro is parsed and is callable.
1448.Ss Enclosure and Quoting Macros
1449The concept of enclosure is similar to quoting.
1450The object being to enclose one or more strings between
1451a pair of characters like quotes or parentheses.
1452The terms quoting and enclosure are used
1453interchangeably throughout this document.
1454Most of the
1455one line enclosure macros end
1456in small letter
1457.Ql q
1458to give a hint of quoting, but there are a few irregularities.
1459For each enclosure macro
1460there is also a pair of open and close macros which end
1461in small letters
1462.Ql o
1463and
1464.Ql c
1465respectively.
1466These can be used across one or more lines of text
1467and while they have nesting limitations, the one line quote macros
1468can be used inside
1469of them.
1470.Pp
1471.ne 5
1472.Bd -filled -offset indent
1473.Bl -column "quote " "close " "open " "Enclose Stringx(in XX) " XXstringXX
1474.Em " Quote Close Open Function Result"
1475\&.Aq .Ac .Ao Angle Bracket Enclosure <string>
1476\&.Bq .Bc .Bo Bracket Enclosure [string]
1477\&.Dq .Dc .Do Double Quote ``string''
1478 .Ec .Eo Enclose String (in XX) XXstringXX
1479\&.Pq .Pc .Po Parenthesis Enclosure (string)
1480\&.Ql Quoted Literal `st' or string
1481\&.Qq .Qc .Qo Straight Double Quote "string"
1482\&.Sq .Sc .So Single Quote `string'
1483.El
1484.Ed
1485.Pp
1486Except for the irregular macros noted below, all
1487of the quoting macros are parsed and callable.
1488All handle punctuation properly, as long as it
1489is presented one character at a time and separated by spaces.
1490The quoting macros examine opening and closing punctuation
1491to determine whether it comes before or after the
ca7b3c18
MK
1492enclosing string
1493This makes some nesting possible.
fea681da
MK
1494.Bl -tag -width xxx,xxxx
1495.It Li \&.Ec , \&.Eo
1496These macros expect the first argument to be the
1497opening and closing strings respectively.
1498.It Li \&.Ql
1499The quoted literal macro behaves differently for
1500.Xr troff
1501than
1502.Xr nroff .
1503If formatted with
1504.Xr nroff ,
ca7b3c18
MK
1505a quoted literal is always quoted.
1506If formatted with
33a0ccb2 1507troff, an item is quoted only if the width
fea681da
MK
1508of the item is less than three constant width characters.
1509This is to make short strings more visible where the font change
1510to literal (constant width) is less noticeable.
1511.It Li \&.Pf
1512The prefix macro is not callable, but it is parsed:
1513.Bl -tag -width "(namexx" -offset indent
1514.It Li ".Pf ( Fa name2"
1515becomes
1516.Pf ( Fa name2 .
1517.El
1518.Pp
1519The
1520.Ql \&.Ns
1521(no space) macro performs the analogous suffix function.
1522.El
1523.Pp
1524.ne 4
1525Examples of quoting:
15a12343 1526.Bl -tag -width "\&.Aq Pa ctype.h ) ,xxxxxxxx" -compact -offset indent
fea681da
MK
1527.It Li \&.Aq
1528.Aq
1529.It Li \&.Aq \&Ar ctype.h\ )\ ,
1530.Aq Ar ctype.h ) ,
1531.It Li \&.Bq
1532.Bq
1533.It Li \&.Bq \&Em Greek \&, French \&.
1534.Bq Em Greek , French .
1535.It Li \&.Dq
1536.Dq
1537.It Li ".Dq string abc ."
1538.Dq string abc .
1539.It Li ".Dq \'^[A-Z]\'"
1540.Dq \'^[A-Z]\'
1541.It Li "\&.Ql man mdoc"
1542.Ql man mdoc
1543.It Li \&.Qq
1544.Qq
1545.It Li "\&.Qq string ) ,"
1546.Qq string ) ,
1547.It Li "\&.Qq string Ns ),"
1548.Qq string Ns ),
1549.It Li \&.Sq
1550.Sq
1551.It Li "\&.Sq string
1552.Sq string
1553.El
1554.Pp
1555For a good example of nested enclosure macros, see the
1556.Ql \&.Op
1557option macro.
1558It was created from the same
1559underlying enclosure macros as those presented in the list
1560above.
1561The
1562.Ql \&.Xo
1563and
1564.Ql \&.Xc
1565extended argument list macros
1566were also built from the same underlying routines and are a good
1567example of
1568.Nm \-mdoc
1569macro usage at its worst.
1570.Ss No\-Op or Normal Text Macro
1571The macro
1572.Ql \&.No
1573is
1574a hack for words in a macro command line which should
1575.Em not
1576be formatted and follows the conventional syntax
1577for content macros.
1578.Ss No Space Macro
1579The
1580.Ql \&.Ns
1581macro eliminates unwanted spaces in between macro requests.
1582It is useful for old style argument lists where there is no space
1583between the flag and argument:
15a12343 1584.Bl -tag -width "\&.Op Fl I Ns Ar directoryxx" -offset indent
fea681da
MK
1585.It Li ".Op Fl I Ns Ar directory"
1586produces
1587.Op Fl I Ns Ar directory
1588.El
1589.Pp
1590Note: the
1591.Ql \&.Ns
1592macro always invokes the
1593.Ql \&.No
1594macro after eliminating the space unless another macro name
1595follows it.
1596The macro
1597.Ql \&.Ns
1598is parsed and is callable.
1599.Ss Section Cross References
1600The
1601.Ql \&.Sx
1602macro designates a reference to a section header
1603within the same document.
1604It is parsed and is callable.
1605.Pp
1606.Bl -tag -width "Li \&.Sx FILES" -offset 14n
1607.It Li \&.Sx FILES
1608.Sx FILES
1609.El
1610.Ss References and Citations
1611The following macros make a modest attempt to handle references.
1612At best, the macros make it convenient to manually drop in a subset of
1613refer style references.
1614.Pp
1615.Bl -tag -width 6n -offset indent -compact
1616.It Li ".Rs"
1617Reference Start.
1618Causes a line break and begins collection
1619of reference information until the
1620reference end macro is read.
1621.It Li ".Re"
1622Reference End.
1623The reference is printed.
1624.It Li ".%A"
1625Reference author name, one name per invocation.
1626.It Li ".%B"
1627Book title.
1628.It Li ".\&%C"
1629City/place.
1630.It Li ".\&%D"
1631Date.
1632.It Li ".%J"
1633Journal name.
1634.It Li ".%N"
1635Issue number.
1636.It Li ".%O"
1637Optional information.
1638.It Li ".%P"
1639Page number.
1640.It Li ".%R"
1641Report name.
1642.It Li ".%T"
1643Title of article.
1644.It Li ".%V"
1645Volume(s).
1646.El
1647.Pp
1648The macros beginning with
1649.Ql %
1650are not callable, and are parsed only for the trade name macro which
1651returns to its caller.
1652(And not very predictably at the moment either.)
1653The purpose is to allow trade names
1654to be pretty printed in
1655.Xr troff Ns / Ns Xr ditroff
1656output.
1657.Ss Return Values
1658The
1659.Ql \&.Rv
1660macro generates text for use in the
0b5dc6f1 1661.Sx RETURN VALUE
fea681da
MK
1662section.
1663.Pp
1664.Dl Usage: .Rv [-std function]
1665.Pp
1666.Ql \&.Rv -std atexit
1667will generate the following text:
1668.Pp
15a12343
BIG
1669.\" fake section 3 to avoid error message from Rv
1670.\".ds cH 3
1671.ds section 3
fea681da
MK
1672.Rv -std atexit
1673.\" and back to 7 again
15a12343
BIG
1674.\".ds cH 7
1675.ds section 7
fea681da
MK
1676.Pp
1677The
1678.Fl std
1679option is valid only for manual page sections 2 and 3.
1680.Ss Trade Names (or Acronyms and Type Names)
1681The trade name macro is generally a small caps macro for
efaef3da 1682all uppercase words longer than two characters.
fea681da
MK
1683.Pp
1684.Dl Usage: .Tn symbol ... \*(Pu
15a12343 1685.Bl -tag -width "\&.Tn ASCII" -compact -offset 14n
fea681da
MK
1686.It Li \&.Tn DEC
1687.Tn DEC
1688.It Li \&.Tn ASCII
1689.Tn ASCII
1690.El
1691.Pp
1692The
1693.Ql \&.Tn
1694macro
1695is parsed and is callable by other macros.
1696.Ss Extended Arguments
1697The
1698.Ql \&.Xo
1699and
1700.Ql \&.Xc
1701macros allow one to extend an argument list
1702on a macro boundary.
1703Argument lists cannot
1704be extended within a macro
1705which expects all of its arguments on one line such
1706as
1707.Ql \&.Op .
1708.Pp
1709Here is an example of
1710.Ql \&.Xo
1711using the space mode macro to turn spacing off:
1712.Bd -literal -offset indent
1713\&.Sm off
1714\&.It Xo Sy I Ar operation
31a6818e 1715\&.No \een Ar count No \een
fea681da
MK
1716\&.Xc
1717\&.Sm on
1718.Ed
1719.Pp
1720Produces
1721.Bd -filled -offset indent
1722.Bl -tag -width flag -compact
1723.Sm off
1724.It Xo Sy I Ar operation
31a6818e 1725.No \en Ar count No \en
fea681da
MK
1726.Xc
1727.Sm on
1728.El
1729.Ed
1730.Pp
1731Another one:
1732.Bd -literal -offset indent
1733\&.Sm off
1734\&.It Cm S No \&/ Ar old_pattern Xo
1735\&.No \&/ Ar new_pattern
1736\&.No \&/ Op Cm g
1737\&.Xc
1738\&.Sm on
1739.Ed
1740.Pp
1741Produces
1742.Bd -filled -offset indent
1743.Bl -tag -width flag -compact
1744.Sm off
1745.It Cm S No \&/ Ar old_pattern Xo
1746.No \&/ Ar new_pattern
1747.No \&/ Op Cm g
1748.Xc
1749.Sm on
1750.El
1751.Ed
1752.Pp
1753Another example of
1754.Ql \&.Xo
1755and using enclosure macros:
69afed51 1756Test the value of a variable.
fea681da
MK
1757.Bd -literal -offset indent
1758\&.It Xo
1759\&.Ic .ifndef
31a6818e 1760\&.Oo \e&! Oc Ns Ar variable
fea681da
MK
1761\&.Op Ar operator variable ...
1762\&.Xc
1763.Ed
1764.Pp
1765Produces
1766.Bd -filled -offset indent
1767.Bl -tag -width flag -compact
1768.It Xo
1769.Ic .ifndef
1770.Oo \&! Oc Ns Ar variable
1771.Op Ar operator variable ...
1772.Xc
1773.El
1774.Ed
1775.Pp
1776All of the above examples have used the
1777.Ql \&.Xo
1778macro on the argument list of the
1779.Ql \&.It
1780(list-item)
1781macro.
1782The extend macros are not used very often, and when they are
1783it is usually to extend the list-item argument list.
1784Unfortunately, this is also where the extend macros are the
1785most finicky.
1786In the first two examples, spacing was turned off;
1787in the third, spacing was desired in part of the output but
1788not all of it.
1789To make these macros work in this situation make sure
1790the
1791.Ql \&.Xo
1792and
1793.Ql \&.Xc
1794macros are placed as shown in the third example.
1795If the
1796.Ql \&.Xo
1797macro is not alone on the
1798.Ql \&.It
1799argument list, spacing will be unpredictable.
1800The
1801.Ql \&.Ns
1802(no space macro)
1803must not occur as the first or last macro on a line
1804in this situation.
1805Out of 900 manual pages (about 1500 actual pages)
1806currently released with
1807.Bx
1808only fifteen use the
1809.Ql \&.Xo
1810macro.
1811.Sh PAGE STRUCTURE DOMAIN
1812.Ss Section Headers
1813The first three
1814.Ql \&.Sh
1815section header macros
1816list below are required in every
1817man page.
1818The remaining section headers
1819are recommended at the discretion of the author
1820writing the manual page.
1821The
1822.Ql \&.Sh
1823macro can take up to nine arguments.
1824It is parsed and but is not callable.
15a12343 1825.Bl -tag -width "\&.Sh SYNOPSIS"
fea681da
MK
1826.It \&.Sh NAME
1827The
1828.Ql \&.Sh NAME
1829macro is mandatory.
1830If not specified,
1831the headers, footers and page layout defaults
1832will not be set and things will be rather unpleasant.
1833The
1834.Sx NAME
1835section consists of at least three items.
1836The first is the
1837.Ql \&.Nm
1838name macro naming the subject of the man page.
1839The second is the Name Description macro,
1840.Ql \&.Nd ,
1841which separates the subject
1842name from the third item, which is the description.
1843The
1844description should be the most terse and lucid possible,
1845as the space available is small.
1846.It \&.Sh SYNOPSIS
1847The
1848.Sx SYNOPSIS
1849section describes the typical usage of the
1850subject of a man page.
0425de01 1851The macros required
fea681da
MK
1852are either
1853.Ql ".Nm" ,
1854.Ql ".Cd" ,
1855.Ql ".Fn" ,
1856(and possibly
1857.Ql ".Fo" ,
1858.Ql ".Fc" ,
1859.Ql ".Fd" ,
1860.Ql ".Ft"
1861macros).
1862The function name
1863macro
1864.Ql ".Fn"
1865is required
1866for manual page sections 2 and 3, the command and general
1867name macro
1868.Ql \&.Nm
1869is required for sections 1, 5, 6, 7, 8.
1870Section 4 manuals require a
c13182ef 1871.Ql ".Nm" ,
fea681da
MK
1872.Ql ".Fd"
1873or a
1874.Ql ".Cd"
1875configuration device usage macro.
1876Several other macros may be necessary to produce
1877the synopsis line as shown below:
15a12343 1878.El
fea681da
MK
1879.Pp
1880.Bd -filled -offset indent
1881.Nm cat
1882.Op Fl benstuv
1883.Op Fl
1884.Ar
1885.Ed
1886.Pp
1887The following macros were used:
1888.Pp
1889.Dl \&.Nm cat
1890.Dl \&.Op \&Fl benstuv
1891.Dl \&.Op \&Fl
1892.Dl \&.Ar
1893.Pp
1894.Sy Note :
1895The macros
1896.Ql \&.Op ,
1897.Ql \&.Fl ,
1898and
1899.Ql \&.Ar
1900recognize the pipe bar character
1901.Ql \*(Ba ,
1902so a command line such as:
1903.Pp
1904.Dl ".Op Fl a | Fl b"
1905.Pp
1906will not go orbital.
1907.Xr Troff
1908normally interprets a \*(Ba as a special operator.
1909See
1910.Sx PREDEFINED STRINGS
1911for a usable \*(Ba
1912character in other situations.
15a12343 1913.Bl -tag
fea681da
MK
1914.It \&.Sh DESCRIPTION
1915In most cases the first text in the
1916.Sx DESCRIPTION
1917section
1918is a brief paragraph on the command, function or file,
1919followed by a lexical list of options and respective
1920explanations.
1921To create such a list, the
1922.Ql \&.Bl
1923begin-list,
1924.Ql \&.It
1925list-item and
1926.Ql \&.El
1927end-list
1928macros are used (see
1929.Sx Lists and Columns
1930below).
1931.El
1932.Pp
1933The following
1934.Ql \&.Sh
1935section headers are part of the
1936preferred manual page layout and must be used appropriately
1937to maintain consistency.
1938They are listed in the order
1939in which they would be used.
1940.Bl -tag -width SYNOPSIS
1941.It \&.Sh ENVIRONMENT
1942The
1943.Sx ENVIRONMENT
1944section should reveal any related
1945environment
1946variables and clues to their behavior and/or usage.
1947.It \&.Sh EXAMPLES
1948There are several ways to create examples.
1949See
1950the
1951.Sx EXAMPLES
1952section below
1953for details.
1954.It \&.Sh FILES
1955Files which are used or created by the man page subject
1956should be listed via the
1957.Ql \&.Pa
1958macro in the
1959.Sx FILES
1960section.
1961.It \&.Sh SEE ALSO
1962References to other material on the man page topic and
1963cross references to other relevant man pages should
1964be placed in the
1965.Sx SEE ALSO
1966section.
1967Cross references
1968are specified using the
1969.Ql \&.Xr
1970macro.
1971Cross references in the
1972.Sx SEE ALSO
1973section should be sorted by section number, and then
1974placed in alphabetical order and comma separated. For example:
1975.Pp
1976.Xr ls 1 ,
1977.Xr ps 1 ,
1978.Xr group 5 ,
1979.Xr passwd 5 .
1980.Pp
1981At this time
1982.Xr refer 1
1983style references are not accommodated.
1984.It \&.Sh CONFORMING TO
1985If the command, library function or file adheres to a
1986specific implementation such as
1987.St -p1003.2
1988or
1989.St -ansiC
1990this should be noted here.
1991If the
1992command does not adhere to any standard, its history
1993should be noted in the
1994.Sx HISTORY
1995section.
1996.It \&.Sh HISTORY
1997Any command which does not adhere to any specific standards
1998should be outlined historically in this section.
1999.It \&.Sh AUTHORS
2000Credits, if need be, should be placed here.
2001.It \&.Sh DIAGNOSTICS
2002Diagnostics from a command should be placed in this section.
2003.It \&.Sh ERRORS
2004Specific error handling, especially from library functions
2005(man page sections 2 and 3) should go here.
2006The
2007.Ql \&.Er
2008macro is used to specify an errno.
2009.It \&.Sh BUGS
2010Blatant problems with the topic go here...
2011.El
2012.Pp
2013User specified
2014.Ql \&.Sh
2015sections may be added,
2016for example, this section was set with:
2017.Bd -literal -offset 14n
2018\&.Sh PAGE STRUCTURE DOMAIN
2019.Ed
2020.Ss Paragraphs and Line Spacing.
2021.Bl -tag -width 6n
2022.It \&.Pp
2023The
2024.Ql \&.Pp
2025paragraph command may
2026be used to specify a line space where necessary.
2027The macro is not necessary after a
2028.Ql \&.Sh
2029or
2030.Ql \&.Ss
2031macro or before
2032a
2033.Ql \&.Bl
2034macro.
2035(The
2036.Ql \&.Bl
2037macro asserts a vertical distance unless the -compact flag is given).
2038.El
2039.\" This worked with version one, need to redo for version three
2040.\" .Pp
2041.\" .Ds I
2042.\" .Cw (ax+bx+c) \ is\ produced\ by\ \&
2043.\" .\".Cw (ax+bx+c) \&.Va_by_) \&_and_\& \&[?/]m_b1_e1_f1[?/]\&
2044.\" .Cl Cx \t\t
2045.\" .Li \&.Cx\ (
2046.\" .Cx
2047.\" .Cl Cx \t\t
2048.\" .Li \&.Va ax
2049.\" .Cx
2050.\" .Cl Cx \t\t
2051.\" .Li \&.Sy \+
2052.\" .Cx
2053.\" .Cl Cx \&(\&
2054.\" .Va ax
2055.\" .Cx +
2056.\" .Va by
2057.\" .Cx +
2058.\" .Va c )
2059.\" .Cx \t
2060.\" .Em is produced by
2061.\" .Cx \t
2062.\" .Li \&.Va by
2063.\" .Cx
2064.\" .Cl Cx \t\t
2065.\" .Li \&.Sy \+
2066.\" .Cx
2067.\" .Cl Cx \t\t
2068.\" .Li \&.Va c )
2069.\" .Cx
2070.\" .Cl Cx \t\t
2071.\" .Li \&.Cx
2072.\" .Cx
2073.\" .Cw
2074.\" .De
2075.\" .Pp
2076.\" This example shows the same equation in a different format.
2077.\" The spaces
2078.\" around the
2079.\" .Li \&+
2080.\" signs were forced with
31a6818e 2081.\" .Li \e :
fea681da
MK
2082.\" .Pp
2083.\" .Ds I
2084.\" .Cw (ax\ +\ bx\ +\ c) \ is\ produced\ by\ \&
2085.\" .\".Cw (ax+bx+c) \&.Va_by_) \&_and_\& \&[?/]m_b1_e1_f1[?/]\&
2086.\" .Cl Cx \t\t
2087.\" .Li \&.Cx\ (
2088.\" .Cx
2089.\" .Cl Cx \t\t
2090.\" .Li \&.Va a
2091.\" .Cx
2092.\" .Cl Cx \t\t
2093.\" .Li \&.Sy x
2094.\" .Cx
2095.\" .Cl Cx \t\t
31a6818e 2096.\" .Li \&.Cx \e\ +\e\ \e&
fea681da
MK
2097.\" .Cx
2098.\" .Cl Cx \&(\&
2099.\" .Va a
2100.\" .Sy x
2101.\" .Cx \ +\ \&
2102.\" .Va b
2103.\" .Sy y
2104.\" .Cx \ +\ \&
2105.\" .Va c )
2106.\" .Cx \t
2107.\" .Em is produced by
2108.\" .Cl Cx \t\t
2109.\" .Li \&.Va b
2110.\" .Cx
2111.\" .Cl Cx \t\t
2112.\" .Li \&.Sy y
2113.\" .Cx
2114.\" .Cl Cx \t\t
31a6818e 2115.\" .Li \&.Cx \e\ +\e\ \e&
fea681da
MK
2116.\" .Cx
2117.\" .Cl Cx \t\t
2118.\" .Li \&.Va c )
2119.\" .Cx
2120.\" .Cl Cx \t\t
2121.\" .Li \&.Cx
2122.\" .Cx
2123.\" .Cw
2124.\" .De
2125.\" .Pp
2126.\" The incantation below was
2127.\" lifted from the
2128.\" .Xr adb 1
2129.\" manual page:
2130.\" .Pp
2131.\" .Ds I
2132.\" .Cw \&[?/]m_b1_e1_f1[?/]\& is\ produced\ by
2133.\" .Cl Cx \t\t
2134.\" .Li \&.Cx Op Sy ?/
2135.\" .Cx
2136.\" .Cl Cx \t\t
2137.\" .Li \&.Nm m
2138.\" .Cx
2139.\" .Cl Cx Op Sy ?/
2140.\" .Nm m
2141.\" .Ad \ b1 e1 f1
2142.\" .Op Sy ?/
2143.\" .Cx \t
2144.\" .Em is produced by
2145.\" .Cx \t
31a6818e 2146.\" .Li \&.Ar \e\ b1 e1 f1
fea681da
MK
2147.\" .Cx
2148.\" .Cl Cx \t\t
2149.\" .Li \&.Op Sy ?/
2150.\" .Cx
2151.\" .Cl Cx \t\t
2152.\" .Li \&.Cx
2153.\" .Cx
2154.\" .Cw
2155.\" .De
2156.\" .Pp
2157.Ss Keeps
2158The only keep that is implemented at this time is for words.
2159The macros are
2160.Ql \&.Bk
2161(begin-keep)
2162and
2163.Ql \&.Ek
2164(end-keep).
2165The only option that
2166.Ql \&.Bk
2167accepts is
2168.Fl words
2169and is useful for preventing line breaks in the middle of options.
76c44d83 2170In the example for the make command-line arguments (see
fea681da
MK
2171.Sx What's in a name ) ,
2172the keep prevented
2173.Xr nroff
2174from placing up the
2175flag and the argument
2176on separate lines.
2177(Actually, the option macro used to prevent this from occurring,
2178but was dropped when the decision (religious) was made to force
2179right justified margins in
2180.Xr troff
2181as options in general look atrocious when spread across a sparse
2182line.
2183More work needs to be done with the keep macros, a
2184.Fl line
2185option needs to be added.)
2186.Ss Examples and Displays
2187There are five types of displays, a quickie one line indented display
2188.Ql \&.D1 ,
2189a quickie one line literal display
2190.Ql \&.Dl ,
2191and a block literal, block filled and block ragged which use
2192the
2193.Ql \&.Bd
2194begin-display
2195and
2196.Ql \&.Ed
2197end-display macros.
2198.Pp
2199.Bl -tag -width \&.Dlxx
2200.It Li \&.D1
2201(D-one) Display one line of indented text.
2202This macro is parsed, but it is not callable.
2203.Pp
2204.Dl Fl ldghfstru
2205.Pp
2206The above was produced by:
2207.Li \&.Dl Fl ldghfstru .
2208.It Li \&.Dl
2209(D-ell)
2210Display one line of indented
2211.Em literal
2212text.
2213The
2214.Ql \&.Dl
2215example macro has been used throughout this
2216file.
2217It allows
2218the indent (display) of one line of text.
2219Its default font is set to
2220constant width (literal) however
2221it is parsed and will recognized other macros.
2222It is not callable however.
2223.Pp
2224.Dl % ls -ldg /usr/local/bin
2225.Pp
2226The above was produced by
2227.Li \&.Dl % ls -ldg /usr/local/bin .
2228.It Li \&.Bd
2229Begin-display.
2230The
2231.Ql \&.Bd
2232display must be ended with the
2233.Ql \&.Ed
2234macro.
2235Displays may be nested within displays and
2236lists.
2237.Ql \&.Bd
2238has the following syntax:
2239.Pp
2240.Dl ".Bd display-type [-offset offset_value] [-compact]"
2241.Pp
2242The display-type must be one of the following four types and
2243may have an offset specifier for indentation:
2244.Ql \&.Bd .
15a12343 2245.El
fea681da
MK
2246.Pp
2247.Bl -tag -width "file file_name " -compact
2248.It Fl ragged
2249Display a block of text as typed,
2250right (and left) margin edges are left ragged.
2251.It Fl filled
2252Display a filled (formatted) block.
2253The block of text is formatted (the edges are filled \-
2254not left unjustified).
2255.It Fl literal
2256Display a literal block, useful for source code or
2257simple tabbed or spaced text.
2258.It Fl file Ar file_name
ef50679c 2259The filename following the
fea681da
MK
2260.Fl file
2261flag is read and displayed.
2262Literal mode is
2263asserted and tabs are set at 8 constant width character
2264intervals, however any
2265.Xr troff/ Ns Nm \-mdoc
2266commands in file will be processed.
2267.It Fl offset Ar string
2268If
2269.Fl offset
2270is specified with one of the following strings, the string
2271is interpreted to indicate the level of indentation for the
2272forthcoming block of text:
2273.Pp
2274.Bl -tag -width "indent-two" -compact
2275.It Ar left
2276Align block on the current left margin,
2277this is the default mode of
2278.Ql \&.Bd .
2279.It Ar center
2280Supposedly center the block.
2281At this time
2282unfortunately, the block merely gets
2283left aligned about an imaginary center margin.
2284.It Ar indent
2285Indents by one default indent value or tab.
2286The default
2287indent value is also used for the
2288.Ql \&.D1
2289display so one is guaranteed the two types of displays
2290will line up.
2291This indent is normally set to 6n or about two
2292thirds of an inch (six constant width characters).
2293.It Ar indent-two
2294Indents two times the default indent value.
2295.It Ar right
2296This
2297.Em left
2298aligns the block about two inches from
2299the right side of the page.
2300This macro needs
2301work and perhaps may never do the right thing by
2302.Xr troff .
2303.El
fea681da
MK
2304.It ".Ed"
2305End-display.
2306.El
2307.Ss Font Modes
2308There are five macros for changing the appearance of the manual page text:
2309.Bl -tag -width \&.Emxx
2310.It \&.Em
2311Text may be stressed or emphasized with the
2312.Ql \&.Em
2313macro.
2314The usual font for emphasis is italic.
2315.Pp
2316.Dl Usage: .Em argument ... \*(Pu
15a12343 2317.Bl -tag -width "\&.Em vide infra ) ) ," -compact -offset 14n
fea681da
MK
2318.It Li ".Em does not"
2319.Em does not
2320.It Li ".Em exceed 1024 ."
2321.Em exceed 1024 .
2322.It Li ".Em vide infra ) ) ,"
2323.Em vide infra ) ) ,
2324.El
2325.Pp
2326The
2327.Ql \&.Em
2328macro is parsed and is callable.
2329It is an error to call
2330.Ql \&.Em
2331without arguments.
2332.It \&.Li
2333The
2334.Ql \&.Li
2335literal macro may be used for special characters,
2336variable constants, anything which should be displayed as it
2337would be typed.
2338.Pp
2339.Dl Usage: .Li argument ... \*(Pu
15a12343 2340.Bl -tag -width "\&.Li cntrl-D ) ," -compact -offset 14n
31a6818e
MK
2341.It Li \&.Li \een
2342.Li \en
fea681da
MK
2343.It Li \&.Li M1 M2 M3\ ;
2344.Li M1 M2 M3 ;
2345.It Li \&.Li cntrl-D\ )\ ,
2346.Li cntrl-D ) ,
2347.It Li \&.Li 1024\ ...
2348.Li 1024 ...
2349.El
2350.Pp
2351The
2352.Ql \&.Li
2353macro is parsed and is callable.
2354.It \&.Sy
2355The symbolic emphasis macro is generally a boldface macro in
2356either the symbolic sense or the traditional English usage.
2357.Pp
2358.Dl Usage: .Sy symbol ... \*(Pu
15a12343 2359.Bl -tag -width "\&.Sy Important Noticex" -compact -offset 14n
fea681da
MK
2360.It Li \&.Sy Important Notice
2361.Sy Important Notice
fea681da
MK
2362.Pp
2363The
2364.Ql \&.Sy
2365macro is parsed and is callable.
2366Arguments to
2367.Ql \&.Sy
2368may be quoted.
15a12343 2369.El
fea681da
MK
2370.It Li \&.Bf
2371Begin font mode.
2372The
2373.Ql \&.Bf
2374font mode must be ended with the
2375.Ql \&.Ef
2376macro.
2377Font modes may be nested within other font modes.
2378.Ql \&.Bf
2379has the following syntax:
2380.Pp
2381.Dl ".Bf font-mode"
2382.Pp
2383The font-mode must be one of the following three types:
2384.Ql \&.Bf .
2385.Pp
2386.Bl -tag -width "file file_name " -compact
2387.It Sy \&Em | Fl emphasis
c13182ef 2388Same as if the
fea681da
MK
2389.Ql \&.Em
2390macro was used for the entire block of text.
2391.It Sy \&Li | Fl literal
2392Same as if the
2393.Ql \&.Li
2394macro was used for the entire block of text.
2395.It Sy \&Sy | Fl symbolic
2396Same as if the
2397.Ql \&.Sy
2398macro was used for the entire block of text.
2399.El
2400.It ".Ef"
2401End font mode.
2402.El
2403.Ss Tagged Lists and Columns
2404There are several types of lists which may be initiated with the
2405.Ql ".Bl"
2406begin-list macro.
2407Items within the list
2408are specified with the
2409.Ql ".It"
2410item macro and
2411each list must end with the
2412.Ql ".El"
2413macro.
2414Lists may be nested within themselves and within displays.
2415Columns may be used inside of lists, but lists are unproven
2416inside of columns.
2417.Pp
2418In addition, several list attributes may be specified such as
2419the width of a tag, the list offset, and compactness
2420(blank lines between items allowed or disallowed).
2421Most of this document has been formatted with a tag style list
2422.Pq Fl tag .
2423For a change of pace, the list-type used to present the list-types
2424is an over-hanging list
2425.Pq Fl ohang .
2426This type of list is quite popular with
2427.Tn TeX
2428users, but might look a bit funny after having read many pages of
2429tagged lists.
2430The following list types are accepted by
2431.Ql ".Bl" :
2432.Pp
2433.Bl -ohang -compact
2434.It Fl bullet
2435.It Fl item
2436.It Fl enum
2437These three are the simplest types of lists.
2438Once the
2439.Ql ".Bl"
2440macro has been given, items in the list are merely
2441indicated by a line consisting solely of the
2442.Ql ".It"
2443macro.
2444For example, the source text for a simple enumerated list
2445would look like:
2446.Bd -literal -offset indent-two
2447\&.Bl -enum -compact
2448\&.It
2449\&Item one goes here.
2450\&.It
2451\&And item two here.
2452\&.It
2453\&Lastly item three goes here.
2454\&.El
2455.Ed
15a12343 2456.El
fea681da
MK
2457.Pp
2458The results:
2459.Pp
2460.Bl -enum -offset indent-two -compact
2461.It
2462Item one goes here.
2463.It
2464And item two here.
2465.It
2466Lastly item three goes here.
2467.El
2468.Pp
2469A simple bullet list construction:
2470.Bd -literal -offset indent-two
2471\&.Bl -bullet -compact
2472\&.It
2473\&Bullet one goes here.
2474\&.It
2475\&Bullet two here.
2476\&.El
2477.Ed
2478.Pp
2479Produces:
2480.Bl -bullet -offset indent-two -compact
2481.It
2482Bullet one goes here.
2483.It
2484Bullet two here.
2485.El
2486.Pp
15a12343 2487.Bl -ohang -compact
fea681da
MK
2488.It Fl tag
2489.It Fl diag
2490.It Fl hang
2491.It Fl ohang
2492.It Fl inset
2493These list-types collect arguments specified with the
2494.Ql \&.It
2495macro and create a label which may be
2496.Em inset
2497into the forthcoming text,
2498.Em hanged
2499from the forthcoming text,
2500.Em overhanged
2501from above and not indented or
2502.Em tagged .
2503This
2504list was constructed with the
15a12343 2505.Ql \&Fl ohang
fea681da
MK
2506list-type.
2507The
2508.Ql \&.It
2509macro is parsed only for the inset, hang
2510and tag list-types and is not callable.
2511Here is an example of inset labels:
15a12343 2512.El
fea681da
MK
2513.Bl -inset -offset indent
2514.It Em Tag
2515The tagged list (also called a tagged paragraph) is the
2516most common type of list used in the Berkeley manuals.
2517.It Em Diag
2518Diag lists create section four diagnostic lists
2519and are similar to inset lists except callable
2520macros are ignored.
2521.It Em Hang
2522Hanged labels are a matter of taste.
2523.It Em Ohang
2524Overhanging labels are nice when space is constrained.
2525.It Em Inset
2526Inset labels are useful for controlling blocks of
2527paragraphs and are valuable for converting
2528.Nm \-mdoc
2529manuals to other formats.
2530.El
2531.Pp
2532Here is the source text which produced the above example:
2533.Bd -literal -offset indent
2534\&.Bl -inset -offset indent
2535\&.It Em Tag
2536\&The tagged list (also called a tagged paragraph) is the
2537\&most common type of list used in the Berkeley manuals.
2538\&.It Em Diag
2539\&Diag lists create section four diagnostic lists
2540\&and are similar to inset lists except callable
2541\&macros are ignored.
2542\&.It Em Hang
2543\&Hanged labels are a matter of taste.
2544\&.It Em Ohang
2545\&Overhanging labels are nice when space is constrained.
2546\&.It Em Inset
2547\&Inset labels are useful for controlling blocks of
2548\&paragraphs and are valuable for converting
2549\&.Nm \-mdoc
2550\&manuals to other formats.
2551\&.El
2552.Ed
2553.Pp
2554Here is a hanged list with two items:
2555.Bl -hang -offset indent
2556.It Em Hanged
2557labels appear similar to tagged lists when the
2558label is smaller than the label width.
2559.It Em Longer hanged list labels
2560blend in to the paragraph unlike
2561tagged paragraph labels.
2562.El
2563.Pp
2564And the unformatted text which created it:
2565.Bd -literal -offset indent
2566\&.Bl -hang -offset indent
2567\&.It Em Hanged
2568\&labels appear similar to tagged lists when the
2569\&label is smaller than the label width.
2570\&.It Em Longer hanged list labels
2571\&blend in to the paragraph unlike
2572\&tagged paragraph labels.
2573\&.El
2574.Ed
2575.Pp
2576The tagged list which follows uses an optional width specifier to control
2577the width of the tag.
2578.Pp
2579.Bl -tag -width "PAGEIN" -compact -offset indent
2580.It SL
2581sleep time of the process (seconds blocked)
2582.It PAGEIN
2583number of disk
2584.Tn I/O Ns 's
2585resulting from references
2586by the process to pages not loaded in core.
2587.It UID
2588numerical user-id of process owner
2589.It PPID
357cf3fe 2590numerical ID of parent of process process priority
24b74457 2591(nonpositive when in noninterruptible wait)
fea681da
MK
2592.El
2593.Pp
2594The raw text:
2595.Bd -literal -offset indent
2596\&.Bl -tag -width "PAGEIN" -compact -offset indent
2597\&.It SL
2598\&sleep time of the process (seconds blocked)
2599\&.It PAGEIN
2600\&number of disk
2601\&.Tn I/O Ns 's
2602\&resulting from references
2603\&by the process to pages not loaded in core.
2604\&.It UID
357cf3fe 2605\&numerical user ID of process owner
fea681da 2606\&.It PPID
357cf3fe 2607\&numerical ID of parent of process process priority
24b74457 2608\&(nonpositive when in noninterruptible wait)
fea681da
MK
2609\&.El
2610.Ed
2611.Pp
2612Acceptable width specifiers:
2613.Bl -tag -width Ar -offset indent
2614.It Fl width Ar "\&Fl"
2615sets the width to the default width for a flag.
2616All callable
2617macros have a default width value.
2618The
2619.Ql \&.Fl ,
2620value is presently
2621set to ten constant width characters or about five sixth of
2622an inch.
2623.It Fl width Ar "24n"
2624sets the width to 24 constant width characters or about two
2625inches.
2626The
2627.Ql n
2628is absolutely necessary for the scaling to work correctly.
2629.It Fl width Ar "ENAMETOOLONG"
2630sets width to the constant width length of the
2631string given.
2632.It Fl width Ar "\\*qint mkfifo\\*q"
2633again, the width is set to the constant width of the string
2634given.
2635.El
2636.Pp
2637If a width is not specified for the tag list type, the first
2638time
2639.Ql \&.It
2640is invoked, an attempt is made to determine an appropriate
2641width.
2642If the first argument to
2643.Ql ".It"
2644is a callable macro, the default width for that macro will be used
2645as if the macro name had been supplied as the width.
2646However,
2647if another item in the list is given with a different callable
2648macro name, a new and nested list is assumed.
2649.Sh PREDEFINED STRINGS
2650The following strings are predefined as may be used by
2651preceding with the troff string interpreting sequence
31a6818e 2652.Ql \&\e*(xx
fea681da
MK
2653where
2654.Em xx
2655is the name of the defined string or as
31a6818e 2656.Ql \&\e*x
fea681da
MK
2657where
2658.Em x
2659is the name of the string.
2660The interpreting sequence may be used any where in the text.
2661.Pp
2662.Bl -column "String " "Nroff " "Troff " -offset indent
2663.It Sy "String Nroff Troff"
2664.It Li "<=" Ta \&<\&= Ta \*(<=
2665.It Li ">=" Ta \&>\&= Ta \*(>=
2666.It Li "Rq" Ta "''" Ta \*(Rq
2667.It Li "Lq" Ta "``" Ta \*(Lq
2668.It Li "ua" Ta ^ Ta \*(ua
2669.It Li "aa" Ta ' Ta \*(aa
2670.It Li "ga" Ta \` Ta \*(ga
2671.\" .It Li "sL" Ta ` Ta \*(sL
2672.\" .It Li "sR" Ta ' Ta \*(sR
2673.It Li "q" Ta \&" Ta \*q
2674.It Li "Pi" Ta pi Ta \*(Pi
2675.It Li "Ne" Ta != Ta \*(Ne
2676.It Li "Le" Ta <= Ta \*(Le
2677.It Li "Ge" Ta >= Ta \*(Ge
2678.It Li "Lt" Ta < Ta \*(Gt
2679.It Li "Gt" Ta > Ta \*(Lt
2680.It Li "Pm" Ta +- Ta \*(Pm
2681.It Li "If" Ta infinity Ta \*(If
2682.It Li "Na" Ta \fINaN\fP Ta \*(Na
2683.It Li "Ba" Ta \fR\&|\fP Ta \*(Ba
2684.El
2685.Pp
2686.Sy Note :
2687The string named
2688.Ql q
2689should be written as
31a6818e 2690.Ql \e*q
fea681da
MK
2691since it is only one char.
2692.Sh DIAGNOSTICS
2693The debugging facilities for
2694.Nm \-mdoc
2695are limited, but can help detect subtle errors such
2696as the collision of an argument name with an internal
2697register or macro name.
2698(A what?)
2699A register is an arithmetic storage class for
2700.Xr troff
2701with a one or two character name.
2702All registers internal to
2703.Nm \-mdoc
2704for
2705.Xr troff
2706and
2707.Xr ditroff
2708are two characters and
2709of the form <upper_case><lower_case> such as
2710.Ql \&Ar ,
2711<lower_case><upper_case> as
2712.Ql \&aR
2713or
2714<upper or lower letter><digit> as
2715.Ql \&C\&1 .
2716And adding to the muddle,
2717.Xr troff
2718has its own internal registers all of which are either
efaef3da 2719two lowercase characters or a dot plus a letter or metacharacter
fea681da
MK
2720character.
2721In one of the introduction examples, it was shown how to
2722prevent the interpretation of a macro name with the escape sequence
31a6818e 2723.Ql \e& .
fea681da
MK
2724This is sufficient for the internal register names also.
2725.Pp
2726.\" Every callable macro name has a corresponding register
2727.\" of the same name (<upper_case><lower_case>).
2728.\" There are also specific registers which have
2729.\" been used for stacks and arrays and are listed in the
2730.\" .Sx Appendix .
2731.\" .Bd -ragged -offset 4n
2732.\" [A-Z][a-z] registers corresponding to macro names (example ``Ar'')
2733.\" [a-z][A-Z] registers corresponding to macro names (example ``aR'')
2734.\" C[0-9] argument types (example C1)
2735.\" O[0-9] offset stack (displays)
2736.\" h[0-9] horizontal spacing stack (lists)
2737.\" o[0-9] offset (stack) (lists)
2738.\" t[0-9] tag stack (lists)
2739.\" v[0-9] vertical spacing stack (lists)
2740.\" w[0-9] width tag/label stack
2741.\" .Ed
2742.\" .Pp
075972df 2743If a nonescaped register name is given in the argument list of a request,
fea681da
MK
2744unpredictable behavior will occur.
2745In general, any time huge portions
2746of text do not appear where expected in the output, or small strings
2747such as list tags disappear, chances are there is a misunderstanding
2748about an argument type in the argument list.
2749Your mother never intended for you to remember this evil stuff - so here
2750is a way to find out whether or not your arguments are valid: The
2751.Ql \&.Db
2752(debug)
2753macro displays the interpretation of the argument list for most
2754macros.
2755Macros such as the
2756.Ql \&.Pp
2757(paragraph)
2758macro do not contain debugging information.
2759All of the callable macros do,
2760and it is strongly advised whenever in doubt,
2761turn on the
2762.Ql \&.Db
2763macro.
2764.Pp
2765.Dl Usage: \&.Db [on | off]
2766.Pp
2767An example of a portion of text with
2768the debug macro placed above and below an
2769artificially created problem (a flag argument
2770.Ql \&aC
2771which should be
31a6818e 2772.Ql \e&aC
fea681da
MK
2773in order to work):
2774.Bd -literal -offset indent
2775\&.Db on
2776\&.Op Fl aC Ar file )
2777\&.Db off
2778.Ed
2779.Pp
2780The resulting output:
2781.Bd -literal -offset indent
2782DEBUGGING ON
2783DEBUG(argv) MACRO: `.Op' Line #: 2
2784 Argc: 1 Argv: `Fl' Length: 2
2785 Space: `' Class: Executable
2786 Argc: 2 Argv: `aC' Length: 2
2787 Space: `' Class: Executable
2788 Argc: 3 Argv: `Ar' Length: 2
2789 Space: `' Class: Executable
2790 Argc: 4 Argv: `file' Length: 4
2791 Space: ` ' Class: String
2792 Argc: 5 Argv: `)' Length: 1
2793 Space: ` ' Class: Closing Punctuation or suffix
2794 MACRO REQUEST: .Op Fl aC Ar file )
2795DEBUGGING OFF
2796.Ed
2797.Pp
2798The first line of information tells the name of the calling
2799macro, here
2800.Ql \&.Op ,
2801and the line number it appears on.
2802If one or more files are involved
075972df 2803(especially if text from another file is included), the line number
fea681da
MK
2804may be bogus.
2805If there is only one file, it should be accurate.
2806The second line gives the argument count, the argument
2807.Pq Ql \&Fl
2808and its length.
2809If the length of an argument is two characters, the
2810argument is tested to see if it is executable (unfortunately, any
c7094399 2811register which contains a nonzero value appears executable).
fea681da
MK
2812The third line gives the space allotted for a class, and the
2813class type.
2814The problem here is the argument aC should not be
2815executable.
2816The four types of classes are string, executable, closing
2817punctuation and opening punctuation.
2818The last line shows the entire
2819argument list as it was read.
2820In this next example, the offending
2821.Ql \&aC
2822is escaped:
2823.Bd -literal -offset indent
2824\&.Db on
31a6818e 2825\&.Em An escaped \e&aC
fea681da
MK
2826\&.Db off
2827.Ed
2828.Bd -literal -offset indent
2829DEBUGGING ON
2830DEBUG(fargv) MACRO: `.Em' Line #: 2
2831 Argc: 1 Argv: `An' Length: 2
2832 Space: ` ' Class: String
2833 Argc: 2 Argv: `escaped' Length: 7
2834 Space: ` ' Class: String
2835 Argc: 3 Argv: `aC' Length: 2
2836 Space: ` ' Class: String
2837 MACRO REQUEST: .Em An escaped &aC
2838DEBUGGING OFF
2839.Ed
2840.Pp
2841The argument
31a6818e 2842.Ql \e&aC
fea681da 2843shows up with the same length of 2 as the
31a6818e 2844.Ql \e&
fea681da
MK
2845sequence produces a zero width, but a register
2846named
31a6818e 2847.Ql \e&aC
fea681da
MK
2848was not found and the type classified as string.
2849.Pp
2850Other diagnostics consist of usage statements and are self explanatory.
2851.Sh GROFF, TROFF AND NROFF
2852The
2853.Nm \-mdoc
2854package does not need compatibility mode with
2855.Xr groff .
2856.Pp
2857The package inhibits page breaks, and the headers and footers
2858which normally occur at those breaks with
2859.Xr nroff ,
2860to make the manual more efficient for viewing on-line.
2861At the moment,
2862.Xr groff
2863with
2864.Fl T Ns Ar ascii
2865does eject the imaginary remainder of the page at end of file.
2866The inhibiting of the page breaks makes
2867.Xr nroff Ns 'd
2868files unsuitable for hardcopy.
2869There is a register named
2870.Ql \&cR
2871which can be set to zero in the site dependent style file
2872.Pa /usr/src/share/tmac/doc-nroff
2873to restore the old style behavior.
2874.Sh FILES
2875.Bl -tag -width /usr/share/man0/template.doc -compact
add00eab 2876.It Pa /usr/share/tmac/doc.tmac
fea681da
MK
2877manual macro package
2878.It Pa /usr/share/misc/mdoc.template
2879template for writing a man page
2880.It Pa /usr/share/examples/mdoc/*
2881several example man pages
2882.El
fea681da
MK
2883.Sh BUGS
2884Undesirable hyphenation on the dash of a flag
2885argument is not yet resolved, and causes
2886occasional mishaps in the
2887.Sx DESCRIPTION
2888section.
2889(line break on the hyphen).
2890.Pp
2891Predefined strings are not declared in documentation.
2892.Pp
2893Section 3f has not been added to the header routines.
2894.Pp
2895.Ql \&.Nm
2896font should be changed in
2897.Sx NAME
2898section.
2899.Pp
2900.Ql \&.Fn
2901needs to have a check to prevent splitting up
2902if the line length is too short.
2903Occasionally it
2904separates the last parenthesis, and sometimes
2905looks ridiculous if a line is in fill mode.
2906.Pp
2907The method used to prevent header and footer page
2908breaks (other than the initial header and footer) when using
2909nroff occasionally places an unsightly partially filled line (blank)
2910at the would be bottom of the page.
2911.Pp
2912The list and display macros to not do any keeps
2913and certainly should be able to.
2914.\" Note what happens if the parameter list overlaps a newline
2915.\" boundary.
2916.\" to make sure a line boundary is crossed:
2917.\" .Bd -literal
31a6818e 2918.\" \&.Fn struct\e\ dictionarytable\e\ *dictionarylookup struct\e\ dictionarytable\e\ *tab[]
fea681da
MK
2919.\" .Ed
2920.\" .Pp
2921.\" produces, nudge nudge,
2922.\" .Fn struct\ dictionarytable\ *dictionarylookup char\ *h struct\ dictionarytable\ *tab[] ,
2923.\" .Fn struct\ dictionarytable\ *dictionarylookup char\ *h struct\ dictionarytable\ *tab[] ,
2924.\" nudge
2925.\" .Fn struct\ dictionarytable\ *dictionarylookup char\ *h struct\ dictionarytable\ *tab[] .
2926.\" .Pp
2927.\" If double quotes are used, for example:
2928.\" .Bd -literal
2929.\" \&.Fn \*qstruct dictionarytable *dictionarylookup\*q \*qchar *h\*q \*qstruct dictionarytable *tab[]\*q
2930.\" .Ed
2931.\" .Pp
2932.\" produces, nudge nudge,
2933.\" .Fn "struct dictionarytable *dictionarylookup" "char *h" "struct dictionarytable *tab[]" ,
2934.\" nudge
2935.\" .Fn "struct dictionarytable *dictionarylookup" "char *h" "struct dictionarytable *tab[]" ,
2936.\" nudge
2937.\" .Fn "struct dictionarytable *dictionarylookup" "char *h" "struct dictionarytable *tab[]" .
2938.\" .Pp
2939.\" Not a pretty sight...
2940.\" In a paragraph, a long parameter containing unpaddable spaces as
2941.\" in the former example will cause
2942.\" .Xr troff
2943.\" to break the line and spread
2944.\" the remaining words out.
2945.\" The latter example will adjust nicely to
2946.\" justified margins, but may break in between an argument and its
2947.\" declaration.
2948.\" In
2949.\" .Xr nroff
2950.\" the right margin adjustment is normally ragged and the problem is
2951.\" not as severe.
e37e3282
MK
2952.Sh SEE ALSO
2953.Xr man 1 ,
2954.Xr troff 1 ,
6026c417 2955.Xr groff_mdoc 7 ,
e37e3282 2956.Xr mdoc 7