home *** CD-ROM | disk | FTP | other *** search
/ BURKS 2 / BURKS_AUG97.ISO / BURKS / LINUX / HOWTO / mini / manpage.txt < prev    next >
Text File  |  1997-07-07  |  32KB  |  805 lines

  1.  
  2.                        THE LINUX MAN-PAGE-HOWTO
  3.  
  4.       Copyright 1995,96,97 by Jens Schweikhardt <schweikh@noc.dfn.de>
  5.             See further information on copying conditions below.
  6.  
  7.                          Last update: March 1997
  8.                    Corrections and suggestions welcome!
  9.  
  10.    This HOWTO explains what you should bear in mind when you are going
  11.    to write on-line documentation -- a so called man page -- that you
  12.    want to make accessible via the man(1) command.
  13.  
  14.    Throughout this HOWTO, a manual entry is simply referred to as a
  15.    man page, regardless of actual length and without sexist intention.
  16.  
  17.    Table of contents:
  18.    ------------------
  19.  
  20.    0)  A few thoughts on documentation
  21.    1)  How are man pages accessed?
  22.    2)  How should a formatted man page look like?
  23.    3)  How do I document several programs/functions in a single man page?
  24.    4)  Which macro package should I use?
  25.    5)  What preprocessors may I use?
  26.    6)  Should I distribute source and/or already formatted documentation?
  27.    7)  What are the font conventions?
  28.    8)  How do I polish my man page?
  29.    9)  How do I get a plain text man page without all that ^H^_ stuff?
  30.   10)  How do I get a high quality PostScript man page?
  31.   11)  How do I get apropos and whatis to work?
  32.  
  33.    A)  Copying conditions
  34.  
  35.  
  36.  
  37.  0)   A few thoughts on documentation
  38.  ====================================
  39.  
  40.  Why do we write documentation? Silly question. Because we want others to
  41.  be able to use our program, library function or whatever we have written
  42.  and made available. But writing documentation is not all there is to it:
  43.  
  44.  + documentation must be accessible.
  45.    If it's hidden in some non-standard place where the documentation
  46.    related tools won't find it -- how can it serve its purpose?
  47.  
  48.  + documentation must be reliable and accurate.
  49.    There's nothing more annoying than having program behaviour and
  50.    documentation disagree. Users will curse you, send you hate mail and
  51.    throw your work into the bit bucket, with the firm intent to never
  52.    install anything written by that jerk again.
  53.  
  54.  The historical and well known way documentation is accessed on UNIX
  55.  is via the man(1) command. This HOWTO describes what you have to do to
  56.  write a man page that will be correctly processed by the documentation
  57.  related tools. The most important of these tools are man(1), xman(1x),
  58.  apropos(1), makewhatis(8) and catman(8).
  59.  
  60.  Reliability and accuracy of the information are, of course, up to you.
  61.  But even in this respect you will find some ideas below that help you
  62.  avoid some common glitches.
  63.  
  64.  1)   How are man pages accessed?
  65.  ================================
  66.  
  67.  You need to know the precise mechanism how man pages are accessed
  68.  in order to give your man page the right name and install it in the
  69.  right place.  Any man page belongs to a specific section, which is
  70.  denoted by a single character. The most common sections under Linux
  71.  and their human readable names are
  72.  
  73.  Section   The human readable name
  74.  
  75.     1      User commands that may be started by everyone.
  76.     2      System calls, that is, functions provided by the kernel.
  77.     3      Subroutines, that is, library functions.
  78.     4      Devices, that is, special files in the /dev directory.
  79.     5      File format descriptions, e.g. /etc/passwd.
  80.     6      Games, self-explanatory.
  81.     7      Miscellaneous, e.g. macro packages, conventions.
  82.     8      System administration tools that only root can execute.
  83.     9      Another (Linux specific) place for kernel routine documentation.
  84.     n      New documentation, that may be moved to a more appropriate section.
  85.     o      Old documentation, that may be kept for a grace period.
  86.     l      Local documentation referring to this particular system.
  87.  
  88.  The name of the source file for a man page (the input to the formatting
  89.  system) is the name of the command, function or file name, followed by
  90.  a dot, followed by the section. If you write the documentation on the
  91.  format of the `passwd' file you have to name the source file `passwd.5'.
  92.  Here we also have an example of a file name that is the same as a
  93.  command name. There might be even a library subroutine named passwd.
  94.  Sectioning is the usual way to resolve these ambiguities: The command
  95.  description is found in the file `passwd.1' and the hypothetical
  96.  library subroutine in `passwd.3'.
  97.  
  98.    Sometimes additional characters are appended and the file name looks
  99.    for example like `xterm.1x' or `wish.1tk'. The intent is to indicate
  100.    that this is documentation for an X Window program or a Tk application,
  101.    respectively. Some manual browsers can make use of this additional
  102.    information. For example xman will use `xterm(x)' and `wish(tk)' in
  103.    the list of available documentation.
  104.  
  105.    Please don't use the n, o and l sections; according to the File System
  106.    Standard these sections are deprecated. Stick to the numeric sections.
  107.  
  108.  Beware of name clashes with existing programs, functions or file names.
  109.  It is certainly a bad idea to write yet another editor and call it
  110.  ed, sed (for smart ed) or red (for Rocky's ed). By making sure your
  111.  program's name is unique you avoid that someone executes your program
  112.  and reads someone else's man page or vice versa. Checking out the lsm
  113.  database on a program name is a place to start doing so.
  114.  
  115.  Now we know the name to give our file. The next decision is which
  116.  directory it will finally get installed (say, when the user runs
  117.  `make install' for your package.)  On Linux, all man pages are
  118.  below directories mentioned in the environment variable MANPATH. The
  119.  doc related tools use it quite similar like the shell uses PATH to
  120.  locate executables. In fact, MANPATH has the same format as PATH.
  121.  Both hold a colon separated list of directories (with the exception
  122.  that MANPATH does not allow empty fields and relative pathnames but
  123.  has absolute names only.) If MANPATH is not set or not exported, a
  124.  default will be used that contains at least the /usr/man directory.
  125.  To speed up the search and to keep directories small, the directories
  126.  specified by MANPATH (the so called base directories) contain a bunch
  127.  of subdirectories named `man<s>' where <s> stands for the one character
  128.  section introduced in the table above. Not all of the sections may
  129.  be represented by a subdirectory because there simply is no reason to
  130.  keep an empty `mano' subdirectory. However, there may be directories
  131.  named `cat<s>', `dvi<s>' and `ps<s>' which hold documentation that is
  132.  ready to display or print. More on this later.  The only other file
  133.  in any base directory should be a file named `whatis'. The purpose
  134.  and creation of this file will also be described under paragraph 11).
  135.  The safest way to have a man page for section <s> installed in
  136.  the right place is to put it in the directory /usr/man/man<s>. A good
  137.  Makefile, however, will allow the user to chose a base directory, by
  138.  means of a make variable, MANDIR, say. Most of the GNU packages can be
  139.  configured with the --prefix=/what/ever option. The manuals will then
  140.  be installed under the base directory /what/ever/man. I suggest you
  141.  also provide a way to do something similar.
  142.  
  143.    With the advent of the Linux File System Standard (FS-Stnd), things
  144.    became more complicated. The FS-Stnd 1.2 states that "Provisions must
  145.    be made in the structure of /usr/man to support manual pages which
  146.    are written in different (or multiple) languages." This is achieved
  147.    by introducing another directory level that distinguishes between
  148.    different languages. Quoting again from FS-Stnd 1.2:
  149.  
  150.    "This naming of language subdirectories of /usr/man is based on
  151.    Appendix E of the POSIX 1003.1 standard which describes the locale
  152.    identification string -- the most well accepted method to describe
  153.    a cultural environment. The <locale> string is:
  154.  
  155.        <language>[_<territory>][.<character-set>][,<version>]"
  156.  
  157.    (See the FS-Stnd for a few common <locale> strings.)
  158.    According to these guidelines, we have our man pages in
  159.    /usr/man/<locale>/man[1-9lno]. The formatted versions should then be
  160.    in /usr/man/<locale>/cat[1-9lno] of course, otherwise we could only
  161.    provide them for a single locale.
  162.  
  163.    HOWEVER,