\def{"man::synstyle"}{long}
\def{"man::defstyle"}{long}

\import{man.zmm}
\import{zoem.zmm}

\set{"man::name"}{pud-man}
\set{"man::html-title"}{The PUD manual page mini-language}
\set{"man::author"}{Stijn van Dongen}
\set{"man::section"}{7}

\"man::preamble"
\${html}{\"man::maketoc"}

\sec{name}{NAME}
\NAME{pud-man}{A description of the Portable Unix Documentation Language for writing manual pages}

\sec{description}{DESCRIPTION}

\par{
   This document describes the Portable Unix Documentation (PUD) manual
   page mini-language. PUD-man is built on top of the macro interpreter
   zoem. A PUD document is generally well-structured, relatively free of
   formatting statements, compact to write and easily extendable. It can
   be converted to both troff and html, for viewing in terminals and
   browsers. High quality Postscript and plain text formats can be derived
   from the troff output.}

\par{
   Write your own manual pages by copying the example page
   \lref{buzzz.azm}{buzzz.azm}
   and modifying it to your needs. If you are documenting \it{foo},
   the usual approach is to create \it{foo.azm}, and from that
   create \it{foo.1} and \it{foo.html} as follows:}

\verbatim{\
   zoem -i foo -d html
   zoem -i foo -d html
   zoem -i foo -d roff -o foo.1
   zoem -i foo -d roff -o foo.1}
 
 \car{
   This generates files foo.html and foo.1.
   Each device is run twice to be certain that references
   are found and linked. PostScript and text versions
   can be made from \v{foo.1} as follows:}

\verbatim{\
   groff -man foo.1 > foo.ps
   groff -t -e -mandoc -Tascii foo.1 | col -bx > foo.txt}

\par{
   Note though that \v{foo.1} does not use any groff specific
   extensions; it should be acceptable input to ancient roffs as well,
   exceptions imply a bug in the PUD man macros.}

\par{
   The PUD manual page macro package
   automatically imports a set of generic macros from the
   pud-base and pud-ref packages.  The \sibref7{pud-base}
   and \sibref7{pud-ref} manual pages
   document those macros, which are also essential for writing manual
   pages. The most important are}


\begin{itemize}{
   {compact}{1}
   {mark}{\*{bullet}}
   {type}{roman}
   {rp}{)}
   {align}{right}
}
\item
\car{
   The \it{itemize} environment
   (used as \mc{begin{itemize}[{options}] ... \\end{itemize}})
   and its associated macros
   \mc{item#1}, \mc{items#1}, \mc{item}
   \mc{itemskip}, \mc{intermezzo}, and others.}

\item
\car{
   The font style/appearance macros \mc{bf#1}, \mc{it#1}, \mc{tt#1},
   \mc{v#1},
   the font size macros \mc{ftinc#2} and \mc{ftdec#2}.}

\item
\car{
   The paragraph mark \mc{par} (required for each paragraph).}

\item
\car{
   The verbatim macros \mc{verbatim#1} and \mc{verbatix#1}.}

\item
\car{
   The link macros \mc{httpref#1}, \mc{sibref#2}, \mc{iref#2},
   \mc{lref#2}, \mc{aref#2}.}

\item
\car{
   In \sibref7{pud-ref} the pair of \mc{reference#2} and \mc{refer#1}.}

\end{itemize}

\par{
   For the authorative listing consult the \sibref{pud-base}{pud-base}
   manual page.  The listing above includes a silly demonstration of some
   itemize features such as alignment and automatic numbering.  Read the
   \sibref{../doc/zum}{Zoem User Manual} for a better understanding of
   zoem macro packages and the design of zoem.}

\sec{macros}{MACROS}

\begin{itemize}

\items{
   {\defmac{"man::author"}}
   {\defmac{"man::day"}}
   {\defmac{"man::html-title"}}
   {\defmac{"man::month"}}
   {\defmac{"man::name"}}
   {\defmac{"man::section"}}
   {\defmac{"man::cat"}}
   {\defmac{"man::tag"}}
   {\defmac{"man::year"}}
}
   These have to be set to appropriate values before the
   macro \mc{"man::preamble"} is used.
   See the example page \lref{buzzz.azm}{buzzz.azm}.

\par
   The \mc{"man::cat"} macro can be used to set the centered heading
   found in all UNIX roff manual pages. If not set, a heading is
   derived from the \mc{"man::section"} macro.
   Below is the listing of default headers. It can probably be improved.

\verbatim{\:/
      1     USER COMMANDS
      2     SYSTEM CALLS
      3     LIBRARY CALLS
      4     SPECIAL FILES
      5     FILE FORMATS
      6     GAMES
      7     MACRO PACKAGES
      8     SYSTEM ADMINISTRATION
      9     KERNEL ROUTINES}

\items{
   {\defmac{"man::preamble"}}
   {\defmac{"man::postamble"}}
}
   Before any text or macro resulting in output occurs, the
   macro \mc{"man::preamble"} has to be used.
   This macro may certainly be preceded by \mc{def#2} uses
   and variants thereof. See the macros listed in the
   previous entry and the example page \lref{buzzz.azm}{buzzz.azm}.

\par
   The last textual item in a manual page must be the macro
   \mc{"man::postamble"}.
   See the example page \lref{buzzz.azm}{buzzz.azm}.

\items{
   {\defmac{sec#2}}
   {\defmac{secref#1}}
}
   Start a section, refer to a section.  The first argument of \mc{sec#2} is
   the anchor for that section, the second argument is the title.  The macro
   \mc{secref#1} takes an anchor and outputs the title of the associated
   section.

\par
   The NAME section should be written like the example below, taken
   from the zoem interpreter manual.

\verbatim{\protect{
\sec{name}{NAME}
\NAME{zoem}{interpreter for the Zoem macro/programming language.}}}

\car{
   Usage of the NAME macro ensures that the troff output
   complies with the format expected by \bf{apropos}.}

\items{
   {\defmac{defopt#2}}
   {\defmac{defopt#3}}
   {\defmac{defkvp#3}}
}
\car{
   Write entry in the options section.  typical usage is within an \mc{item#1}
   macro.  For all macros the first argument is the option being described,
   and the last argument is a short string describing the option.  This string
   is printed in case the macro \mc{"man::defstyle"} is set to \v{long}.  The
   macro \mc{defopt#3} is used for options taking arguments; the second
   argument is the name describing the argument.
   The macro \mc{defkvp#3} is used for long options of the form
   \v{--mode=str}, which you would enter as
   \mc{defkvp{mode}{str}{set foo mode}}. Long options of the form
   \v{--verbose} are simply entered using \mc{defopt#2}.}

\item{\defmac{optref#2}}
\car{
   Refer to an option. The first argument is the option, the second argument
   is the text associated with the link. This text will indeed be linking
   in html, but nothing special will happen in troff - the text is printed
   as is.}

\items{
   {\defmac{synoptopt#2}}
   {\defmac{synoptopt#3}}
   {\defmac{synreqopt#2}}
   {\defmac{synreqopt#3}}
}
   Write entries in the synopsis section. This assumes that somewhere
   an option was created using one of the \v{defopt} family members
   described below.

\par{
   For all 'syn' options the first argument is simply the option itself.  From
   this argument the anchor is reconstructed that was created by one of the
   \v{defopt} macros.  The last argument is always a short string describing
   the option. It depends on the style chosen, i.e. whether
   \mc{"man::synstyle"} is \v{long} or \v{short}, whether this string shows up
   or not.  The macros in this group that take two arguments describe unary
   options that take no argument. The macros taking three arguments describe
   options that do take an argument.}

\par{
   Here is an example from the zoem manual page:}

\verbatim{\
\\synoptopt{--trace}{trace mode, default}
\\synoptopt{--trace-all-long}{long trace mode}
\\synoptopt{--trace-all-short}{short trace mode}
\\synoptopt{--trace-regex}{trace regexes}
\\synoptopt{--show-tracebits}{show trace bits}
\\synoptopt{-trace}{k}{trace mode, explicit}
\\synoptopt{--stats}{show symbol table stats after run}}

\items{
   {\defmac{"man::synstyle"}}
   {\defmac{"man::defstyle"}}
}
\car{
   Before importing the manual macros, set these to your prefered
   style. Each of these should be set either to \v{short} or \v{long}.}

\items{
   {\defmac{genopt#1}}
   {\defmac{genopt#2}}
   {\defmac{genarg#1}}
   {\defmac{useopt#1}}
   {\defmac{useopt#2}}
   {\defmac{usearg#1}}
   {\defmac{genkvp#2}}
   {\defmac{usekvp#2}}
}
\car{
   These are for creating a consistent style when refering to options.  One is
   free to disregard these altogether. They are meant as convenience, but some
   may find the extra typing annoying.}

\par{
   The idea is that the 'gen' macros are used when generic mention is
   made of an option and possibly its argument.
   The 'use' macros are used when explicit usage is mentioned.
   An example is the following:}
   
\begin{spacing}{
   {left}{3}
}
\car{
   Modes can be chosen using \genopt{-mode}{str} where \genarg{str} is any of
   \usearg{small}, \usearg{medium}, or \usearg{large}. Use
   \useopt{-mode}{small} if your hardware is outdated.}

\par{
   Use \genkvp{--milage}{str} to set the milage, e.g. \usekvp{--milage}{high}
   or \usekvp{--milage}{astronomical}.}

\end{spacing}

\end{itemize}

\sec{seealso}{SEE ALSO}

\par{
   The \sibref{pud} manual page gives an overview of PUD.}

\"man::postamble"

