[BACK]Return to mandoc.1 CVS log [TXT][DIR] Up to [local] / src / usr.bin / mandoc

Annotation of src/usr.bin/mandoc/mandoc.1, Revision 1.33

1.33    ! schwarze    1: .\"    $OpenBSD: mandoc.1,v 1.32 2010/06/26 17:56:43 schwarze Exp $
1.1       kristaps    2: .\"
1.29      schwarze    3: .\" Copyright (c) 2009 Kristaps Dzonsons <kristaps@bsd.lv>
1.1       kristaps    4: .\"
                      5: .\" Permission to use, copy, modify, and distribute this software for any
1.3       schwarze    6: .\" purpose with or without fee is hereby granted, provided that the above
                      7: .\" copyright notice and this permission notice appear in all copies.
1.1       kristaps    8: .\"
1.3       schwarze    9: .\" THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
                     10: .\" WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
                     11: .\" MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
                     12: .\" ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
                     13: .\" WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
                     14: .\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
                     15: .\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
1.1       kristaps   16: .\"
1.33    ! schwarze   17: .Dd $Mdocdate: June 26 2010 $
1.2       deraadt    18: .Dt MANDOC 1
1.1       kristaps   19: .Os
                     20: .Sh NAME
                     21: .Nm mandoc
                     22: .Nd format and display UNIX manuals
                     23: .Sh SYNOPSIS
                     24: .Nm mandoc
1.26      jmc        25: .Op Fl V
                     26: .Op Fl f Ns Ar option
1.1       kristaps   27: .Op Fl m Ns Ar format
1.26      jmc        28: .Op Fl O Ns Ar option
1.17      schwarze   29: .Op Fl T Ns Ar output
1.26      jmc        30: .Op Fl W Ns Ar err
                     31: .Op Ar file...
1.1       kristaps   32: .Sh DESCRIPTION
                     33: The
                     34: .Nm
1.10      schwarze   35: utility formats
1.1       kristaps   36: .Ux
1.25      jmc        37: manual pages for display.
                     38: The arguments are as follows:
1.5       schwarze   39: .Bl -tag -width Ds
1.26      jmc        40: .It Fl f Ns Ar option
1.25      jmc        41: Comma-separated compiler options.
                     42: See
1.1       kristaps   43: .Sx Compiler Options
                     44: for details.
                     45: .It Fl m Ns Ar format
1.25      jmc        46: Input format.
                     47: See
1.1       kristaps   48: .Sx Input Formats
1.25      jmc        49: for available formats.
                     50: Defaults to
1.26      jmc        51: .Fl m Ns Cm andoc .
                     52: .It Fl O Ns Ar option
1.25      jmc        53: Comma-separated output options.
                     54: See
1.17      schwarze   55: .Sx Output Options
                     56: for details.
1.1       kristaps   57: .It Fl T Ns Ar output
1.25      jmc        58: Output format.
                     59: See
1.1       kristaps   60: .Sx Output Formats
1.25      jmc        61: for available formats.
                     62: Defaults to
1.26      jmc        63: .Fl T Ns Cm ascii .
1.4       schwarze   64: .It Fl V
                     65: Print version and exit.
1.26      jmc        66: .It Fl W Ns Ar err
1.25      jmc        67: Comma-separated warning options.
                     68: Use
1.26      jmc        69: .Fl W Ns Cm all
1.8       schwarze   70: to print warnings,
1.26      jmc        71: .Fl W Ns Cm error
1.8       schwarze   72: for warnings to be considered errors and cause utility
1.25      jmc        73: termination.
                     74: Multiple
1.1       kristaps   75: .Fl W
                     76: arguments may be comma-separated, such as
1.26      jmc        77: .Fl W Ns Cm error , Ns Cm all .
                     78: .It Ar file
                     79: Read input from zero or more files.
1.25      jmc        80: If unspecified, reads from stdin.
                     81: If multiple files are specified,
1.1       kristaps   82: .Nm
                     83: will halt with the first failed parse.
                     84: .El
                     85: .Pp
1.10      schwarze   86: By default,
                     87: .Nm
                     88: reads
1.1       kristaps   89: .Xr mdoc 7
                     90: or
                     91: .Xr man 7
                     92: text from stdin, implying
1.26      jmc        93: .Fl m Ns Cm andoc ,
1.20      schwarze   94: and produces
1.26      jmc        95: .Fl T Ns Cm ascii
1.20      schwarze   96: output.
1.1       kristaps   97: .Pp
                     98: .Ex -std mandoc
                     99: .Ss Input Formats
                    100: The
                    101: .Nm
                    102: utility accepts
                    103: .Xr mdoc 7
                    104: and
                    105: .Xr man 7
                    106: input with
1.26      jmc       107: .Fl m Ns Cm doc
1.1       kristaps  108: and
1.26      jmc       109: .Fl m Ns Cm an ,
1.25      jmc       110: respectively.
                    111: The
1.1       kristaps  112: .Xr mdoc 7
                    113: format is
                    114: .Em strongly
1.10      schwarze  115: recommended;
1.1       kristaps  116: .Xr man 7
                    117: should only be used for legacy manuals.
                    118: .Pp
                    119: A third option,
1.26      jmc       120: .Fl m Ns Cm andoc ,
1.1       kristaps  121: which is also the default, determines encoding on-the-fly: if the first
1.10      schwarze  122: non-comment macro is
1.11      schwarze  123: .Sq \&Dd
1.1       kristaps  124: or
1.11      schwarze  125: .Sq \&Dt ,
1.10      schwarze  126: the
1.1       kristaps  127: .Xr mdoc 7
                    128: parser is used; otherwise, the
                    129: .Xr man 7
                    130: parser is used.
                    131: .Pp
                    132: If multiple
1.10      schwarze  133: files are specified with
1.26      jmc       134: .Fl m Ns Cm andoc ,
1.25      jmc       135: each has its file-type determined this way.
                    136: If multiple files are
1.1       kristaps  137: specified and
1.26      jmc       138: .Fl m Ns Cm doc
1.1       kristaps  139: or
1.26      jmc       140: .Fl m Ns Cm an
1.1       kristaps  141: is specified, then this format is used exclusively.
                    142: .Ss Output Formats
                    143: The
                    144: .Nm
                    145: utility accepts the following
                    146: .Fl T
1.20      schwarze  147: arguments (see
                    148: .Sx OUTPUT ) :
1.5       schwarze  149: .Bl -tag -width Ds
1.26      jmc       150: .It Fl T Ns Cm ascii
1.1       kristaps  151: Produce 7-bit ASCII output, backspace-encoded for bold and underline
1.25      jmc       152: styles.
                    153: This is the default.
                    154: See
1.20      schwarze  155: .Sx ASCII Output .
1.26      jmc       156: .It Fl T Ns Cm html
1.25      jmc       157: Produce strict HTML-4.01 output, with a sane default style.
                    158: See
1.20      schwarze  159: .Sx HTML Output .
1.26      jmc       160: .It Fl T Ns Cm lint
                    161: Parse only: produce no output.
                    162: Implies
                    163: .Fl W Ns Cm all
                    164: and
                    165: .Fl f Ns Cm strict .
1.31      schwarze  166: .It Fl T Ns Cm ps
                    167: Produce PostScript output.
                    168: See
                    169: .Sx PostScript Output .
1.26      jmc       170: .It Fl T Ns Cm tree
                    171: Produce an indented parse tree.
                    172: .It Fl T Ns Cm xhtml
1.25      jmc       173: Produce strict XHTML-1.0 output, with a sane default style.
                    174: See
1.21      schwarze  175: .Sx XHTML Output .
1.1       kristaps  176: .El
                    177: .Pp
                    178: If multiple input files are specified, these will be processed by the
                    179: corresponding filter in-order.
                    180: .Ss Compiler Options
1.15      schwarze  181: Default compiler behaviour may be overridden with the
1.1       kristaps  182: .Fl f
                    183: flag.
1.5       schwarze  184: .Bl -tag -width Ds
1.26      jmc       185: .It Fl f Ns Cm ign-errors
                    186: When parsing multiple files, don't halt when one errors out.
                    187: Useful with
                    188: .Fl T Ns Cm lint
                    189: over a large set of manuals passed on the command line.
                    190: .It Fl f Ns Cm ign-escape
                    191: Ignore invalid escape sequences.
                    192: This is the default, but the option can be used to override an earlier
                    193: .Fl f Ns Cm strict .
                    194: .It Fl f Ns Cm ign-scope
1.1       kristaps  195: When rewinding the scope of a block macro, forces the compiler to ignore
1.25      jmc       196: scope violations.
                    197: This can seriously mangle the resulting tree.
1.1       kristaps  198: .Pq mdoc only
1.26      jmc       199: .It Fl f Ns Cm no-ign-escape
                    200: Do not ignore invalid escape sequences.
                    201: .It Fl f Ns Cm no-ign-macro
1.1       kristaps  202: Do not ignore unknown macros at the start of input lines.
1.26      jmc       203: .It Fl f Ns Cm strict
1.10      schwarze  204: Implies
1.28      schwarze  205: .Fl f Ns Cm no-ign-escape
1.1       kristaps  206: and
1.28      schwarze  207: .Fl f Ns Cm no-ign-macro .
1.1       kristaps  208: .El
1.17      schwarze  209: .Ss Output Options
1.30      schwarze  210: The
1.17      schwarze  211: .Fl T Ns Ar html
1.23      schwarze  212: and
                    213: .Fl T Ns Ar xhtml
1.33    ! schwarze  214: modes accept the following
        !           215: .Fl O
        !           216: arguments:
1.17      schwarze  217: .Bl -tag -width Ds
1.33    ! schwarze  218: .It Cm includes Ns = Ns Ar fmt
1.17      schwarze  219: The string
                    220: .Ar fmt ,
1.21      schwarze  221: for example,
1.17      schwarze  222: .Ar ../src/%I.html ,
                    223: is used as a template for linked header files (usually via the
                    224: .Sq \&In
1.25      jmc       225: macro).
                    226: Instances of
1.17      schwarze  227: .Sq \&%I
1.25      jmc       228: are replaced with the include filename.
                    229: The default is not to present a
1.17      schwarze  230: hyperlink.
1.33    ! schwarze  231: .It Cm man Ns = Ns Ar fmt
1.17      schwarze  232: The string
                    233: .Ar fmt ,
1.21      schwarze  234: for example,
1.17      schwarze  235: .Ar ../html%S/%N.%S.html ,
                    236: is used as a template for linked manuals (usually via the
                    237: .Sq \&Xr
1.25      jmc       238: macro).
                    239: Instances of
1.17      schwarze  240: .Sq \&%N
                    241: and
                    242: .Sq %S
                    243: are replaced with the linked manual's name and section, respectively.
1.25      jmc       244: If no section is included, section 1 is assumed.
                    245: The default is not to
1.17      schwarze  246: present a hyperlink.
1.33    ! schwarze  247: .It Cm style Ns = Ns Ar style.css
1.26      jmc       248: The file
                    249: .Ar style.css
                    250: is used for an external style-sheet.
                    251: This must be a valid absolute or
                    252: relative URI.
1.30      schwarze  253: .El
                    254: .Pp
                    255: The
                    256: .Fl T Ns Ar ascii
1.33    ! schwarze  257: mode accepts the following
        !           258: .Fl O
        !           259: argument:
1.30      schwarze  260: .Bl -tag -width Ds
1.33    ! schwarze  261: .It Cm width Ns = Ns Ar width
1.30      schwarze  262: The output width is set to
                    263: .Ar width ,
                    264: which will normalise to \(>=60.
1.17      schwarze  265: .El
1.20      schwarze  266: .Sh OUTPUT
                    267: This section documents output details of
                    268: .Nm .
                    269: In general, output conforms to the traditional manual style of a header,
1.21      schwarze  270: a body composed of sections and sub-sections, and a footer.
1.20      schwarze  271: .Pp
                    272: The text style of output characters (non-macro characters, punctuation,
                    273: and white-space) is dictated by context.
                    274: .Pp
1.25      jmc       275: White-space is generally stripped from input.
                    276: This can be changed with
1.20      schwarze  277: character escapes (specified in
                    278: .Xr mandoc_char 7 )
                    279: or literal modes (specified in
                    280: .Xr mdoc 7
                    281: and
                    282: .Xr man 7 ) .
                    283: .Pp
                    284: If non-macro punctuation is set apart from words, such as in the phrase
                    285: .Dq to be \&, or not to be ,
                    286: it's processed by
                    287: .Nm ,
                    288: regardless of output format, according to the following rules:  opening
                    289: punctuation
                    290: .Po
                    291: .Sq \&( ,
                    292: .Sq \&[ ,
                    293: and
                    294: .Sq \&{
                    295: .Pc
                    296: is not followed by a space; closing punctuation
                    297: .Po
                    298: .Sq \&. ,
                    299: .Sq \&, ,
                    300: .Sq \&; ,
                    301: .Sq \&: ,
                    302: .Sq \&? ,
                    303: .Sq \&! ,
                    304: .Sq \&) ,
                    305: .Sq \&]
                    306: and
                    307: .Sq \&}
                    308: .Pc
                    309: is not preceded by white-space.
                    310: .Pp
                    311: If the input is
                    312: .Xr mdoc 7 ,
                    313: however, these rules are also applied to macro arguments when appropriate.
                    314: .Ss ASCII Output
1.21      schwarze  315: Output produced by
1.26      jmc       316: .Fl T Ns Cm ascii ,
1.20      schwarze  317: which is the default, is rendered in standard 7-bit ASCII documented in
                    318: .Xr ascii 7 .
                    319: .Pp
                    320: Font styles are applied by using back-spaced encoding such that an
                    321: underlined character
                    322: .Sq c
                    323: is rendered as
                    324: .Sq _ Ns \e[bs] Ns c ,
                    325: where
                    326: .Sq \e[bs]
1.25      jmc       327: is the back-space character number 8.
                    328: Emboldened characters are rendered as
1.20      schwarze  329: .Sq c Ns \e[bs] Ns c .
                    330: .Pp
                    331: The special characters documented in
                    332: .Xr mandoc_char 7
                    333: are rendered best-effort in an ASCII equivalent.
                    334: .Pp
                    335: Output width is limited to 78 visible columns unless literal input lines
                    336: exceed this limit.
                    337: .Ss HTML Output
                    338: Output produced by
1.26      jmc       339: .Fl T Ns Cm html
1.21      schwarze  340: conforms to HTML-4.01 strict.
1.20      schwarze  341: .Pp
1.25      jmc       342: Font styles and page structure are applied using CSS2.
                    343: By default, no font style is applied to any text,
                    344: although CSS2 is hard-coded to format
1.20      schwarze  345: the basic structure of output.
                    346: .Pp
                    347: The
                    348: .Pa example.style.css
                    349: file documents the range of styles applied to output and, if used, will
                    350: cause rendered documents to appear as they do in
1.26      jmc       351: .Fl T Ns Cm ascii .
1.20      schwarze  352: .Pp
                    353: Special characters are rendered in decimal-encoded UTF-8.
1.31      schwarze  354: .Ss PostScript Output
1.33    ! schwarze  355: PostScript
        !           356: .Qq Adobe-3.0
        !           357: Level-2 pages may be generated by
1.31      schwarze  358: .Fl T Ns Cm ps .
                    359: Output pages are US-letter sized (215.9 x 279.4 mm) and rendered in
                    360: fixed, 10-point Courier font.
1.21      schwarze  361: .Ss XHTML Output
                    362: Output produced by
1.26      jmc       363: .Fl T Ns Cm xhtml
1.21      schwarze  364: conforms to XHTML-1.0 strict.
                    365: .Pp
                    366: See
                    367: .Sx HTML Output
                    368: for details; beyond generating XHTML tags instead of HTML tags, these
                    369: output modes are identical.
1.1       kristaps  370: .Sh EXAMPLES
                    371: To page manuals to the terminal:
                    372: .Pp
1.26      jmc       373: .D1 $ mandoc \-Wall,error \-fstrict mandoc.1 2\*(Gt&1 | less
                    374: .D1 $ mandoc mandoc.1 mdoc.3 mdoc.7 | less
1.12      schwarze  375: .Pp
1.17      schwarze  376: To produce HTML manuals with
                    377: .Ar style.css
                    378: as the style-sheet:
                    379: .Pp
1.26      jmc       380: .D1 $ mandoc \-Thtml -Ostyle=style.css mdoc.7 \*(Gt mdoc.7.html
1.17      schwarze  381: .Pp
1.12      schwarze  382: To check over a large set of manuals:
                    383: .Pp
1.26      jmc       384: .Dl $ mandoc \-Tlint \-fign-errors `find /usr/src -name \e*\e.[1-9]`
1.6       schwarze  385: .Sh COMPATIBILITY
1.10      schwarze  386: This section summarises
1.6       schwarze  387: .Nm
1.10      schwarze  388: compatibility with
1.6       schwarze  389: .Xr groff 1 .
1.14      schwarze  390: Each input and output format is separately noted.
1.20      schwarze  391: .Ss ASCII Compatibility
1.6       schwarze  392: .Bl -bullet -compact
1.13      schwarze  393: .It
1.21      schwarze  394: The
1.13      schwarze  395: .Sq \e~
1.21      schwarze  396: special character doesn't produce expected behaviour in
1.26      jmc       397: .Fl T Ns Cm ascii .
1.14      schwarze  398: .It
1.21      schwarze  399: The
1.14      schwarze  400: .Sq \&Bd \-literal
1.21      schwarze  401: and
1.14      schwarze  402: .Sq \&Bd \-unfilled
                    403: macros of
                    404: .Xr mdoc 7
                    405: in
1.26      jmc       406: .Fl T Ns Cm ascii
1.14      schwarze  407: are synonyms, as are \-filled and \-ragged.
                    408: .It
1.21      schwarze  409: In
1.14      schwarze  410: .Xr groff 1 ,
                    411: the
                    412: .Sq \&Pa
                    413: .Xr mdoc 7
                    414: macro does not underline when scoped under an
                    415: .Sq \&It
1.25      jmc       416: in the FILES section.
                    417: This behaves correctly in
1.14      schwarze  418: .Nm .
1.10      schwarze  419: .It
1.26      jmc       420: A list or display following the
1.11      schwarze  421: .Sq \&Ss
1.14      schwarze  422: .Xr mdoc 7
                    423: macro in
1.26      jmc       424: .Fl T Ns Cm ascii
1.6       schwarze  425: does not assert a prior vertical break, just as it doesn't with
1.11      schwarze  426: .Sq \&Sh .
1.6       schwarze  427: .It
1.14      schwarze  428: The
                    429: .Sq \&na
                    430: .Xr man 7
1.16      schwarze  431: macro in
1.26      jmc       432: .Fl T Ns Cm ascii
1.16      schwarze  433: has no effect.
1.6       schwarze  434: .It
                    435: Words aren't hyphenated.
1.7       schwarze  436: .It
                    437: In normal mode (not a literal block), blocks of spaces aren't preserved,
1.14      schwarze  438: so double spaces following sentence closure are reduced to a single space;
                    439: .Xr groff 1
                    440: retains spaces.
                    441: .It
                    442: Sentences are unilaterally monospaced.
1.6       schwarze  443: .El
1.21      schwarze  444: .Ss HTML/XHTML Compatibility
1.17      schwarze  445: .Bl -bullet -compact
                    446: .It
                    447: The
1.20      schwarze  448: .Sq \efP
                    449: escape will revert the font to the previous
                    450: .Sq \ef
                    451: escape, not to the last rendered decoration, which is now dictated by
1.25      jmc       452: CSS instead of hard-coded.
                    453: It also will not span past the current scope,
                    454: for the same reason.
                    455: Note that in
1.20      schwarze  456: .Sx ASCII Output
                    457: mode, this will work fine.
                    458: .It
                    459: The
1.17      schwarze  460: .Xr mdoc 7
                    461: .Sq \&Bl \-hang
                    462: and
                    463: .Sq \&Bl \-tag
                    464: list types render similarly (no break following overreached left-hand
                    465: side) due to the expressive constraints of HTML.
                    466: .It
                    467: The
                    468: .Xr man 7
                    469: .Sq IP
                    470: and
                    471: .Sq TP
                    472: lists render similarly.
                    473: .El
1.1       kristaps  474: .Sh SEE ALSO
1.25      jmc       475: .Xr man 7 ,
1.1       kristaps  476: .Xr mandoc_char 7 ,
1.25      jmc       477: .Xr mdoc 7
1.1       kristaps  478: .Sh AUTHORS
                    479: The
                    480: .Nm
1.10      schwarze  481: utility was written by
1.29      schwarze  482: .An Kristaps Dzonsons Aq kristaps@bsd.lv .
1.17      schwarze  483: .Sh CAVEATS
1.20      schwarze  484: The
1.26      jmc       485: .Fl T Ns Cm html
1.21      schwarze  486: and
1.26      jmc       487: .Fl T Ns Cm xhtml
1.20      schwarze  488: CSS2 styling used for
1.26      jmc       489: .Fl m Ns Cm doc
1.22      schwarze  490: input lists does not render properly in older browsers, such as Internet
                    491: Explorer 6 and earlier.
1.20      schwarze  492: .Pp
1.17      schwarze  493: In
1.26      jmc       494: .Fl T Ns Cm html
1.21      schwarze  495: and
1.26      jmc       496: .Fl T Ns Cm xhtml ,
1.17      schwarze  497: the maximum size of an element attribute is determined by
                    498: .Dv BUFSIZ ,
1.25      jmc       499: which is usually 1024 bytes.
                    500: Be aware of this when setting long link
1.26      jmc       501: formats such as
                    502: .Fl O Ns Cm style Ns = Ns Ar really/long/link .
1.20      schwarze  503: .Pp
                    504: The
1.26      jmc       505: .Fl T Ns Cm html
1.21      schwarze  506: and
1.26      jmc       507: .Fl T Ns Cm xhtml
1.21      schwarze  508: output modes don't render the
1.20      schwarze  509: .Sq \es
                    510: font size escape documented in
                    511: .Xr mdoc 7
                    512: and
                    513: .Xr man 7 .
1.22      schwarze  514: .Pp
                    515: Nesting elements within next-line element scopes of
1.26      jmc       516: .Fl m Ns Cm an ,
1.22      schwarze  517: such as
                    518: .Sq br
                    519: within an empty
                    520: .Sq B ,
                    521: will confuse
1.26      jmc       522: .Fl T Ns Cm html
1.22      schwarze  523: and
1.26      jmc       524: .Fl T Ns Cm xhtml
1.23      schwarze  525: and cause them to forget the formatting of the prior next-line scope.
                    526: .Pp
                    527: The
                    528: .Sq i
                    529: macro in
1.26      jmc       530: .Fl m Ns Cm an
1.23      schwarze  531: should italicise all subsequent text if a line argument is not provided.
                    532: This behaviour is not implemented.
1.24      schwarze  533: The
                    534: .Sq \(aq
                    535: control character is an alias for the standard macro control character
                    536: and does not emit a line-break as stipulated in GNU troff.