1MDOC.SAMPLES(7) BSD Miscellaneous Information Manual MDOC.SAMPLES(7)
2
4 mdoc.samples — tutorial sampler for writing BSD manuals with -mdoc
5
7 man mdoc.samples
8
10 A tutorial sampler for writing BSD manual pages with the -mdoc macro
11 package, a content-based and domain-based formatting package for
12 troff(1). Its predecessor, the -man(7) package, addressed page layout
13 leaving the manipulation of fonts and other typesetting details to the
14 individual author. In -mdoc, page layout macros make up the page
15 structure domain which consists of macros for titles, section headers,
16 displays and lists. Essentially items which affect the physical position
17 of text on a formatted page. In addition to the page structure domain,
18 there are two more domains, the manual domain and the general text
19 domain. The general text domain is defined as macros which perform tasks
20 such as quoting or emphasizing pieces of text. The manual domain is
21 defined as macros that are a subset of the day to day informal language
22 used to describe commands, routines and related BSD files. Macros in the
23 manual domain handle command names, command line arguments and options,
24 function names, function parameters, pathnames, variables, cross refer‐
25 ences to other manual pages, and so on. These domain items have value
26 for both the author and the future user of the manual page. It is hoped
27 the consistency gained across the manual set will provide easier transla‐
28 tion to future documentation tools.
29
30 Throughout the UNIX manual pages, a manual entry is simply referred to as
31 a man page, regardless of actual length and without sexist intention.
32
34 Since a tutorial document is normally read when a person desires to use
35 the material immediately, the assumption has been made that the user of
36 this document may be impatient. The material presented in the remained
37 of this document is outlined as follows:
38
39 1. TROFF IDIOSYNCRASIES
40 Macro Usage.
41 Passing Space Characters in an Argument.
42 Trailing Blank Space Characters (a warning).
43 Escaping Special Characters.
44
45 2. THE ANATOMY OF A MAN PAGE
46 A manual page template.
47
48 3. TITLE MACROS.
49
50 4. INTRODUCTION OF MANUAL AND GENERAL TEXT DOMAINS.
51 What's in a name....
52 General Syntax.
53
54 5. MANUAL DOMAIN
55 Addresses.
56 Author name.
57 Arguments.
58 Configuration Declarations (section four only).
59 Command Modifier.
60 Defined Variables.
61 Errno's (Section two only).
62 Environment Variables.
63 Function Argument.
64 Function Declaration.
65 Flags.
66 Functions (library routines).
67 Function Types.
68 Interactive Commands.
69 Names.
70 Options.
71 Pathnames.
72 Variables.
73 Cross References.
74
75 6. GENERAL TEXT DOMAIN
76 AT&T Macro.
77 BSD Macro.
78 FreeBSD Macro.
79 UNIX Macro.
80 Enclosure/Quoting Macros
81 Angle Bracket Quote/Enclosure.
82 Bracket Quotes/Enclosure.
83 Double Quote macro/Enclosure.
84 Parenthesis Quote/Enclosure.
85 Single Quotes/Enclosure.
86 Prefix Macro.
87 No-Op or Normal Text Macro.
88 No Space Macro.
89 Section Cross References.
90 References and Citations.
91 Return Values (sections two and three only)
92 Trade Names (Acronyms and Type Names).
93 Extended Arguments.
94
95 7. PAGE STRUCTURE DOMAIN
96 Section Headers.
97 Paragraphs and Line Spacing.
98 Keeps.
99 Displays.
100 Font Modes (Emphasis, Literal, and Symbolic).
101 Lists and Columns.
102
103 8. PREDEFINED STRINGS
104
105 9. DIAGNOSTICS
106
107 10. FORMATTING WITH GROFF, TROFF AND NROFF
108
109 11. BUGS
110
112 The -mdoc package attempts to simplify the process of writing a man page.
113 Theoretically, one should not have to learn the dirty details of troff(1)
114 to use -mdoc; however, there are a few limitations which are unavoidable
115 and best gotten out of the way. And, too, be forewarned, this package is
116 not fast.
117
118 Macro Usage
119 As in troff(1), a macro is called by placing a ‘.’ (dot character) at the
120 beginning of a line followed by the two character name for the macro.
121 Arguments may follow the macro separated by spaces. It is the dot char‐
122 acter at the beginning of the line which causes troff(1) to interpret the
123 next two characters as a macro name. To place a ‘.’ (dot character) at
124 the beginning of a line in some context other than a macro invocation,
125 precede the ‘.’ (dot) with the ‘\&’ escape sequence. The ‘\&’ translates
126 literally to a zero width space, and is never displayed in the output.
127
128 In general, troff(1) macros accept up to nine arguments, any extra argu‐
129 ments are ignored. Most macros in -mdoc accept nine arguments and, in
130 limited cases, arguments may be continued or extended on the next line
131 (See Extensions). A few macros handle quoted arguments (see Passing
132 Space Characters in an Argument below).
133
134 Most of the -mdoc general text domain and manual domain macros are spe‐
135 cial in that their argument lists are parsed for callable macro names.
136 This means an argument on the argument list which matches a general text
137 or manual domain macro name and is determined to be callable will be exe‐
138 cuted or called when it is processed. In this case the argument,
139 although the name of a macro, is not preceded by a ‘.’ (dot). It is in
140 this manner that many macros are nested; for example the option macro,
141 ‘.Op’, may call the flag and argument macros, ‘Fl’ and ‘Ar’, to specify
142 an optional flag with an argument:
143
144 [-s bytes] is produced by .Op Fl s Ar bytes
145
146 To prevent a two character string from being interpreted as a macro name,
147 precede the string with the escape sequence ‘\&’:
148
149 [Fl s Ar bytes] is produced by .Op \&Fl s \&Ar bytes
150
151 Here the strings ‘Fl’ and ‘Ar’ are not interpreted as macros. Macros
152 whose argument lists are parsed for callable arguments are referred to as
153 parsed and macros which may be called from an argument list are referred
154 to as callable throughout this document and in the companion quick refer‐
155 ence manual mdoc(7). This is a technical faux pas as almost all of the
156 macros in -mdoc are parsed, but as it was cumbersome to constantly refer
157 to macros as being callable and being able to call other macros, the term
158 parsed has been used.
159
160 Passing Space Characters in an Argument
161 Sometimes it is desirable to give as one argument a string containing one
162 or more blank space characters. This may be necessary to defeat the nine
163 argument limit or to specify arguments to macros which expect particular
164 arrangement of items in the argument list. For example, the function
165 macro ‘.Fn’ expects the first argument to be the name of a function and
166 any remaining arguments to be function parameters. As ANSI C stipulates
167 the declaration of function parameters in the parenthesized parameter
168 list, each parameter is guaranteed to be at minimum a two word string.
169 For example, int foo.
170
171 There are two possible ways to pass an argument which contains an embed‐
172 ded space. Implementation note: Unfortunately, the most convenient way
173 of passing spaces in between quotes by reassigning individual arguments
174 before parsing was fairly expensive speed wise and space wise to imple‐
175 ment in all the macros for AT&T troff. It is not expensive for groff but
176 for the sake of portability, has been limited to the following macros
177 which need it the most:
178
179 Cd Configuration declaration (section 4 SYNOPSIS)
180 Bl Begin list (for the width specifier).
181 Em Emphasized text.
182 Fn Functions (sections two and four).
183 It List items.
184 Li Literal text.
185 Sy Symbolic text.
186 %B Book titles.
187 %J Journal names.
188 %O Optional notes for a reference.
189 %R Report title (in a reference).
190 %T Title of article in a book or journal.
191
192 One way of passing a string containing blank spaces is to use the hard or
193 unpaddable space character ‘\ ’, that is, a blank space preceded by the
194 escape character ‘\’. This method may be used with any macro but has the
195 side effect of interfering with the adjustment of text over the length of
196 a line. Troff sees the hard space as if it were any other printable
197 character and cannot split the string into blank or newline separated
198 pieces as one would expect. The method is useful for strings which are
199 not expected to overlap a line boundary. For example:
200
201 fetch(char *str) is created by ‘.Fn fetch char\ *str’
202
203 fetch(char *str) can also be created by ‘.Fn fetch "char *str"’
204
205 If the ‘\’ or quotes were omitted, ‘.Fn’ would see three arguments and
206 the result would be:
207
208 fetch(char, *str)
209
210 For an example of what happens when the parameter list overlaps a newline
211 boundary, see the BUGS section.
212
213 Trailing Blank Space Characters
214 Troff can be confused by blank space characters at the end of a line. It
215 is a wise preventive measure to globally remove all blank spaces from
216 <blank-space><end-of-line> character sequences. Should the need arise to
217 force a blank character at the end of a line, it may be forced with an
218 unpaddable space and the ‘\&’ escape character. For example,
219 ‘string\ \&’.
220
221 Escaping Special Characters
222 Special characters like the newline character ‘\n’, are handled by
223 replacing the ‘\’ with ‘\e’ (e.g. ‘\en’) to preserve the backslash.
224
226 The body of a man page is easily constructed from a basic template found
227 in the file /usr/share/misc/mdoc.template. Several example man pages can
228 also be found in /usr/share/examples/mdoc.
229
230 A manual page template
231 .\" The following requests are required for all man pages.
232 .Dd Month day, year
233 .Os OPERATING_SYSTEM [version/release]
234 .Dt DOCUMENT_TITLE [section number] [volume]
235 .Sh NAME
236 .Nm name
237 .Nd one line description of name
238 .Sh SYNOPSIS
239 .Sh DESCRIPTION
240 .\" The following requests should be uncommented and
241 .\" used where appropriate. This next request is
242 .\" for sections 2 and 3 function return values only.
243 .\" .Sh RETURN VALUES
244 .\" This next request is for sections 1, 6, 7 & 8 only
245 .\" .Sh ENVIRONMENT
246 .\" .Sh FILES
247 .\" .Sh EXAMPLES
248 .\" This next request is for sections 1, 6, 7 & 8 only
249 .\" (command return values (to shell) and
250 .\" fprintf/stderr type diagnostics)
251 .\" .Sh DIAGNOSTICS
252 .\" The next request is for sections 2 and 3 error
253 .\" and signal handling only.
254 .\" .Sh ERRORS
255 .\" .Sh SEE ALSO
256 .\" .Sh CONFORMING TO
257 .\" .Sh HISTORY
258 .\" .Sh AUTHORS
259 .\" .Sh BUGS
260
261 The first items in the template are the macros (.Dd, .Os, .Dt); the docu‐
262 ment date, the operating system the man page or subject source is devel‐
263 oped or modified for, and the man page title (in upper case) along with
264 the section of the manual the page belongs in. These macros identify the
265 page, and are discussed below in TITLE MACROS.
266
267 The remaining items in the template are section headers (.Sh); of which
268 NAME, SYNOPSIS and DESCRIPTION are mandatory. The headers are discussed
269 in PAGE STRUCTURE DOMAIN, after presentation of MANUAL DOMAIN. Several
270 content macros are used to demonstrate page layout macros; reading about
271 content macros before page layout macros is recommended.
272
274 The title macros are the first portion of the page structure domain, but
275 are presented first and separate for someone who wishes to start writing
276 a man page yesterday. Three header macros designate the document title
277 or manual page title, the operating system, and the date of authorship.
278 These macros are one called once at the very beginning of the document
279 and are used to construct the headers and footers only.
280
281 .Dt DOCUMENT_TITLE section# [volume]
282 The document title is the subject of the man page and must be in
283 CAPITALS due to troff limitations. The section number may be
284 1, ..., 8, and if it is specified, the volume title may be omit‐
285 ted. A volume title may be arbitrary or one of the following:
286
287 AMD UNIX Ancestral Manual Documents
288 SMM UNIX System Manager's Manual
289 URM UNIX Reference Manual
290 PRM UNIX Programmer's Manual
291
292 The default volume labeling is URM for sections 1, 6, and 7; SMM
293 for section 8; PRM for sections 2, 3, 4, and 5.
294
295 .Os operating_system release#
296 The name of the operating system should be the common acronym,
297 e.g. BSD or FreeBSD or ATT. The release should be the standard
298 release nomenclature for the system specified, e.g. 4.3,
299 4.3+Tahoe, V.3, V.4. Unrecognized arguments are displayed as
300 given in the page footer. For instance, a typical footer might
301 be:
302
303 .Os 4.3BSD
304
305 or
306 .Os FreeBSD 2.2
307
308 or for a locally produced set
309
310 .Os CS Department
311
312 The Berkeley default, ‘.Os’ without an argument, has been defined
313 as BSD in the site specific file /usr/share/tmac/mdoc/doc-common.
314 It really should default to LOCAL. Note, if the ‘.Os’ macro is
315 not present, the bottom left corner of the page will be ugly.
316
317 .Dd month day, year
318 The date should be written formally:
319
320 January 25, 1989
321
323 What's in a name...
324 The manual domain macro names are derived from the day to day informal
325 language used to describe commands, subroutines and related files.
326 Slightly different variations of this language are used to describe the
327 three different aspects of writing a man page. First, there is the
328 description of -mdoc macro request usage. Second is the description of a
329 UNIX command with -mdoc macros and third, the description of a command to
330 a user in the verbal sense; that is, discussion of a command in the text
331 of a man page.
332
333 In the first case, troff(1) macros are themselves a type of command; the
334 general syntax for a troff command is:
335
336 .Va argument1 argument2 ... argument9
337
338 The ‘.Va’ is a macro command or request, and anything following it is an
339 argument to be processed. In the second case, the description of a UNIX
340 command using the content macros is a bit more involved; a typical
341 SYNOPSIS command line might be displayed as:
342
343 filter [-flag] infile outfile
344
345 Here, filter is the command name and the bracketed string -flag is a flag
346 argument designated as optional by the option brackets. In -mdoc terms,
347 infile and outfile are called arguments. The macros which formatted the
348 above example:
349
350 .Nm filter
351 .Op Fl flag
352 .Ar infile outfile
353
354 In the third case, discussion of commands and command syntax includes
355 both examples above, but may add more detail. The arguments infile and
356 outfile from the example above might be referred to as operands or file
357 arguments. Some command line argument lists are quite long:
358
359 make [-eiknqrstv] [-D variable] [-d flags] [-f makefile]
360 [-I directory] [-j max_jobs] [variable=value] [target ...]
361
362 Here one might talk about the command make and qualify the argument
363 makefile, as an argument to the flag, -f, or discuss the optional file
364 operand target. In the verbal context, such detail can prevent confu‐
365 sion, however the -mdoc package does not have a macro for an argument to
366 a flag. Instead the ‘Ar’ argument macro is used for an operand or file
367 argument like target as well as an argument to a flag like variable. The
368 make command line was produced from:
369
370 .Nm make
371 .Op Fl eiknqrstv
372 .Op Fl D Ar variable
373 .Op Fl d Ar flags
374 .Op Fl f Ar makefile
375 .Op Fl I Ar directory
376 .Op Fl j Ar max_jobs
377 .Op Ar variable=value
378 .Bk -words
379 .Op Ar target ...
380 .Ek
381
382 The ‘.Bk’ and ‘.Ek’ macros are explained in Keeps.
383
384 General Syntax
385 The manual domain and general text domain macros share a similar syntax
386 with a few minor deviations: ‘.Ar’, ‘.Fl’, ‘.Nm’, and ‘.Pa’ differ only
387 when called without arguments; ‘.Fn’ and ‘.Xr’ impose an order on their
388 argument lists and the ‘.Op’ and ‘.Fn’ macros have nesting limitations.
389 All content macros are capable of recognizing and properly handling punc‐
390 tuation, provided each punctuation character is separated by a leading
391 space. If an request is given:
392
393 .Li sptr, ptr),
394
395 The result is:
396
397 sptr, ptr),
398
399 The punctuation is not recognized and all is output in the literal font.
400 If the punctuation is separated by a leading white space:
401
402 .Li sptr , ptr ) ,
403
404 The result is:
405
406 sptr, ptr),
407
408 The punctuation is now recognized and is output in the default font dis‐
409 tinguishing it from the strings in literal font.
410
411 To remove the special meaning from a punctuation character escape it with
412 ‘\&’. Troff is limited as a macro language, and has difficulty when pre‐
413 sented with a string containing a member of the mathematical, logical or
414 quotation set:
415
416 {+,-,/,*,%,<,>,<=,>=,=,==,&,`,',"}
417
418 The problem is that troff may assume it is supposed to actually perform
419 the operation or evaluation suggested by the characters. To prevent the
420 accidental evaluation of these characters, escape them with ‘\&’. Typi‐
421 cal syntax is shown in the first content macro displayed below, ‘.Ad’.
422
424 Address Macro
425 The address macro identifies an address construct of the form
426 addr1[,addr2[,addr3]].
427
428 Usage: .Ad address ...
429 .Ad addr1 addr1
430 .Ad addr1 . addr1.
431 .Ad addr1 , file2
432 addr1, file2
433 .Ad f1 , f2 , f3 :
434 f1, f2, f3:
435 .Ad addr ) ) ,
436 addr)),
437
438 It is an error to call ‘.Ad’ without arguments. ‘.Ad’ is callable by
439 other macros and is parsed.
440
441 Author Name
442 The ‘.An’ macro is used to specify the name of the author of the item
443 being documented, or the name of the author of the actual manual page.
444 Any remaining arguments after the name information are assumed to be
445 punctuation.
446
447 Usage: .An author_name
448 .An Joe Author
449 Joe Author
450 .An Joe Author ,
451 Joe Author,
452 .An Joe Author Aq nobody@FreeBSD.ORG
453 Joe Author <nobody@FreeBSD.ORG>
454 .An Joe Author ) ) ,
455 Joe Author)),
456
457 The ‘.An’ macro is parsed and is callable. It is an error to call ‘.An’
458 without any arguments.
459
460 Argument Macro
461 The ‘.Ar’ argument macro may be used whenever a command line argument is
462 referenced.
463
464 Usage: .Ar argument ...
465 .Ar file ...
466 .Ar file1 file1
467 .Ar file1 . file1.
468 .Ar file1 file2
469 file1 file2
470 .Ar f1 f2 f3 :
471 f1 f2 f3:
472 .Ar file ) ) ,
473 file)),
474
475 If ‘.Ar’ is called without arguments ‘file ...’ is assumed. The ‘.Ar’
476 macro is parsed and is callable.
477
478 Configuration Declaration (section four only)
479 The ‘.Cd’ macro is used to demonstrate a config(8) declaration for a
480 device interface in a section four manual. This macro accepts quoted
481 arguments (double quotes only).
482
483 device le0 at scode? produced by: ‘.Cd device le0 at scode?’.
484
485 Command Modifier
486 The command modifier is identical to the ‘.Fl’ (flag) command with the
487 exception the ‘.Cm’ macro does not assert a dash in front of every argu‐
488 ment. Traditionally flags are marked by the preceding dash, some com‐
489 mands or subsets of commands do not use them. Command modifiers may also
490 be specified in conjunction with interactive commands such as editor com‐
491 mands. See Flags.
492
493 Defined Variables
494 A variable which is defined in an include file is specified by the macro
495 ‘.Dv’.
496
497 Usage: .Dv defined_variable ...
498 .Dv MAXHOSTNAMELEN
499 MAXHOSTNAMELEN
500 .Dv TIOCGPGRP )
501 TIOCGPGRP)
502
503 It is an error to call ‘.Dv’ without arguments. ‘.Dv’ is parsed and is
504 callable.
505
506 Errno's (Section two only)
507 The ‘.Er’ errno macro specifies the error return value for section two
508 library routines. The second example below shows ‘.Er’ used with the
509 ‘.Bq’ general text domain macro, as it would be used in a section two
510 manual page.
511
512 Usage: .Er ERRNOTYPE ...
513 .Er ENOENT
514 ENOENT
515 .Er ENOENT ) ;
516 ENOENT);
517 .Bq Er ENOTDIR
518 [ENOTDIR]
519
520 It is an error to call ‘.Er’ without arguments. The ‘.Er’ macro is
521 parsed and is callable.
522
523 Environment Variables
524 The ‘.Ev’ macro specifies an environment variable.
525
526 Usage: .Ev argument ...
527 .Ev DISPLAY
528 DISPLAY
529 .Ev PATH . PATH.
530 .Ev PRINTER ) ) ,
531 PRINTER)),
532
533 It is an error to call ‘.Ev’ without arguments. The ‘.Ev’ macro is
534 parsed and is callable.
535
536 Function Argument
537 The ‘.Fa’ macro is used to refer to function arguments (parameters) out‐
538 side of the SYNOPSIS section of the manual or inside the SYNOPSIS section
539 should a parameter list be too long for the ‘.Fn’ macro and the enclosure
540 macros ‘.Fo’ and ‘.Fc’ must be used. ‘.Fa’ may also be used to refer to
541 structure members.
542
543 Usage: .Fa function_argument ...
544 .Fa d_namlen ) ) ,
545 d_namlen)),
546 .Fa iov_len iov_len
547
548 It is an error to call ‘.Fa’ without arguments. ‘.Fa’ is parsed and is
549 callable.
550
551 Function Declaration
552 The ‘.Fd’ macro is used in the SYNOPSIS section with section two or three
553 functions. The ‘.Fd’ macro does not call other macros and is not
554 callable by other macros.
555
556 Usage: .Fd include_file (or defined variable)
557
558 In the SYNOPSIS section a ‘.Fd’ request causes a line break if a function
559 has already been presented and a break has not occurred. This leaves a
560 nice vertical space in between the previous function call and the decla‐
561 ration for the next function.
562
563 Flags
564 The ‘.Fl’ macro handles command line flags. It prepends a dash, ‘-’, to
565 the flag. For interactive command flags, which are not prepended with a
566 dash, the ‘.Cm’ (command modifier) macro is identical, but without the
567 dash.
568
569 Usage: .Fl argument ...
570 .Fl -
571 .Fl cfv -cfv
572 .Fl cfv . -cfv.
573 .Fl s v t -s -v -t
574 .Fl - , --,
575 .Fl xyz ) , -xyz),
576
577 The ‘.Fl’ macro without any arguments results in a dash representing
578 stdin/stdout. Note that giving ‘.Fl’ a single dash, will result in two
579 dashes. The ‘.Fl’ macro is parsed and is callable.
580
581 Functions (library routines)
582 The .Fn macro is modeled on ANSI C conventions.
583
584 Usage: .Fn [type] function [[type] parameters ... ]
585 .Fn getchar getchar()
586 .Fn strlen ) , strlen()),
587 .Fn "int align" "const * char *sptrs", int align(const * char *sptrs),
588
589 It is an error to call ‘.Fn’ without any arguments. The ‘.Fn’ macro is
590 parsed and is callable, note that any call to another macro signals the
591 end of the ‘.Fn’ call (it will close-parenthesis at that point).
592
593 For functions that have more than eight parameters (and this is rare),
594 the macros ‘.Fo’ (function open) and ‘.Fc’ (function close) may be used
595 with ‘.Fa’ (function argument) to get around the limitation. For example:
596
597 .Fo "int res_mkquery"
598 .Fa "int op"
599 .Fa "char *dname"
600 .Fa "int class"
601 .Fa "int type"
602 .Fa "char *data"
603 .Fa "int datalen"
604 .Fa "struct rrec *newrr"
605 .Fa "char *buf"
606 .Fa "int buflen"
607 .Fc
608
609 Produces:
610
611 int res_mkquery(int op, char *dname, int class, int type,
612 char *data, int datalen, struct rrec *newrr, char *buf, int buflen)
613
614 The ‘.Fo’ and ‘.Fc’ macros are parsed and are callable. In the SYNOPSIS
615 section, the function will always begin at the beginning of line. If
616 there is more than one function presented in the SYNOPSIS section and a
617 function type has not been given, a line break will occur, leaving a nice
618 vertical space between the current function name and the one prior. At
619 the moment, ‘.Fn’ does not check its word boundaries against troff line
620 lengths and may split across a newline ungracefully. This will be fixed
621 in the near future.
622
623 Function Type
624 This macro is intended for the SYNOPSIS section. It may be used anywhere
625 else in the man page without problems, but its main purpose is to present
626 the function type in kernel normal form for the SYNOPSIS of sections two
627 and three (it causes a line break allowing the function name to appear on
628 the next line).
629
630 Usage: .Ft type ...
631 .Ft struct stat struct stat
632
633 The ‘.Ft’ request is not callable by other macros.
634
635 Interactive Commands
636 The ‘.Ic’ macro designates an interactive or internal command.
637
638 Usage: .Ic argument ...
639 .Ic :wq :wq
640 .Ic do while {...} do while {...}
641 .Ic setenv , unsetenv
642 setenv, unsetenv
643
644 It is an error to call ‘.Ic’ without arguments. The ‘.Ic’ macro is
645 parsed and is callable.
646
647 Name Macro
648 The ‘.Nm’ macro is used for the document title or subject name. It has
649 the peculiarity of remembering the first argument it was called with,
650 which should always be the subject name of the page. When called without
651 arguments, ‘.Nm’ regurgitates this initial name for the sole purpose of
652 making less work for the author. Note: a section two or three document
653 function name is addressed with the ‘.Nm’ in the NAME section, and with
654 ‘.Fn’ in the SYNOPSIS and remaining sections. For interactive commands,
655 such as the ‘while’ command keyword in csh(1), the ‘.Ic’ macro should be
656 used. While the ‘.Ic’ is nearly identical to ‘.Nm’, it can not recall
657 the first argument it was invoked with.
658
659 Usage: .Nm argument ...
660 .Nm mdoc.sample
661 mdoc.sample
662 .Nm \-mdoc -mdoc.
663 .Nm foo ) ) ,
664 foo)),
665 .Nm mdoc.samples
666
667 The ‘.Nm’ macro is parsed and is callable.
668
669 Options
670 The ‘.Op’ macro places option brackets around the any remaining arguments
671 on the command line, and places any trailing punctuation outside the
672 brackets. The macros ‘.Oc’ and ‘.Oo’ may be used across one or more
673 lines.
674
675 Usage: .Op options ...
676 .Op []
677 .Op Fl k [-k]
678 .Op Fl k ) . [-k]).
679 .Op Fl k Ar kookfile [-k kookfile]
680 .Op Fl k Ar kookfile ,
681 [-k kookfile],
682 .Op Ar objfil Op Ar corfil
683 [objfil [corfil]]
684 .Op Fl c Ar objfil Op Ar corfil ,
685 [-c objfil [corfil]],
686 .Op word1 word2 [word1 word2]
687
688 The ‘.Oc’ and ‘.Oo’ macros:
689
690 .Oo
691 .Op Fl k Ar kilobytes
692 .Op Fl i Ar interval
693 .Op Fl c Ar count
694 .Oc
695
696 Produce: [[-k kilobytes] [-i interval] [-c count]]
697
698 The macros ‘.Op’, ‘.Oc’ and ‘.Oo’ are parsed and are callable.
699
700 Pathnames
701 The ‘.Pa’ macro formats pathnames or filenames.
702
703 Usage: .Pa pathname
704 .Pa /usr/share /usr/share
705 .Pa /tmp/fooXXXXX ) .
706 /tmp/fooXXXXX).
707
708 The ‘.Pa’ macro is parsed and is callable.
709
710 Variables
711 Generic variable reference:
712
713 Usage: .Va variable ...
714 .Va count count
715 .Va settimer,
716 settimer,
717 .Va int *prt ) :
718 int *prt):
719 .Va char s ] ) ) ,
720 char s])),
721
722 It is an error to call ‘.Va’ without any arguments. The ‘.Va’ macro is
723 parsed and is callable.
724
725 Manual Page Cross References
726 The ‘.Xr’ macro expects the first argument to be a manual page name, and
727 the second argument, if it exists, to be either a section page number or
728 punctuation. Any remaining arguments are assumed to be punctuation.
729
730 Usage: .Xr man_page [1,...,8]
731 .Xr mdoc mdoc
732 .Xr mdoc , mdoc,
733 .Xr mdoc 7 mdoc(7)
734 .Xr mdoc 7 ) ) ,
735 mdoc(7))),
736
737 The ‘.Xr’ macro is parsed and is callable. It is an error to call ‘.Xr’
738 without any arguments.
739
741 AT&T Macro
742 Usage: .At [v6 | v7 | 32v | V.1 | V.4] ...
743 .At AT&T UNIX
744 .At v6 . Version 6 AT&T UNIX.
745
746 The ‘.At’ macro is not parsed and not callable. It accepts at most two
747 arguments.
748
749 BSD Macro
750 Usage: .Bx [Version/release] ...
751 .Bx BSD
752 .Bx 4.3 .
753 4.3BSD.
754
755 The ‘.Bx’ macro is parsed and is callable.
756
757 FreeBSD Macro
758 Usage: .Fx Version.release ...
759 .Fx 2.2 . FreeBSD 2.2.
760
761 The ‘.Fx’ macro is not parsed and not callable. It accepts at most two
762 arguments.
763
764 UNIX Macro
765 Usage: .Ux ...
766 .Ux UNIX
767
768 The ‘.Ux’ macro is parsed and is callable.
769
770 Enclosure and Quoting Macros
771 The concept of enclosure is similar to quoting. The object being to
772 enclose one or more strings between a pair of characters like quotes or
773 parentheses. The terms quoting and enclosure are used interchangeably
774 throughout this document. Most of the one line enclosure macros end in
775 small letter ‘q’ to give a hint of quoting, but there are a few irregu‐
776 larities. For each enclosure macro there is also a pair of open and
777 close macros which end in small letters ‘o’ and ‘c’ respectively. These
778 can be used across one or more lines of text and while they have nesting
779 limitations, the one line quote macros can be used inside of them.
780
781 Quote Close Open Function Result
782 .Aq .Ac .Ao Angle Bracket Enclosure <string>
783 .Bq .Bc .Bo Bracket Enclosure [string]
784 .Dq .Dc .Do Double Quote ``string''
785 .Ec .Eo Enclose String (in XX) XXstringXX
786 .Pq .Pc .Po Parenthesis Enclosure (string)
787 .Ql Quoted Literal `st' or string
788 .Qq .Qc .Qo Straight Double Quote "string"
789 .Sq .Sc .So Single Quote `string'
790
791 Except for the irregular macros noted below, all of the quoting macros
792 are parsed and callable. All handle punctuation properly, as long as it
793 is presented one character at a time and separated by spaces. The quot‐
794 ing macros examine opening and closing punctuation to determine whether
795 it comes before or after the enclosing string. This makes some nesting
796 possible.
797
798 .Ec, .Eo These macros expect the first argument to be the opening and
799 closing strings respectively.
800
801 .Ql The quoted literal macro behaves differently for troff than
802 nroff. If formatted with nroff, a quoted literal is always
803 quoted. If formatted with troff, an item is only quoted if the
804 width of the item is less than three constant width characters.
805 This is to make short strings more visible where the font
806 change to literal (constant width) is less noticeable.
807
808 .Pf The prefix macro is not callable, but it is parsed:
809
810 .Pf ( Fa name2
811 becomes (name2.
812
813 The ‘.Ns’ (no space) macro performs the analogous suffix func‐
814 tion.
815
816 Examples of quoting:
817 .Aq ⟨⟩
818 .Aq Ar ctype.h ) , ⟨ctype.h⟩),
819 .Bq []
820 .Bq Em Greek , French .
821 [Greek, French].
822 .Dq “”
823 .Dq string abc . “string abc”.
824 .Dq ´^[A-Z]´ “´^[A-Z]´”
825 .Ql man mdoc ‘man mdoc’
826 .Qq ""
827 .Qq string ) , "string"),
828 .Qq string Ns ), "string),"
829 .Sq ‘’
830 .Sq string ‘string’
831
832 For a good example of nested enclosure macros, see the ‘.Op’ option
833 macro. It was created from the same underlying enclosure macros as those
834 presented in the list above. The ‘.Xo’ and ‘.Xc’ extended argument list
835 macros were also built from the same underlying routines and are a good
836 example of -mdoc macro usage at its worst.
837
838 No-Op or Normal Text Macro
839 The macro ‘.No’ is a hack for words in a macro command line which should
840 not be formatted and follows the conventional syntax for content macros.
841
842 Space Macro
843 The ‘.Ns’ macro eliminates unwanted spaces in between macro requests. It
844 is useful for old style argument lists where there is no space between
845 the flag and argument:
846
847 .Op Fl I Ns Ar directory
848 produces [-Idirectory]
849
850 Note: the ‘.Ns’ macro always invokes the ‘.No’ macro after eliminating
851 the space unless another macro name follows it. The macro ‘.Ns’ is
852 parsed and is callable.
853
854 Section Cross References
855 The ‘.Sx’ macro designates a reference to a section header within the
856 same document. It is parsed and is callable.
857
858 .Sx FILES FILES
859
860 References and Citations
861 The following macros make a modest attempt to handle references. At
862 best, the macros make it convenient to manually drop in a subset of refer
863 style references.
864
865 .Rs Reference Start. Causes a line break and begins collection
866 of reference information until the reference end macro is
867 read.
868 .Re Reference End. The reference is printed.
869 .%A Reference author name, one name per invocation.
870 .%B Book title.
871 .%C City/place.
872 .%D Date.
873 .%J Journal name.
874 .%N Issue number.
875 .%O Optional information.
876 .%P Page number.
877 .%R Report name.
878 .%T Title of article.
879 .%V Volume(s).
880
881 The macros beginning with ‘%’ are not callable, and are parsed only for
882 the trade name macro which returns to its caller. (And not very pre‐
883 dictably at the moment either.) The purpose is to allow trade names to
884 be pretty printed in troff/ditroff output.
885
886 Return Values
887 The ‘.Rv’ macro generates text for use in the RETURN VALUES section.
888
889 Usage: .Rv [-std function]
890
891 ‘.Rv -std atexit’ will generate the following text:
892
893 The atexit() function returns the value 0 if successful; otherwise the
894 value -1 is returned and the global variable errno is set to indicate the
895 error.
896
897 The -std option is valid only for manual page sections 2 and 3.
898
899 Trade Names (or Acronyms and Type Names)
900 The trade name macro is generally a small caps macro for all upper case
901 words longer than two characters.
902
903 Usage: .Tn symbol ...
904 .Tn DEC
905 DEC
906 .Tn ASCII
907 ASCII
908
909 The ‘.Tn’ macro is parsed and is callable by other macros.
910
911 Extended Arguments
912 The ‘.Xo’ and ‘.Xc’ macros allow one to extend an argument list on a
913 macro boundary. Argument lists cannot be extended within a macro which
914 expects all of its arguments on one line such as ‘.Op’.
915
916 Here is an example of ‘.Xo’ using the space mode macro to turn spacing
917 off:
918
919 .Sm off
920 .It Xo Sy I Ar operation
921 .No \en Ar count No \en
922 .Xc
923 .Sm on
924
925 Produces
926
927 Ioperation\ncount\n
928
929 Another one:
930
931 .Sm off
932 .It Cm S No / Ar old_pattern Xo
933 .No / Ar new_pattern
934 .No / Op Cm g
935 .Xc
936 .Sm on
937
938 Produces
939
940 S/old_pattern/new_pattern/[g]
941
942 Another example of ‘.Xo’ and using enclosure macros: Test the value of an
943 variable.
944
945 .It Xo
946 .Ic .ifndef
947 .Oo \&! Oc Ns Ar variable
948 .Op Ar operator variable ...
949 .Xc
950
951 Produces
952
953 .ifndef [!]variable [operator variable ...]
954
955 All of the above examples have used the ‘.Xo’ macro on the argument list
956 of the ‘.It’ (list-item) macro. The extend macros are not used very
957 often, and when they are it is usually to extend the list-item argument
958 list. Unfortunately, this is also where the extend macros are the most
959 finicky. In the first two examples, spacing was turned off; in the
960 third, spacing was desired in part of the output but not all of it. To
961 make these macros work in this situation make sure the ‘.Xo’ and ‘.Xc’
962 macros are placed as shown in the third example. If the ‘.Xo’ macro is
963 not alone on the ‘.It’ argument list, spacing will be unpredictable. The
964 ‘.Ns’ (no space macro) must not occur as the first or last macro on a
965 line in this situation. Out of 900 manual pages (about 1500 actual
966 pages) currently released with BSD only fifteen use the ‘.Xo’ macro.
967
969 Section Headers
970 The first three ‘.Sh’ section header macros list below are required in
971 every man page. The remaining section headers are recommended at the
972 discretion of the author writing the manual page. The ‘.Sh’ macro can
973 take up to nine arguments. It is parsed and but is not callable.
974
975 .Sh NAME The ‘.Sh NAME’ macro is mandatory. If not specified, the head‐
976 ers, footers and page layout defaults will not be set and
977 things will be rather unpleasant. The NAME section consists of
978 at least three items. The first is the ‘.Nm’ name macro naming
979 the subject of the man page. The second is the Name Descrip‐
980 tion macro, ‘.Nd’, which separates the subject name from the
981 third item, which is the description. The description should
982 be the most terse and lucid possible, as the space available is
983 small.
984
985 .Sh SYNOPSIS
986 The SYNOPSIS section describes the typical usage of the subject
987 of a man page. The macros required are either ‘.Nm’, ‘.Cd’,
988 ‘.Fn’, (and possibly ‘.Fo’, ‘.Fc’, ‘.Fd’, ‘.Ft’ macros). The
989 function name macro ‘.Fn’ is required for manual page sections
990 2 and 3, the command and general name macro ‘.Nm’ is required
991 for sections 1, 5, 6, 7, 8. Section 4 manuals require a ‘.Nm’,
992 ‘.Fd’ or a ‘.Cd’ configuration device usage macro. Several
993 other macros may be necessary to produce the synopsis line as
994 shown below:
995
996 cat [-benstuv] [-] file ...
997
998 The following macros were used:
999
1000 .Nm cat
1001 .Op Fl benstuv
1002 .Op Fl
1003 .Ar
1004
1005 Note: The macros ‘.Op’, ‘.Fl’, and ‘.Ar’ recognize the pipe bar
1006 character ‘|’, so a command line such as:
1007
1008 .Op Fl a | Fl b
1009
1010 will not go orbital. Troff normally interprets a | as a spe‐
1011 cial operator. See PREDEFINED STRINGS for a usable | character
1012 in other situations.
1013
1014 .Sh DESCRIPTION
1015 In most cases the first text in the DESCRIPTION section is a
1016 brief paragraph on the command, function or file, followed by a
1017 lexical list of options and respective explanations. To create
1018 such a list, the ‘.Bl’ begin-list, ‘.It’ list-item and ‘.El’
1019 end-list macros are used (see Lists and Columns below).
1020
1021 The following ‘.Sh’ section headers are part of the preferred manual page
1022 layout and must be used appropriately to maintain consistency. They are
1023 listed in the order in which they would be used.
1024
1025 .Sh ENVIRONMENT
1026 The ENVIRONMENT section should reveal any related environment
1027 variables and clues to their behavior and/or usage.
1028
1029 .Sh EXAMPLES
1030 There are several ways to create examples. See the EXAMPLES
1031 section below for details.
1032
1033 .Sh FILES
1034 Files which are used or created by the man page subject should
1035 be listed via the ‘.Pa’ macro in the FILES section.
1036
1037 .Sh SEE ALSO
1038 References to other material on the man page topic and cross
1039 references to other relevant man pages should be placed in the
1040 SEE ALSO section. Cross references are specified using the
1041 ‘.Xr’ macro. Cross references in the SEE ALSO section should
1042 be sorted by section number, and then placed in alphabetical
1043 order and comma separated. For example:
1044
1045 ls(1), ps(1), group(5), passwd(5).
1046
1047 At this time refer(1) style references are not accommodated.
1048
1049 .Sh CONFORMING TO
1050 If the command, library function or file adheres to a specific
1051 implementation such as IEEE Std 1003.2 (“POSIX.2”) or ANSI
1052 X3.159-1989 (“ANSI C89”) this should be noted here. If the
1053 command does not adhere to any standard, its history should be
1054 noted in the HISTORY section.
1055
1056 .Sh HISTORY
1057 Any command which does not adhere to any specific standards
1058 should be outlined historically in this section.
1059
1060 .Sh AUTHORS
1061 Credits, if need be, should be placed here.
1062
1063 .Sh DIAGNOSTICS
1064 Diagnostics from a command should be placed in this section.
1065
1066 .Sh ERRORS
1067 Specific error handling, especially from library functions (man
1068 page sections 2 and 3) should go here. The ‘.Er’ macro is used
1069 to specify an errno.
1070
1071 .Sh BUGS Blatant problems with the topic go here...
1072
1073 User specified ‘.Sh’ sections may be added, for example, this section was
1074 set with:
1075
1076 .Sh PAGE STRUCTURE DOMAIN
1077
1078 Paragraphs and Line Spacing.
1079 .Pp The ‘.Pp’ paragraph command may be used to specify a line space
1080 where necessary. The macro is not necessary after a ‘.Sh’ or
1081 ‘.Ss’ macro or before a ‘.Bl’ macro. (The ‘.Bl’ macro asserts a
1082 vertical distance unless the -compact flag is given).
1083
1084 Keeps
1085 The only keep that is implemented at this time is for words. The macros
1086 are ‘.Bk’ (begin-keep) and ‘.Ek’ (end-keep). The only option that ‘.Bk’
1087 accepts is -words and is useful for preventing line breaks in the middle
1088 of options. In the example for the make command line arguments (see
1089 What's in a name), the keep prevented nroff from placing up the flag and
1090 the argument on separate lines. (Actually, the option macro used to pre‐
1091 vent this from occurring, but was dropped when the decision (religious)
1092 was made to force right justified margins in troff as options in general
1093 look atrocious when spread across a sparse line. More work needs to be
1094 done with the keep macros, a -line option needs to be added.)
1095
1096 Examples and Displays
1097 There are five types of displays, a quickie one line indented display
1098 ‘.D1’, a quickie one line literal display ‘.Dl’, and a block literal,
1099 block filled and block ragged which use the ‘.Bd’ begin-display and ‘.Ed’
1100 end-display macros.
1101
1102 .D1 (D-one) Display one line of indented text. This macro is parsed,
1103 but it is not callable.
1104
1105 -ldghfstru
1106
1107 The above was produced by: .Dl -ldghfstru.
1108
1109 .Dl (D-ell) Display one line of indented literal text. The ‘.Dl’
1110 example macro has been used throughout this file. It allows the
1111 indent (display) of one line of text. Its default font is set to
1112 constant width (literal) however it is parsed and will recognized
1113 other macros. It is not callable however.
1114
1115 % ls -ldg /usr/local/bin
1116
1117 The above was produced by .Dl % ls -ldg /usr/local/bin.
1118
1119 .Bd Begin-display. The ‘.Bd’ display must be ended with the ‘.Ed’
1120 macro. Displays may be nested within displays and lists. ‘.Bd’
1121 has the following syntax:
1122
1123 .Bd display-type [-offset offset_value] [-compact]
1124
1125 The display-type must be one of the following four types and may
1126 have an offset specifier for indentation: ‘.Bd’.
1127
1128 -ragged Display a block of text as typed, right (and
1129 left) margin edges are left ragged.
1130 -filled Display a filled (formatted) block. The block
1131 of text is formatted (the edges are filled - not
1132 left unjustified).
1133 -literal Display a literal block, useful for source code
1134 or simple tabbed or spaced text.
1135 -file file_name The filename following the -file flag is read
1136 and displayed. Literal mode is asserted and
1137 tabs are set at 8 constant width character
1138 intervals, however any troff/-mdoc commands in
1139 file will be processed.
1140 -offset string If -offset is specified with one of the follow‐
1141 ing strings, the string is interpreted to indi‐
1142 cate the level of indentation for the forthcom‐
1143 ing block of text:
1144
1145 left Align block on the current left mar‐
1146 gin, this is the default mode of
1147 ‘.Bd’.
1148 center Supposedly center the block. At
1149 this time unfortunately, the block
1150 merely gets left aligned about an
1151 imaginary center margin.
1152 indent Indents by one default indent value
1153 or tab. The default indent value is
1154 also used for the ‘.D1’ display so
1155 one is guaranteed the two types of
1156 displays will line up. This indent
1157 is normally set to 6n or about two
1158 thirds of an inch (six constant
1159 width characters).
1160 indent-two Indents two times the default indent
1161 value.
1162 right This left aligns the block about two
1163 inches from the right side of the
1164 page. This macro needs work and
1165 perhaps may never do the right thing
1166 by troff.
1167
1168 .Ed End-display.
1169
1170 Font Modes
1171 There are five macros for changing the appearance of the manual page
1172 text:
1173
1174 .Em Text may be stressed or emphasized with the ‘.Em’ macro. The
1175 usual font for emphasis is italic.
1176
1177 Usage: .Em argument ...
1178 .Em does not does not
1179 .Em exceed 1024 .
1180 exceed 1024.
1181 .Em vide infra ) ) ,
1182 vide infra)),
1183
1184 The ‘.Em’ macro is parsed and is callable. It is an error to call
1185 ‘.Em’ without arguments.
1186
1187 .Li The ‘.Li’ literal macro may be used for special characters, vari‐
1188 able constants, anything which should be displayed as it would be
1189 typed.
1190
1191 Usage: .Li argument ...
1192 .Li \en \n
1193 .Li M1 M2 M3 ;
1194 M1 M2 M3;
1195 .Li cntrl-D ) ,
1196 cntrl-D),
1197 .Li 1024 ...
1198 1024 ...
1199
1200 The ‘.Li’ macro is parsed and is callable.
1201
1202 .Sy The symbolic emphasis macro is generally a boldface macro in
1203 either the symbolic sense or the traditional English usage.
1204
1205 Usage: .Sy symbol ...
1206 .Sy Important Notice
1207 Important Notice
1208
1209 The ‘.Sy’ macro is parsed and is callable. Arguments to ‘.Sy’ may
1210 be quoted.
1211
1212 .Bf Begin font mode. The ‘.Bf’ font mode must be ended with the ‘.Ef’
1213 macro. Font modes may be nested within other font modes. ‘.Bf’
1214 has the following syntax:
1215
1216 .Bf font-mode
1217
1218 The font-mode must be one of the following three types: ‘.Bf’.
1219
1220 Em | -emphasis Same as if the ‘.Em’ macro was used for the
1221 entire block of text.
1222 Li | -literal Same as if the ‘.Li’ macro was used for the
1223 entire block of text.
1224 Sy | -symbolic Same as if the ‘.Sy’ macro was used for the
1225 entire block of text.
1226
1227 .Ef End font mode.
1228
1229 Tagged Lists and Columns
1230 There are several types of lists which may be initiated with the ‘.Bl’
1231 begin-list macro. Items within the list are specified with the ‘.It’
1232 item macro and each list must end with the ‘.El’ macro. Lists may be
1233 nested within themselves and within displays. Columns may be used inside
1234 of lists, but lists are unproven inside of columns.
1235
1236 In addition, several list attributes may be specified such as the width
1237 of a tag, the list offset, and compactness (blank lines between items
1238 allowed or disallowed). Most of this document has been formatted with a
1239 tag style list (-tag). For a change of pace, the list-type used to
1240 present the list-types is an over-hanging list (-ohang). This type of
1241 list is quite popular with TeX users, but might look a bit funny after
1242 having read many pages of tagged lists. The following list types are
1243 accepted by ‘.Bl’:
1244
1245 -bullet
1246 -item
1247 -enum
1248 These three are the simplest types of lists. Once the ‘.Bl’ macro has
1249 been given, items in the list are merely indicated by a line consisting
1250 solely of the ‘.It’ macro. For example, the source text for a simple
1251 enumerated list would look like:
1252
1253 .Bl -enum -compact
1254 .It
1255 Item one goes here.
1256 .It
1257 And item two here.
1258 .It
1259 Lastly item three goes here.
1260 .El
1261
1262 The results:
1263
1264 1. Item one goes here.
1265 2. And item two here.
1266 3. Lastly item three goes here.
1267
1268 A simple bullet list construction:
1269
1270 .Bl -bullet -compact
1271 .It
1272 Bullet one goes here.
1273 .It
1274 Bullet two here.
1275 .El
1276
1277 Produces:
1278 · Bullet one goes here.
1279 · Bullet two here.
1280
1281 -tag
1282 -diag
1283 -hang
1284 -ohang
1285 -inset
1286 These list-types collect arguments specified with the ‘.It’ macro and
1287 create a label which may be inset into the forthcoming text, hanged from
1288 the forthcoming text, overhanged from above and not indented or tagged.
1289 This list was constructed with the ‘-ohang’ list-type. The ‘.It’ macro
1290 is parsed only for the inset, hang and tag list-types and is not
1291 callable. Here is an example of inset labels:
1292
1293 Tag The tagged list (also called a tagged paragraph) is the most
1294 common type of list used in the Berkeley manuals.
1295
1296 Diag Diag lists create section four diagnostic lists and are simi‐
1297 lar to inset lists except callable macros are ignored.
1298
1299 Hang Hanged labels are a matter of taste.
1300
1301 Ohang Overhanging labels are nice when space is constrained.
1302
1303 Inset Inset labels are useful for controlling blocks of paragraphs
1304 and are valuable for converting -mdoc manuals to other formats.
1305
1306 Here is the source text which produced the above example:
1307
1308 .Bl -inset -offset indent
1309 .It Em Tag
1310 The tagged list (also called a tagged paragraph) is the
1311 most common type of list used in the Berkeley manuals.
1312 .It Em Diag
1313 Diag lists create section four diagnostic lists
1314 and are similar to inset lists except callable
1315 macros are ignored.
1316 .It Em Hang
1317 Hanged labels are a matter of taste.
1318 .It Em Ohang
1319 Overhanging labels are nice when space is constrained.
1320 .It Em Inset
1321 Inset labels are useful for controlling blocks of
1322 paragraphs and are valuable for converting
1323 .Nm -mdoc
1324 manuals to other formats.
1325 .El
1326
1327 Here is a hanged list with two items:
1328
1329 Hanged labels appear similar to tagged lists when the label is
1330 smaller than the label width.
1331
1332 Longer hanged list labels blend in to the paragraph unlike tagged
1333 paragraph labels.
1334
1335 And the unformatted text which created it:
1336
1337 .Bl -hang -offset indent
1338 .It Em Hanged
1339 labels appear similar to tagged lists when the
1340 label is smaller than the label width.
1341 .It Em Longer hanged list labels
1342 blend in to the paragraph unlike
1343 tagged paragraph labels.
1344 .El
1345
1346 The tagged list which follows uses an optional width specifier to control
1347 the width of the tag.
1348
1349 SL sleep time of the process (seconds blocked)
1350 PAGEIN number of disk I/O's resulting from references by the
1351 process to pages not loaded in core.
1352 UID numerical user-id of process owner
1353 PPID numerical ID of parent of process process priority (non-
1354 positive when in non-interruptible wait)
1355
1356 The raw text:
1357
1358 .Bl -tag -width "PAGEIN" -compact -offset indent
1359 .It SL
1360 sleep time of the process (seconds blocked)
1361 .It PAGEIN
1362 number of disk
1363 .Tn I/O Ns 's
1364 resulting from references
1365 by the process to pages not loaded in core.
1366 .It UID
1367 numerical user ID of process owner
1368 .It PPID
1369 numerical ID of parent of process process priority
1370 (non-positive when in non-interruptible wait)
1371 .El
1372
1373 Acceptable width specifiers:
1374
1375 -width Fl sets the width to the default width for a flag. All
1376 callable macros have a default width value. The
1377 ‘.Fl’, value is presently set to ten constant width
1378 characters or about five sixth of an inch.
1379
1380 -width 24n sets the width to 24 constant width characters or
1381 about two inches. The ‘n’ is absolutely necessary
1382 for the scaling to work correctly.
1383
1384 -width ENAMETOOLONG
1385 sets width to the constant width length of the string
1386 given.
1387
1388 -width "int mkfifo"
1389 again, the width is set to the constant width of the
1390 string given.
1391
1392 If a width is not specified for the tag list type, the first time ‘.It’
1393 is invoked, an attempt is made to determine an appropriate width. If the
1394 first argument to ‘.It’ is a callable macro, the default width for that
1395 macro will be used as if the macro name had been supplied as the width.
1396 However, if another item in the list is given with a different callable
1397 macro name, a new and nested list is assumed.
1398
1400 The following strings are predefined as may be used by preceding with the
1401 troff string interpreting sequence ‘\*(xx’ where xx is the name of the
1402 defined string or as ‘\*x’ where x is the name of the string. The inter‐
1403 preting sequence may be used any where in the text.
1404
1405 String Nroff Troff
1406 <= <= ≤
1407 >= >= ≥
1408 Rq '' ”
1409 Lq `` “
1410 ua ^ ↑
1411 aa ' ´
1412 ga ` `
1413 q " "
1414 Pi pi π
1415 Ne != ≠
1416 Le <= ≤
1417 Ge >= ≥
1418 Lt < >
1419 Gt > <
1420 Pm +- ±
1421 If infinity ∞
1422 Na NaN NaN
1423 Ba | |
1424
1425 Note: The string named ‘q’ should be written as ‘\*q’ since it is only
1426 one char.
1427
1429 The debugging facilities for -mdoc are limited, but can help detect sub‐
1430 tle errors such as the collision of an argument name with an internal
1431 register or macro name. (A what?) A register is an arithmetic storage
1432 class for troff with a one or two character name. All registers internal
1433 to -mdoc for troff and ditroff are two characters and of the form
1434 <upper_case><lower_case> such as ‘Ar’, <lower_case><upper_case> as ‘aR’
1435 or <upper or lower letter><digit> as ‘C1’. And adding to the muddle,
1436 troff has its own internal registers all of which are either two lower
1437 case characters or a dot plus a letter or meta-character character. In
1438 one of the introduction examples, it was shown how to prevent the inter‐
1439 pretation of a macro name with the escape sequence ‘\&’. This is suffi‐
1440 cient for the internal register names also.
1441
1442 If a non-escaped register name is given in the argument list of a request
1443 unpredictable behavior will occur. In general, any time huge portions of
1444 text do not appear where expected in the output, or small strings such as
1445 list tags disappear, chances are there is a misunderstanding about an
1446 argument type in the argument list. Your mother never intended for you
1447 to remember this evil stuff - so here is a way to find out whether or not
1448 your arguments are valid: The ‘.Db’ (debug) macro displays the interpre‐
1449 tation of the argument list for most macros. Macros such as the ‘.Pp’
1450 (paragraph) macro do not contain debugging information. All of the
1451 callable macros do, and it is strongly advised whenever in doubt, turn on
1452 the ‘.Db’ macro.
1453
1454 Usage: .Db [on | off]
1455
1456 An example of a portion of text with the debug macro placed above and
1457 below an artificially created problem (a flag argument ‘aC’ which should
1458 be ‘\&aC’ in order to work):
1459
1460 .Db on
1461 .Op Fl aC Ar file )
1462 .Db off
1463
1464 The resulting output:
1465
1466 DEBUGGING ON
1467 DEBUG(argv) MACRO: `.Op' Line #: 2
1468 Argc: 1 Argv: `Fl' Length: 2
1469 Space: `' Class: Executable
1470 Argc: 2 Argv: `aC' Length: 2
1471 Space: `' Class: Executable
1472 Argc: 3 Argv: `Ar' Length: 2
1473 Space: `' Class: Executable
1474 Argc: 4 Argv: `file' Length: 4
1475 Space: ` ' Class: String
1476 Argc: 5 Argv: `)' Length: 1
1477 Space: ` ' Class: Closing Punctuation or suffix
1478 MACRO REQUEST: .Op Fl aC Ar file )
1479 DEBUGGING OFF
1480
1481 The first line of information tells the name of the calling macro, here
1482 ‘.Op’, and the line number it appears on. If one or more files are
1483 involved (especially if text from another file is included) the line num‐
1484 ber may be bogus. If there is only one file, it should be accurate. The
1485 second line gives the argument count, the argument (‘Fl’) and its length.
1486 If the length of an argument is two characters, the argument is tested to
1487 see if it is executable (unfortunately, any register which contains a
1488 non-zero value appears executable). The third line gives the space
1489 allotted for a class, and the class type. The problem here is the argu‐
1490 ment aC should not be executable. The four types of classes are string,
1491 executable, closing punctuation and opening punctuation. The last line
1492 shows the entire argument list as it was read. In this next example, the
1493 offending ‘aC’ is escaped:
1494
1495 .Db on
1496 .Em An escaped \&aC
1497 .Db off
1498
1499 DEBUGGING ON
1500 DEBUG(fargv) MACRO: `.Em' Line #: 2
1501 Argc: 1 Argv: `An' Length: 2
1502 Space: ` ' Class: String
1503 Argc: 2 Argv: `escaped' Length: 7
1504 Space: ` ' Class: String
1505 Argc: 3 Argv: `aC' Length: 2
1506 Space: ` ' Class: String
1507 MACRO REQUEST: .Em An escaped &aC
1508 DEBUGGING OFF
1509
1510 The argument ‘\&aC’ shows up with the same length of 2 as the ‘\&’
1511 sequence produces a zero width, but a register named ‘\&aC’ was not found
1512 and the type classified as string.
1513
1514 Other diagnostics consist of usage statements and are self explanatory.
1515
1517 The -mdoc package does not need compatibility mode with groff.
1518
1519 The package inhibits page breaks, and the headers and footers which nor‐
1520 mally occur at those breaks with nroff, to make the manual more efficient
1521 for viewing on-line. At the moment, groff with -Tascii does eject the
1522 imaginary remainder of the page at end of file. The inhibiting of the
1523 page breaks makes nroff'd files unsuitable for hardcopy. There is a reg‐
1524 ister named ‘cR’ which can be set to zero in the site dependent style
1525 file /usr/src/share/tmac/doc-nroff to restore the old style behavior.
1526
1528 /usr/share/tmac/tmac.doc manual macro package
1529 /usr/share/misc/mdoc.template
1530 template for writing a man page
1531 /usr/share/examples/mdoc/* several example man pages
1532
1534 man(1), troff(1), mdoc(7)
1535
1537 Undesirable hyphenation on the dash of a flag argument is not yet
1538 resolved, and causes occasional mishaps in the DESCRIPTION section.
1539 (line break on the hyphen).
1540
1541 Predefined strings are not declared in documentation.
1542
1543 Section 3f has not been added to the header routines.
1544
1545 ‘.Nm’ font should be changed in NAME section.
1546
1547 ‘.Fn’ needs to have a check to prevent splitting up if the line length is
1548 too short. Occasionally it separates the last parenthesis, and sometimes
1549 looks ridiculous if a line is in fill mode.
1550
1551 The method used to prevent header and footer page breaks (other than the
1552 initial header and footer) when using nroff occasionally places an
1553 unsightly partially filled line (blank) at the would be bottom of the
1554 page.
1555
1556 The list and display macros to not do any keeps and certainly should be
1557 able to.
1558
1559BSD December 30, 1993 BSD