Developer's Daily | Unix by Example |
main | java | perl | unix | dev directory | web log |
MDOC.SAMPLES(7) BSD Miscellaneous Information Manual MDOC.SAMPLES(7)
NAME
mdoc.samples ? tutorial sampler for writing BSD manuals with ?mdoc |
SYNOPSIS
man mdoc.samples |
DESCRIPTION |
A tutorial sampler for writing BSD manual pages with the ?mdoc macro package, a content?based and domain?based formatting package for troff(1). Its predecessor, the ?man(7) package, addressed page layout leaving the manipulation of fonts and other typesetting details to the individual author. In ?mdoc, page layout macros make up the page structure domain which consists of macros for titles, section headers, displays and lists. Essentially items which affect the physical position of text on a formatted page. In addition to the page structure domain, there are two more domains, the manual domain and the general text domain. The general text domain is defined as macros which perform tasks such as quoting or emphasizing pieces of text. The manual domain is defined as macros that are a subset of the day to day informal language used to describe commands, routines and related BSD files. Macros in the manual domain handle command names, command line arguments and options, function names, function parameters, pathnames, variables, cross references to other manual pages, and so on. These domain items have value for both the author and the future user of the manual page. It is hoped the consistency gained across the manual set will provide easier translation to future documentation tools. Throughout the UNIX manual pages, a manual entry is simply referred to as a man page, regardless of actual length and without sexist intention. |
GETTING STARTED
Since a tutorial document is normally read when a person desires to use the material immediately, the assumption has been made that the user of this document may be impatient. The material presented in the remained of this document is outlined as follows: |
1. TROFF IDIOSYNCRASIES
Macro Usage. 2. THE ANATOMY OF A MAN PAGE 3. INTRODUCTION OF TITLE MACROS. 4. INTRODUCTION OF MANUAL AND GENERAL TEXT DOMAINS. 5. MANUAL DOMAIN 6. GENERAL TEXT DOMAIN 7. PAGE STRUCTURE DOMAIN 8. PREDEFINED STRINGS 9. DIAGNOSTICS 10.FORMATTING WITH GROFF, TROFF AND NROFF 11.BUGS TROFF IDIOSYNCRASIES |
The ?mdoc package attempts to simplify the process of writing a man page. Theoretically, one should not have to learn the dirty details of troff(1) to use ?mdoc; however, there are a few limitations which are unavoidable and best gotten out of the way. And, too, be forewarned, this package is not fast. |
Macro Usage |
As in troff(1), a macro is called by placing a ’.’ (dot character) at the beginning of a line followed by the two character name for the macro. Arguments may follow the macro separated by spaces. It is the dot character at the beginning of the line which causes troff(1) to interpret the next two characters as a macro name. To place a ’.’ (dot character) at the beginning of a line in some context other than a macro invocation, precede the ’.’ (dot) with the ’\&’ escape sequence. The ’\&’ translates literally to a zero width space, and is never displayed in the output. In general, troff(1) macros accept up to nine arguments, any extra arguments are ignored. Most macros in ?mdoc accept nine arguments and, in limited cases, arguments may be continued or extended on the next line (See Extended Arguments). A few macros handle quoted arguments (see Passing Space Characters in an Argument below). Most of the ?mdoc general text domain and manual domain macros are special in that their argument lists are parsed for callable macro names. This means an argument on the argument list which matches a general text or manual domain macro name and is determined to be callable will be executed or called when it is processed. In this case the argument, although the name of a macro, is not preceded by a ’.’ (dot). It is in this manner that many macros are nested; for example the option macro, ’.Op’, may call the flag and argument macros, ’Fl’ and ’Ar’, to specify an optional flag with an argument: |
[?s bytes]’ is produced by .Op Fl s Ar bytes
To prevent a two character string from being interpreted as a macro name, precede the string with the escape sequence ’\&’: [Fl s Ar bytes]’ is produced by .Op \&Fl s \&Ar bytes Here the strings ’Fl’ and ’Ar’ are not interpreted as macros. Macros whose argument lists are parsed for callable arguments are referred to as parsed and macros which may be called from an argument list are referred to as callable throughout this document and in the companion quick reference manual mdoc(7). This is a technical faux pas as almost all of the macros in ?mdoc are parsed, but as it was cumbersome to constantly refer to macros as being callable and being able to call other macros, the term parsed has been used. Passing Space Characters in an Argument There are two possible ways to pass an argument which contains an embedded space. Implementation note: Unfortunately, the most convenient way of passing spaces in between quotes by reassigning individual arguments before parsing was fairly expensive speed wise and space wise to implement in all the macros for AT&T troff. It is not expensive for groff but for the sake of portability, has been limited to the following macros which need it the most: Cd’ Configuration declaration (section 4
SYNOPSIS) One way of passing a string containing blank spaces is to use the hard or unpaddable space character ’\ ’, that is, a blank space preceded by the escape character ’\’. This method may be used with any macro but has the side effect of interfering with the adjustment of text over the length of a line. Troff sees the hard space as if it were any other printable character and cannot split the string into blank or newline separated pieces as one would expect. The method is useful for strings which are not expected to overlap a line boundary. For example: fetch(char *str) fetch(char *str) If the ’\’ or quotes were omitted, ’.Fn’ would see three arguments and the result would be: fetch(char, *str) For an example of what happens when the parameter list overlaps a newline boundary, see the BUGS section. Trailing Blank Space Characters Escaping Special Characters THE ANATOMY OF A MAN PAGE |
The body of a man page is easily constructed from a basic template found in the file: .\" /usr/share/misc/mdoc.template: .\" The following six lines are required. .Dd Month day, year .Os OPERATING_SYSTEM [version/release] .Dt DOCUMENT_TITLE [section number] [volume] .Sh NAME .Sh SYNOPSIS .Sh DESCRIPTION .\" The following requests should be uncommented and .\" used where appropriate. This next request is .\" for sections 2 and 3 function return values only. .\" .Sh RETURN VALUES .\" This next request is for sections 1, 6, 7 & 8 only .\" .Sh ENVIRONMENT .\" .Sh FILES .\" .Sh EXAMPLES .\" This next request is for sections 1, 6, 7 & 8 only .\" (command return values (to shell) and |
.\"
fprintf/stderr type diagnostics) |
.\" .Sh DIAGNOSTICS The first items in the template are the macros (.Dd, .Os, .Dt); the document date, the operating system the man page or subject source is developed or modified for, and the man page title (in upper case) along with the section of the manual the page belongs in. These macros identify the page, and are discussed below in TITLE MACROS. The remaining items in the template are section headers (.Sh); of which NAME, SYNOPSIS and DESCRIPTION are mandatory. The headers are discussed in PAGE STRUCTURE DOMAIN, after presentation of MANUAL DOMAIN. Several content macros are used to demonstrate page layout macros; reading about content macros before page layout macros is recommended. |
TITLE MACROS
The title macros are the first portion of the page structure domain, but are presented first and separate for someone who wishes to start writing a man page yesterday. Three header macros designate the document title or manual page title, the operating system, and the date of authorship. These macros are one called once at the very beginning of the document and are used to construct the headers and footers only. |
.Dt DOCUMENT_TITLE section# [volume]
The document title is the subject of the man page and must be in CAPITALS due to troff limitations. The section number may be 1, ..., 9, and if it is specified, the volume title may be omitted. A volume title may be arbitrary or one of the following: |
AMD NetBSD Ancestral Manual Documents |
SMM NetBSD System Manager’s Manual |
URM NetBSD Reference Manual |
PRM NetBSD Programmer’s Manual |
KM NetBSD Kernel Manual |
The default volume labeling is URM for sections 1, 6, and 7; SMM for section 8; PRM for sections 2, 3, 4, and 5; KM for section 9. |
.Os operating_system release#
The name of the operating system should be the common acronym, e.g. BSD or ATT. The release should be the standard release nomenclature for the system specified, e.g. 4.3, 4.3+Tahoe, V.3, V.4. Unrecognized arguments are displayed as given in the page footer. For instance, a typical footer might be: .Os BSD 4.3 or for a locally produced set .Os CS Department The Berkeley default, ’.Os’ without an argument, has been defined as NetBSD 1.4 in the site specific file /usr/share/tmac/tmac.doc-common. Note, if the ’.Os’ macro is not present, the bottom left corner of the page will be ugly. .Dd month day, year January 25, 1989 Note that the date must not be placed in quotes! MANUAL DOMAIN |
What’s in a name... |
The manual domain macro names are derived from the day to day informal language used to describe commands, subroutines and related files. Slightly different variations of this language are used to describe the three different aspects of writing a man page. First, there is the description of ?mdoc macro request usage. Second is the description of a UNIX command with ?mdoc macros and third, the description of a command to a user in the verbal sense; that is, discussion of a command in the text of a man page. In the first case, troff(1) macros are themselves a type of command; the general syntax for a troff command is: .Va argument1 argument2 ... argument9 The ’.Va’ is a macro command or request, and anything following it is an argument to be processed. In the second case, the description of a UNIX command using the content macros is a bit more involved; a typical SYNOPSIS command line might be displayed as: filter [?flag] infile outfile Here, filter is the command name and the bracketed string ?flag is a flag argument designated as optional by the option brackets. In ?mdoc terms, infile and outfile are called arguments. The macros which formatted the above example: .Nm filter .Op Fl flag .Ar infile outfile In the third case, discussion of commands and command syntax includes both examples above, but may add more detail. The arguments infile and outfile from the example above might be referred to as operands or file arguments. Some command line argument lists are quite long: |
make
[?eiknqrstv] [?D variable] [?d flags] [?f makefile] [?I directory] [?j max_jobs] [variable=value] [target ...] Here one might talk about the command make and qualify the argument makefile, as an argument to the flag, ?f, or discuss the optional file operand target. In the verbal context, such detail can prevent confusion, however the ?mdoc package does not have a macro for an argument to a flag. Instead the ’Ar’ argument macro is used for an operand or file argument like target as well as an argument to a flag like variable. The make command line was produced from: .Nm make The ’.Bk’ and ’.Ek’ macros are explained in Keeps. |
General Syntax |
The manual domain and general text domain macros share a similar syntax with a few minor deviations: ’.Ar’, ’.Fl’, ’.Nm’, and ’.Pa’ differ only when called without arguments; ’.Fn’ and ’.Xr’ impose an order on their argument lists and the ’.Op’ and ’.Fn’ macros have nesting limitations. All content macros are capable of recognizing and properly handling punctuation, provided each punctuation character is separated by a leading space. If an request is given: |
.Li sptr, ptr), |
The result is: |
sptr, ptr), |
The punctuation is not recognized and all is output in the literal font. If the punctuation is separated by a leading white space: |
.Li sptr , ptr ) , |
The result is: |
sptr, ptr), |
The punctuation is now recognized and is output in the default font distinguishing it from the strings in literal font. To remove the special meaning from a punctuation character escape it with ’\&’. Troff is limited as a macro language, and has difficulty when presented with a string containing a member of the mathematical, logical or quotation set: {+,?,/,*,%,<,>,<=,>=,=,==,&,‘,’,"} The problem is that troff may assume it is supposed to actually perform the operation or evaluation suggested by the characters. To prevent the accidental evaluation of these characters, escape them with ’\&’. Typical syntax is shown in the first content macro displayed below, ’.Ad’. |
Address Macro |
The address macro identifies an address construct of the form addr1[,addr2[,addr3]]. |
Usage: .Ad address ... |
.Ad addr1’ addr1
.Ad addr1 . It is an error to call .Ad without arguments. .Ad is callable by other macros and is parsed. Argument Macro Usage: .Ar argument ... If .Ar is called without arguments ’file ...’ is assumed. The .Ar macro is parsed and is callable. Configuration Declaration (section four only) device le0 at scode? Command Modifier Defined Variables Usage: .Dv defined_variable ... It is an error to call ’.Dv’ without arguments. ’.Dv’ is parsed and is callable. Errno’s (Section two only) Usage: .Er ERRNOTYPE ... It is an error to call ’.Er’ without arguments. The ’.Er’ macro is parsed and is callable. Environment Variables Usage: .Ev argument ... It is an error to call ’.Ev’ without arguments. The ’.Ev’ macro is parsed and is callable. Function Argument Usage: .Fa function_argument ... It is an error to call ’.Fa’ without arguments. ’.Fa’ is parsed and is callable. Function Declaration Usage: .Fd include_file (or defined variable) In the SYNOPSIS section a ’.Fd’ request causes a line break if a function has already been presented and a break has not occurred. This leaves a nice vertical space in between the previous function call and the declaration for the next function. Flags Usage: .Fl argument ... The ’.Fl’ macro without any arguments results in a dash representing stdin/stdout. Note that giving ’.Fl’ a single dash, will result in two dashes. The ’.Fl’ macro is parsed and is callable. Functions (library routines) Usage: .Fn [type] function [[type] parameters ... ] |
.Fn getchar’ getchar()
.Fn strlen ) ,’ strlen()), It is an error to call ’.Fn’ without any arguments. The ’.Fn’ macro is parsed and is callable, note that any call to another macro signals the end of the ’.Fn’ call (it will close-parenthesis at that point). For functions that have more than eight parameters (and this is rare), the macros ’.Fo’ (function open) and ’.Fc’ (function close) may be used with ’.Fa’ (function argument) to get around the limitation. For example: .Fo "int res_mkquery" Produces: |
int res_mkquery(int op, char *dname, int class, int type,char *data, int datalen, struct rrec *newrr, char *buf, int buflen)
The ’.Fo’ and ’.Fc’ macros are parsed and are callable. In the SYNOPSIS section, the function will always begin at the beginning of line. If there is more than one function presented in the SYNOPSIS section and a function type has not been given, a line break will occur, leaving a nice vertical space between the current function name and the one prior. At the moment, ’.Fn’ does not check its word boundaries against troff line lengths and may split across a newline ungracefully. This will be fixed in the near future.
Function Type |
This macro is intended for the SYNOPSIS section. It may be used anywhere else in the man page without problems, but its main purpose is to present the function type in kernel normal form for the SYNOPSIS of sections two and three (it causes a page break allowing the function name to appear on the next line).
Usage: .Ft type ... |
.Ft struct stat
struct stat The ’.Ft’ request is not callable by other macros. Interactive Commands Usage: .Li argument ... It is an error to call ’.Ic’ without arguments. The ’.Ic’ macro is parsed and is callable. Literals Usage: .Li argument ... The ’.Li’ macro is parsed and is callable. Name Macro Usage: .Nm argument ... The ’.Nm’ macro is parsed and is callable. Options Usage: .Op options ... The ’.Oc’ and ’.Oo’ macros: .Oo Produce: [ |
[?k kilobytes] [?i interval] [?c count]] The macros ’.Op’, ’.Oc’ and ’.Oo’ are parsed and are callable. Pathnames The ’.Pa’ macro formats path or file names. Usage: .Pa pathname .Pa /usr/share /usr/share .Pa /tmp/fooXXXXX ) . /tmp/fooXXXXX). The ’.Pa’ macro is parsed and is callable. Variables Generic variable reference: Usage: .Va variable ... .Va count count .Va settimer, settimer, .Va int *prt ) : int *prt): .Va char s ] ) ) , char s])), It is an error to call ’.Va’ without any arguments. The ’.Va’ macro isparsed and is callable. Manual Page Cross References The ’.Xr’ macro expects the first argument to be a manual page name, andthe second argument, if it exists, to be either a section page number orpunctuation. Any remaining arguments are assumed to be punctuation. Usage: .Xr man_page [1,...,9] .Xr mdoc’ mdoc .Xr mdoc , mdoc, .Xr mdoc 7 mdoc(7) .Xr mdoc 7 ) ) , mdoc(7))), The ’.Xr’ macro is parsed and is callable. It is an error to call ’.Xr’without any arguments.
GENERAL TEXT DOMAIN
AT&T Macro |
Usage: .At [v1 .. v7 | 32v | V.1 | V.4] ... |
.At’ AT&T UNIX
.At v6 .’ Version 6 AT&T UNIX. The ’.At’ macro is not parsed and not callable. It accepts at most two arguments. BSD Macro The ’.Bx’ macro is parsed and is callable. NetBSD Macro The ’.Nx’ macro is parsed and is callable. FreeBSD Macro The ’.Fx’ macro is parsed and is callable. UNIX Macro The ’.Ux’ macro is parsed and is callable. Emphasis Macro Usage: .Em argument ... The ’.Em’ macro is parsed and is callable. It is an error to call ’.Em’ without arguments. Enclosure and Quoting Macros |
Quote Close Open Function Result |
.Aq |
.Ac |
.Ao |
Angle Bracket Enclosure |
<string> |
||
.Bq |
.Bc |
.Bo |
Bracket Enclosure |
[string] |
||
.Dq |
.Dc |
.Do |
Double Quote |
‘‘string’’ |
||
.Ec |
.Eo |
Enclose String (in XX) |
XXstringXX |
|||
.Pq |
.Pc |
.Po |
Parenthesis Enclosure |
(string) |
||
.Ql |
Quoted Literal |
‘st’ or string |
||||
|
.Qc |
.Qo |
Straight Double Quote |
"string" |
||
.Sq |
.Sc |
.So |
Single Quote |
‘string’ |
Except for the irregular macros noted below, all of the quoting macros are parsed and callable. All handle punctuation properly, as long as it is presented one character at a time and separated by spaces. The quoting macros examine opening and closing punctuation to determine whether it comes before or after the enclosing string. This makes some nesting possible. |
.Ec, .Eo
These macros expect the first argument to be the opening and closing strings respectively. .Ql’ The quoted literal macro behaves differently for troff than nroff. If formatted with nroff, a quoted literal is always quoted. If formatted with troff, an item is only quoted if the width of the item is less than three constant width characters. This is to make short strings more visible where the font change to literal (constant width) is less noticeable. .Pf’ The prefix macro is not callable, but it is parsed: .Pf ( Fa name2 .Ns’ The ’.Ns’ (no space) macro, which is callable, performs the analogous suffix function. .Ap’ The .Ap macro inserts an apostrophe and exits any special text modes, continuing in .No mode. Examples of quoting: For a good example of nested enclosure macros, see the ’.Op’ option macro. It was created from the same underlying enclosure macros as those presented in the list above. The ’.Xo’ and ’.Xc’ extended argument list macros were also built from the same underlying routines and are a good example of ?mdoc macro usage at its worst. No?Op or Normal Text Macro Space Macro .Op Fl I Ns Ar directory Note: the ’.Ns’ macro always invokes the ’.No’ macro after eliminating the space unless another macro name follows it. The macro ’.Ns’ is parsed and is callable. Section Cross References .Sx FILES’ FILES Symbolic Usage: .Sy symbol ... The ’.Sy’ macro is parsed and is callable. Arguments to ’.Sy’ may be quoted. References and Citations .Rs’ Reference Start. Causes a line break and
begins collection of reference information until the
reference end macro is read. The macros beginning with ’%’ are not callable, and are parsed only for the trade name macro which returns to its caller. (And not very predictably at the moment either.) The purpose is to allow trade names to be pretty printed in troff/ditroff output. Trade Names (or Acronyms and Type Names) Usage: .Tn symbol ... The ’.Tn’ macro is parsed and is callable by other macros. Extended Arguments Here is an example of ’.Xo’ using the space mode macro to turn spacing off: .Sm off Produces |
Ioperation\ncount\n
Another one: .Sm off .It Cm S No / Ar old_pattern Xo .No / Ar new_pattern .No / Op Cm g .Xc .Sm on Produces |
S/old_pattern /new_pattern/[g]
Another example of ’.Xo’ and using enclosure macros: Test the value of an variable. .It Xo .Ic .ifndef .Oo \&! Oc Ns Ar variable .Op Ar operator variable ... .Xc Produces |
.ifndef [ !]variable [operator variable ...]
All of the above examples have used the ’.Xo’ macro on the argument list of the ’.It’ (list-item) macro. The extend macros are not used very often, and when they are it is usually to extend the list-item argument list. Unfortunately, this is also where the extend macros are the most finicky. In the first two examples, spacing was turned off; in the third, spacing was desired in part of the output but not all of it. To make these macros work in this situation make sure the ’.Xo’ and ’.Xc’ macros are placed as shown in the third example. If the ’.Xo’ macro is not alone on the ’.It’ argument list, spacing will be unpredictable. The ’.Ns’ (no space macro) must not occur as the first or last macro on a line in this situation. Out of 900 manual pages (about 1500 actual pages) currently released with BSD only fifteen use the ’.Xo’ macro. |
PAGE STRUCTURE DOMAIN
Section Headers |
The first three ’.Sh’ section header macros list below are required in every man page. The remaining section headers are recommended at the discretion of the author writing the manual page. The ’.Sh’ macro can take up to nine arguments. It is parsed and but is not callable. |
.Sh NAME
The ’.Sh NAME’ macro is mandatory. If not specified, the headers, footers and page layout defaults will not be set and things will be rather unpleasant. The NAME section consists of at least three items. The first is the ’.Nm’ name macro naming the subject of the man page. The second is the Name Description macro, ’.Nd’, which separates the subject name from the third item, which is the description. The description should be the most terse and lucid possible, as the space available is small. .Sh SYNOPSIS cat [?benstuv] [?] file ... The following macros were used: |
.Nm cat |
.Op Fl benstuv |
.Op Fl |
.Ar |
Note: The macros ’.Op’, ’.Fl’, and ’.Ar’ recognize the pipe bar character ’|’, so a command line such as: |
.Op Fl a | Fl b |
will not go orbital. Troff normally interprets a | as a special operator. See PREDEFINED STRINGS for a usable | character in other situations. |
.Sh DESCRIPTION
In most cases the first text in the DESCRIPTION section is a brief paragraph on the command, function or file, followed by a lexical list of options and respective explanations. To create such a list, the ’.Bl’ begin-list, ’.It’ list-item and ’.El’ end-list macros are used (see Lists and Columns below). The following ’.Sh’ section headers are part of the preferred manual page layout and must be used appropriately to maintain consistency. They are listed in the order in which they would be used. .Sh ENVIRONMENT .Sh EXAMPLES .Sh FILES .Sh SEE ALSO It is recommended that the cross references are sorted on the section number, and then alphabetically on the names within a section. .Sh STANDARDS .Sh HISTORY .Sh AUTHORS .Sh DIAGNOSTICS .Sh ERRORS .Sh BUGS User specified ’.Sh’ sections may be added, for example, this section was set with: .Sh PAGE LAYOUT MACROS |
Paragraphs and Line Spacing. |
.Pp’ The .Pp paragraph command may be used to specify a linespace where necessary. The macro is not necessary after a ’.Sh’or ’.Ss’ macro or before a ’.Bl’ macro. (The ’.Bl’ macro assertsa vertical distance unless the -compact flag is given).
Keeps Examples and Displays .D1’ (D-one) Display one line of indented text. This macro is parsed, but it is not callable. ?ldghfstru The above was produced by: .Dl ?ldghfstru. .Dl’ (D-ell) Display one line of indented literal text. The ’.Dl’ example macro has been used throughout this file. It allows the indent (display) of one line of text. Its default font is set to constant width (literal) however it is parsed and will recognized other macros. It is not callable however. % ls -ldg /usr/local/bin The above was produced by .Dl % ls -ldg /usr/local/bin. .Bd’ Begin-display. The ’.Bd’ display must be ended with the ’.Ed’ macro. Displays may be nested within lists, but may not contain other displays; this also prohibits nesting of .D1 and .Dl one-line displays. ’.Bd’ has the following syntax: .Bd display-type [-offset offset_value] [-compact] The display-type must be one of the following four types and may have an offset specifier for indentation: ’.Bd’. ?ragged’ Fill, but do not adjust the
right margin. left’ Align block on the current left
margin, this is the default mode of
’.Bd’. .Ed’ End-display. Tagged Lists and Columns In addition, several list attributes may be specified such as the width of a tag, the list offset, and compactness (blank lines between items allowed or disallowed). Most of this document has been formatted with a tag style list (?tag). For a change of pace, the list-type used to present the list-types is an over-hanging list (?ohang). This type of list is quite popular with TeX users, but might look a bit funny after having read many pages of tagged lists. The following list types are accepted by ’.Bl’: ?bullet .Bl -enum -compact The results: |
1. Item one goes here.
2. And item two here. A simple bullet list construction: .Bl -bullet -compact Produces: |
• Bullet one goes here.
• Bullet two here. ?tag Tag The tagged list (also called a tagged paragraph) is the most common type of list used in the Berkeley manuals. Use a ?width attribute as described below. Diag Diag lists create section four diagnostic lists and are similar to inset lists except callable macros are ignored. Hang Hanged labels are a matter of taste. Ohang Overhanging labels are nice when space is constrained. Inset Inset labels are useful for controlling blocks of paragraphs and are valuable for converting ?mdoc manuals to other formats. Here is the source text which produced the above example: .Bl -inset -offset indent Here is a hanged list with just one item: |
Hangedlabels appear similar to tagged lists when the label issmaller than the label width.
Longer hanged list labels blend in to the paragraph unlike tagged paragraph labels. And the unformatted text which created it: .Bl -hang -offset indent The tagged list which follows uses a width specifier to control the width of the tag. |
SL’ sleep time of the process (seconds blocked)
PAGEIN The raw text: .Bl -tag -width "PAGEIN" -compact -offset
indent Acceptable width specifiers: |
?width Fl’ sets the width to the default width for aflag. All callable macros have a default widthvalue. The ’.Fl’, value is presently set to tenconstant width characters or about five sixth of aninch.
?width 24n’ sets the width to 24 constant width characters or about two inches. The ’n’ is absolutely necessary for the scaling to work correctly. ?width ENAMETOOLONG ?width "int mkfifo" If a width is not specified for the tag list type, the first time ’.It’ is invoked, an attempt is made to determine an appropriate width. If the first argument to ’.It’ is a callable macro, the default width for that macro will be used as if the macro name had been supplied as the width. However, if another item in the list is given with a different callable macro name, a new and nested list is assumed. This effectively means that ?width is required for the tag list type. ?column |
String Nroff Troff |
<= <= ? |
>= >= ? |
was produced by: .Bl -column "String" "Nroff" "Troff" -offset indent .It Sy "String" Ta Sy "Nroff" Ta Sy "Troff" .It Li "<=" Ta <= Ta ? .It Li ">=" Ta >= Ta ? .El |
PREDEFINED STRINGS
The following strings are predefined as may be used by preceding with the troff string interpreting sequence ’\*(xx’ where xx is the name of the defined string or as ’\*x’ where x is the name of the string. The interpreting sequence may be used any where in the text. |
String Nroff Troff Note: The string named ’q’ should be written as ’\*q’ since it is only one char. |
DIAGNOSTICS
The debugging facilities for ?mdoc are limited, but can help detect subtle errors such as the collision of an argument name with an internal register or macro name. (A what?) A register is an arithmetic storage class for troff with a one or two character name. All registers internal to ?mdoc for troff and ditroff are two characters and of the form <upper_case><lower_case> such as ’Ar’, <lower_case><upper_case> as ’aR’ or <upper or lower letter><digit> as ’C1’. And adding to the muddle, troff has its own internal registers all of which are either two lower case characters or a dot plus a letter or meta-character character. In one of the introduction examples, it was shown how to prevent the interpretation of a macro name with the escape sequence ’\&’. This is sufficient for the internal register names also. If a non-escaped register name is given in the argument list of a request unpredictable behavior will occur. In general, any time huge portions of text do not appear where expected in the output, or small strings such as list tags disappear, chances are there is a misunderstanding about an argument type in the argument list. Your mother never intended for you to remember this evil stuff - so here is a way to find out whether or not your arguments are valid: The ’.Db’ (debug) macro displays the interpretation of the argument list for most macros. Macros such as the ’.Pp’ (paragraph) macro do not contain debugging information. All of the callable macros do, and it is strongly advised whenever in doubt, turn on the ’.Db’ macro. |
Usage: .Db [on | off] |
An example of a portion of text with the debug macro placed above and below an artificially created problem (a flag argument ’aC’ which should be ’\&aC’ in order to work): .Db on .Op Fl aC Ar file ) .Db off The resulting output: DEBUGGING ON DEBUG(argv) MACRO: ‘.Op’ Line #: 2 |
Argc: 1 Argv: ‘Fl’ Length: 2 |
||
Space: ‘’ Class: Executable |
||
Argc: 2 Argv: ‘aC’ Length: 2 |
||
Space: ‘’ Class: Executable |
||
Argc: 3 Argv: ‘Ar’ Length: 2 |
||
Space: ‘’ Class: Executable |
||
Argc: 4 Argv: ‘file’ Length: 4 |
||
Space: ‘ ’ Class: String |
||
Argc: 5 Argv: ‘)’ Length: 1 |
||
Space: ‘ ’ Class: Closing Punctuation or suffix |
||
MACRO REQUEST: .Op Fl aC Ar file ) |
DEBUGGING OFF The first line of information tells the name of the calling macro, here ’.Op’, and the line number it appears on. If one or more files are involved (especially if text from another file is included) the line number may be bogus. If there is only one file, it should be accurate. The second line gives the argument count, the argument (’Fl’) and its length. If the length of an argument is two characters, the argument is tested to see if it is executable (unfortunately, any register which contains a non-zero value appears executable). The third line gives the space allotted for a class, and the class type. The problem here is the argument aC should not be executable. The four types of classes are string, executable, closing punctuation and opening punctuation. The last line shows the entire argument list as it was read. In this next example, the offending ’aC’ is escaped: .Db on .Em An escaped \&aC .Db off DEBUGGING ON DEBUG(fargv) MACRO: ‘.Em’ Line #: 2 |
Argc: 1 Argv: ‘An’ Length: 2 |
||
Space: ‘ ’ Class: String |
||
Argc: 2 Argv: ‘escaped’ Length: 7 |
||
Space: ‘ ’ Class: String |
||
Argc: 3 Argv: ‘aC’ Length: 2 |
||
Space: ‘ ’ Class: String |
||
MACRO REQUEST: .Em An escaped &aC |
DEBUGGING OFF The argument ’\&aC’ shows up with the same length of 2 as the ’\&’ sequence produces a zero width, but a register named ’\&aC’ was not found and the type classified as string. Other diagnostics consist of usage statements and are self explanatory. |
GROFF, TROFF AND NROFF
The ?mdoc package does not need compatibility mode with groff. The package inhibits page breaks, and the headers and footers which normally occur at those breaks with nroff, to make the manual more efficient for viewing on-line. At the moment, groff with ?Tascii does eject the imaginary remainder of the page at end of file. The inhibiting of the page breaks makes nroff’d files unsuitable for hardcopy. There is a register named ’cR’ which can be set to zero in the site dependent style file /usr/src/share/tmac/doc-nroff to restore the old style behavior. |
FILES
/usr/share/tmac/tmac.doc’ manual macropackage
/usr/share/misc/mdoc.template SEE ALSO |
mdoc(7), man(1), troff(1) |
BUGS
Undesirable hyphenation on the dash of a flag argument is not yet resolved, and causes occasional mishaps in the DESCRIPTION section. (line break on the hyphen). Predefined strings are not declared in documentation. Section 3f has not been added to the header routines. ’.Nm’ font should be changed in NAME section. ’.Fn’ needs to have a check to prevent splitting up if the line length is too short. Occasionally it separates the last parenthesis, and sometimes looks ridiculous if a line is in fill mode. The method used to prevent header and footer page breaks (other than the initial header and footer) when using nroff occasionally places an unsightly partially filled line (blank) at the would be bottom of the page. If the outer-most list definition doesn’t have a ?width argument, the ’.It’ elements of inner lists may not work (producing a list where each successive element ’walks’ to the right). The list and display macros to not do any keeps and certainly should be able to. BSD November 24, 1997 BSD |