home *** CD-ROM | disk | FTP | other *** search
/ Caldera Network Desktop 1.0 / caldera-network-desktop-1.0.bin / doc / HOWTO / mini / Man-Page < prev    next >
Text File  |  1995-10-14  |  32KB  |  798 lines

  1.  
  2.                        THE LINUX MAN-PAGE-HOWTO
  3.  
  4.    Copyright 1995 by Jens Schweikhardt <jens@kssun3.rus.uni-stuttgart.de>
  5.             See further information on copying conditions below.
  6.  
  7.                      Last update: September 1995
  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.  Beware of name clashes with existing programs, functions or file names.
  106.  It is certainly a bad idea to write yet another editor and call it
  107.  ed, sed (for smart ed) or red (for Rocky's ed). By making sure your
  108.  program's name is unique you avoid that someone executes your program
  109.  and reads someone else's man page or vice versa. Checking out the lsm
  110.  database on a program name is a place to start doing so.
  111.  
  112.  Now we know the name to give our file. The next decision is which
  113.  directory it will finally get installed (say, when the user runs
  114.  `make install' for your package.)  On Linux, all man pages are
  115.  below directories mentioned in the environment variable MANPATH. The
  116.  doc related tools use it quite similar like the shell uses PATH to
  117.  locate executables. In fact, MANPATH has the same format as PATH.
  118.  Both hold a colon separated list of directories (with the exception
  119.  that MANPATH does not allow empty fields and relative pathnames but
  120.  has absolute names only.) If MANPATH is not set or not exported, a
  121.  default will be used that contains at least the /usr/man directory.
  122.  To speed up the search and to keep directories small, the directories
  123.  specified by MANPATH (the so called base directories) contain a bunch
  124.  of subdirectories named `man<s>' where <s> stands for the one character
  125.  section introduced in the table above. Not all of the sections may
  126.  be represented by a subdirectory because there simply is no reason to
  127.  keep an empty `mano' subdirectory. However, there may be directories
  128.  named `cat<s>', `dvi<s>' and `ps<s>' which hold documentation that is
  129.  ready to display or print. More on this later.  The only other file
  130.  in any base directory should be a file named `whatis'. The purpose
  131.  and creation of this file will also be described under paragraph 11).
  132.  The safest way to have a man page for section <s> installed in
  133.  the right place is to put it in the directory /usr/man/man<s>. A good
  134.  Makefile, however, will allow the user to chose a base directory, by
  135.  means of a make variable, MANDIR, say. Most of the GNU packages can be
  136.  configured with the --prefix=/what/ever option. The manuals will then
  137.  be installed under the base directory /what/ever/man. I suggest you
  138.  also provide a way to do something similar.
  139.  
  140.    With the advent of the Linux File System Standard (FS-Stnd), things
  141.    became more complicated. The FS-Stnd 1.2 states that "Provisions must
  142.    be made in the structure of /usr/man to support manual pages which
  143.    are written in different (or multiple) languages." This is achieved
  144.    by introducing another directory level that distinguishes between
  145.    different languages. Quoting again from FS-Stnd 1.2:
  146.  
  147.    "This naming of language subdirectories of /usr/man is based on
  148.    Appendix E of the POSIX 1003.1 standard which describes the locale
  149.    identification string -- the most well accepted method to describe
  150.    a cultural environment. The <locale> string is:
  151.  
  152.        <language>[_<territory>][.<character-set>][,<version>]"
  153.  
  154.    (See the FS-Stnd for a few common <locale> strings.)
  155.    According to these guidelines, we have our man pages in
  156.    /usr/man/<locale>/man[1-9lno]. The formatted versions should then be
  157.    in /usr/man/<locale>/cat[1-9lno] of course, otherwise we could only
  158.    provide them for a single locale.
  159.  
  160.    HOWEVER, I can not recommend switching to that structure at this time.
  161.    The FS-Stnd 1.2 also allows that "Systems which use a unique language
  162.    and code set for all manual pages may omit the <locale> substring and
  163.    store all manual pages in <mandir>. For example, systems which only
  164.    have English manual pages coded with ASCII, may store manual pages
  165.    (the man[1-9] directories) directly in /usr/man. (That is the traditional
  166.    circumstance and arrangement in fact.)"
  167.  
  168.    I would not switch until all tools (like xman, tkman, info and many
  169.    others that read man pages) can cope with the new structure.
  170.  
  171.  
  172.  2)   How should a formatted man page look like?
  173.  ===============================================
  174.  
  175.  Let me present you an example. Below I will explain it in detail.
  176.  Due to the nature of this document, it can't show the different typefaces
  177.  (bold and italics). Please refer to the paragraph "What are the font
  178.  conventions?" for further explanations.
  179.  
  180.  Here comes the man page for the (hypothetical) foo program. 
  181.  
  182.  
  183.  
  184. FOO(1)                     User Manuals                    FOO(1)
  185.  
  186.  
  187. NAME
  188.        foo - frobnicate the bar library
  189.  
  190. SYNOPSIS
  191.        foo [-bar] [-c config-file ] file ...
  192.  
  193. DESCRIPTION
  194.        foo  frobnicates the bar library by tweaking internal sym-
  195.        bol tables. By default it  parses  all  baz  segments  and
  196.        rearranges  them in reverse order by time for the xyzzy(1)
  197.        linker to find them. The symdef entry is  then  compressed
  198.        using  the WBG (Whiz-Bang-Gizmo) algorithm.  All files are
  199.        processed in the order specified.
  200.  
  201. OPTIONS
  202.        -b     Do not write `busy' to stdout while processing.
  203.  
  204.        -c config-file
  205.               Use the alternate system wide  config-file  instead
  206.               of /etc/foo.conf.  This overrides any FOOCONF envi-
  207.               ronment variable.
  208.  
  209.        -a     In addition to the baz  segments,  also  parse  the
  210.               blurfl headers.
  211.  
  212.        -r     Recursive  mode.  Operates  as fast as lightning at
  213.               the expense of a megabyte of virtual memory.
  214.  
  215. FILES
  216.        /etc/foo.conf
  217.               The system wide configuration file. See foo(5)  for
  218.               further details.
  219.        ~/.foorc
  220.               Per user configuration file. See foo(5) for further
  221.               details.
  222.  
  223. ENVIRONMENT
  224.        FOOCONF
  225.               If non-null the full pathname for an alternate sys-
  226.               tem wide foo.conf.  Overridden by the -c option.
  227.  
  228. DIAGNOSTICS
  229.        The following diagnostics may be issued on stderr:
  230.  
  231.        Bad magic number.
  232.               The  input file does not look like an archive file.
  233.        Old style baz segments.
  234.               foo can only handle new style baz  segments.  COBOL
  235.               object libraries are not supported in this version.
  236.  
  237. BUGS
  238.        The command name should have been chosen more carefully to
  239.        reflect its purpose.
  240.  
  241. AUTHOR
  242.        Jens Schweikhardt <jens@kssun3.rus.uni-stuttgart.de>
  243.  
  244. SEE ALSO
  245.        bar(1), foo(5), xyzzy(1)
  246.  
  247.  
  248. Linux                       MARCH 1995                          1
  249.  
  250.  
  251.  
  252.  Here's the explanation as I promised.
  253.  
  254.  
  255.       The NAME section
  256.  
  257.  ...is the only required section. Man pages without a name section are
  258.  as useful as refrigerators at the north pole. This section also has
  259.  a standardized format consisting of a comma separated list of program
  260.  or function names followed by a dash followed by a short (usually one
  261.  line) description what functionality the program (function, file) is
  262.  supposed to provide. By means of makewhatis(8) the name sections make
  263.  it into the whatis database files. Makewhatis is the reason why the name
  264.  section must exist and why it must adhere to the format I described. In
  265.  the groff source it must look like
  266.  
  267.      .SH NAME
  268.      foo \- frobnicate the bar library
  269.  
  270.  The \- is of importance here. The backslash is needed to make the dash
  271.  distinct from a hyphenation dash that may appear in either the command
  272.  name or the one line description.
  273.  
  274.  
  275.       The SYNOPSIS section
  276.  
  277.  ...is intended to give a short overview on available program options.
  278.  For functions this sections lists corresponding include files and the
  279.  prototype so the programmer knows the type and number of arguments as
  280.  well as the return type.
  281.  
  282.  
  283.       The DESCRIPTION section
  284.  
  285.  ...gives an eloquent explanation why your sequence of 0s and 1s is worth
  286.  anything at all. Here's where you write down all your knowledge. This is
  287.  the Hall Of Fame. Win other programmer's and user's admiration by making
  288.  this section the source of reliable and detailed information. Explain
  289.  what the arguments are for, the file format, what algorithms do the
  290.  dirty jobs.
  291.  
  292.  
  293.       The OPTIONS section
  294.  
  295.  ...gives a description for any option how it affects program behaviour.
  296.  You knew that, didn't you?
  297.  
  298.  
  299.       The FILES section
  300.  
  301.  ...lists files the program or function uses. For example, configuration
  302.  files, startup files, files the program directly operates on. It is
  303.  a good idea to give the full pathname of these files and to make the
  304.  install process modify the directory part to match user preferences: the
  305.  groff manuals have a default prefix of /usr/local, so they reference
  306.  /usr/local/lib/groff/* by default. However, if you install using
  307.  'make prefix=/opt/gnu' the references in the man page change to
  308.  /opt/gnu/lib/groff/*
  309.  
  310.  
  311.       The ENVIRONMENT section
  312.  
  313.  ...lists all environment variables that affect your program or
  314.  function and tells how, of course. Most commonly the variables will
  315.  hold pathnames, filenames or default options.
  316.  
  317.  
  318.       The DIAGNOSTICS section
  319.  
  320.  ...should give an overview of the most common error messages from your
  321.  program and how to cope with them. There's no need to explain system
  322.  error error messages (from perror(3)) or fatal signals (from psignal(3))
  323.  as they can appear during execution of any program.
  324.  
  325.  
  326.       The BUGS section
  327.  
  328.  ...should ideally be non-existent. If you're brave, you can describe
  329.  here limitations, known inconveniences, features that others may regard
  330.  as misfeatures. If you're not so brave, rename it the TO DO section ;-)
  331.  
  332.  
  333.       The AUTHOR section
  334.  
  335.  ...is nice to have in case there are gross errors in the documentation
  336.  or program behaviour (Bzzt!) and you want to mail a bug report.
  337.  
  338.  
  339.       The SEE ALSO section
  340.  
  341.  ...is a list of related man pages in alphabetical order.
  342.  Conventionally, it is the last section.
  343.  
  344.  
  345.  You are free to invent other sections if they really don't fit in one
  346.  of those described so far.
  347.  
  348.   So how exactly did you generate that man page?
  349.   I expected that question, here's the source, Luke:
  350.  
  351.  
  352. .\" Process this file with
  353. .\" groff -man -Tascii foo.1
  354. .\"
  355. .TH FOO 1 "MARCH 1995" Linux "User Manuals"
  356. .SH NAME
  357. foo \- frobnicate the bar library
  358. .SH SYNOPSIS
  359. .B foo [-bar] [-c
  360. .I config-file
  361. .B ]
  362. .I file
  363. .B ...
  364. .SH DESCRIPTION
  365. .B foo
  366. frobnicates the bar library by tweaking internal
  367. symbol tables. By default it parses all baz segments
  368. and rearranges them in reverse order by time for the
  369. .BR xyzzy (1)
  370. linker to find them. The symdef entry is then compressed
  371. using the WBG (Whiz-Bang-Gizmo) algorithm.
  372. All files are processed in the order specified.
  373. .SH OPTIONS
  374. .IP -b
  375. Do not write `busy' to stdout while processing.
  376. .IP "-c config-file"
  377. Use the alternate system wide
  378. .I config-file
  379. instead of
  380. .IR /etc/foo.conf .
  381. This overrides any
  382. .B FOOCONF
  383. environment variable.
  384. .IP -a
  385. In addition to the baz segments, also parse the
  386. blurfl headers.
  387. .IP -r
  388. Recursive mode. Operates as fast as lightning
  389. at the expense of a megabyte of virtual memory.
  390. .SH FILES
  391. .I /etc/foo.conf
  392. .RS
  393. The system wide configuration file. See
  394. .BR foo (5)
  395. for further details.
  396. .RE
  397. .I ~/.foorc
  398. .RS
  399. Per user configuration file. See
  400. .BR foo (5)
  401. for further details.
  402. .SH ENVIRONMENT
  403. .IP FOOCONF
  404. If non-null the full pathname for an alternate system wide
  405. .IR foo.conf .
  406. Overridden by the
  407. .B -c
  408. option.
  409. .SH DIAGNOSTICS
  410. The following diagnostics may be issued on stderr:
  411.  
  412. Bad magic number.
  413. .RS
  414. The input file does not look like an archive file.
  415. .RE
  416. Old style baz segments.
  417. .RS
  418. .B foo
  419. can only handle new style baz segments. COBOL
  420. object libraries are not supported in this version.
  421. .SH BUGS
  422. The command name should have been chosen more carefully
  423. to reflect its purpose.
  424. .SH AUTHOR
  425. Jens Schweikhardt <jens@kssun3.rus.uni-stuttgart.de>
  426. .SH "SEE ALSO"
  427. .BR bar (1),
  428. .BR foo (5),
  429. .BR xyzzy (1)
  430.  
  431.  
  432.  
  433.  
  434.  
  435.   3) How do I document several programs/functions in a single man page?
  436.      ==================================================================
  437.  
  438.   Many programs (grep, egrep) and functions (printf, fprintf, ...) are
  439.   documented in a single man page. However, these man pages would be
  440.   quite useless if they were only accessible under one name. We can not
  441.   expect a user to remember that the egrep man page is actually the grep
  442.   man page. It is therefore necessary to have the man page available
  443.   under different names. You have several possibilities to achieve this:
  444.  
  445.   1) have identical copies for each name.
  446.   2) connect all man pages using hard links.
  447.   3) symbolic links pointing to the actual man page.
  448.   4) use groff's `source' mechanism provided by the `.so' macro.
  449.  
  450.   The first way is obviously a waste of disk space. The second is not
  451.   recommended because intelligent versions of the catman program can save
  452.   a lot of work by looking at the the file type or contents.  Hard links
  453.   will prevent catman from being clever. (catman's purpose is to format
  454.   all man pages so that they can be displayed more quickly.) The third
  455.   alternative has a slight drawback: if flexibility is a concern, you
  456.   have to be aware that there are file systems that do not support
  457.   symbolic links. The upshot of this is that the Best Thing (TM) is
  458.   using groff's source mechanism.
  459.  
  460.   Here's how to do it:
  461.   If you want to have your man page available under the names `foo' and
  462.   `bar' in section 1, then put the man page in foo.1 and have bar.1 look
  463.   like this:
  464.  
  465.          .so man1/foo.1
  466.  
  467.   It is important to specify the `man1/' directory part as well as the
  468.   file name `foo.1' because when groff is run by the browser it will
  469.   have the manual base directory as its current working directory (cwd)
  470.   and groff interprets .so arguments relative to the cwd.
  471.  
  472.   4)   Which macro package should I use?
  473.   ======================================
  474.  
  475.   There are a number of macro packages especially designed for use in
  476.   writing man pages. Usually they are in the groff macro directory
  477.   /usr/lib/groff/tmac.  The file names are tmac.<something>, where
  478.   <something> is the argument to groff's -m option. Groff will use
  479.   tmac.<something> when it is given the `-m <something>' option. Often
  480.   the blank between `-m' and `<something>' is omitted so we may say
  481.   `groff -man' when we are formatting man pages using the tmac.an
  482.   macro package. That's the reason for the strange name `tmac.an'.
  483.   Besides tmac.an there is another popular macro package, tmac.doc,
  484.   which originated at the University of California at Berkeley. Many
  485.   BSD man pages use it and it seems that UCB has made it its standard
  486.   for documentation.  The tmac.doc macros are much more flexible but
  487.   alas, there are manual browsers that will not use them but always call
  488.   groff -man. For example, all xman programs I have seen will screw up
  489.   on man pages requiring tmac.doc.  So do yourself a favor: use tmac.an
  490.   -- use of any other macro package is considered harmful. Tmac.andoc is
  491.   a pseudo macro package that takes a look at the source and then loads
  492.   either tmac.an or tmac.doc. Actually any man page browser should use
  493.   it but until now not all of them do, so it is best we cling to ye olde
  494.   tmac.an. Anything I tell you from now on and concerning macros only
  495.   holds true for tmac.an.
  496.  
  497.     If you want to use the tmac.doc macros anyway, here is a pointer to
  498.     detailed information on how to use them:
  499.  
  500.                    http://www.bsdi.com/bsdi-man
  501.  
  502.     There is a searchable index form on the page. Enter mdoc and it will
  503.     find you mdoc(7) and mdoc.samples(7), a tutorial sampler for
  504.     writing BSD man pages.
  505.  
  506.   5)   What preprocessors may I use?
  507.   ==================================
  508.  
  509.   Groff comes with at least three preprocessors, tbl, eqn, and pic (on
  510.   some systems they are named gtbl, geqn and gpic.) Their purpose is to
  511.   translate preprocessor macros and their data to regular troff input.
  512.   Tbl is a table preprocessor, eqn is an equations/maths preprocessor
  513.   and pic is a picture preprocessor. Please refer to the man pages for
  514.   more information on what functionality they provide.
  515.  
  516.   To put it in a nutshell: don't write man pages requiring ANY preprocessor.
  517.  
  518.   Eqn will generally produce terrible output for typewriter-like devices,
  519.   unfortunately the type of device 99% of all man pages are viewed on.
  520.   For example, XAllocColor.3x uses a few formulas with exponentiation.
  521.   Due to the nature of typewriter-like devices the exponent will be on
  522.   the same line as the base. N to the power of two appears as `N2'.
  523.  
  524.   Tbl should be avoided because all xman programs I have seen fail
  525.   on them.  Xman 3.1.6 uses the following command to format man pages,
  526.   e.g. signal(7):
  527.  
  528.     gtbl /usr/man/man7/signal.7 | geqn | gtbl | groff -Tascii -man \
  529.     > /tmp/xmana01760 2> /dev/null
  530.  
  531.   which screws up for sources using gtbl, because gtbl output is
  532.   fed again into gtbl. The effect is a man page without your table.
  533.   I don't know if it's a bug or a feature that gtbl chokes on its own
  534.   output or if xman could be a little smarter not using gtbl twice...
  535.   Anyway, if you want a table, format it yourself and put it between
  536.   .nf .fi lines so that it will be left unformatted. You won't have bold
  537.   and italics this way but this beats having your table swallowed any day.
  538.  
  539.   I have yet to see a man page requiring pic preprocessing. But I would
  540.   not like it. As you can see above, xman will not use it and groff will
  541.   certainly do the funky wadakiki on the input.
  542.  
  543.  
  544.  
  545.   6)   Should I distribute source and/or already formatted documentation?
  546.   =======================================================================
  547.  
  548.   Let me give the pros (+) and cons (-) of a few selected possibilities:
  549.   1) Source only:
  550.      + smaller distribution package.
  551.      - inaccessible on systems without groff.
  552.   2) Uncompressed formatted only: 
  553.      + accessible even on systems without groff.
  554.      - the user can't generate a dvi or postscript file.
  555.      - waste of disk space on systems that also handle compressed pages.
  556.   3) Compressed formatted only:
  557.      + accessible even on systems without groff.
  558.      - the user can't generate a dvi or postscript file.
  559.      - which compression format would you use? .Z? .z? .gz? All of them?
  560.   4) Source and uncompressed formatted:
  561.      + accessible even on systems without groff.
  562.      - larger distribution package
  563.      - some systems may expect compressed formatted man pages.
  564.      - redundant information on systems equipped with groff.
  565.  
  566.   IMHO it is best to distribute source only. The argument that it's
  567.   inaccessible on systems without groff does not matter. The 500+ man
  568.   pages of the Linux Documentation Project are source only. The man
  569.   pages of XFree86 are source only. The man pages from the FSF are source
  570.   only. In fact, I have rarely seen software distributed with formatted
  571.   man pages. If any sysadmin is really concerned about having man pages
  572.   accessible then he also has groff installed.
  573.  
  574.  
  575.  
  576.   7)   What are the font conventions?
  577.   ===================================
  578.  
  579.   First of all: don't use direct font operators like \fB \fP etc. Use
  580.   macros which take arguments. This way you avoid a common glitch:
  581.   forgetting the font change at the end of the word and having the bold
  582.   or italic extend up to the next font change. Believe me, it happens
  583.   more often than you think.
  584.  
  585.   The tmac.an macros provide the following type faces:
  586.  
  587.        .B      Bold
  588.        .BI     Bold alternating with italics
  589.        .BR     Bold alternating with Roman
  590.        .I      Italics
  591.        .IB     Italics alternating with bold
  592.        .IR     Italics alternating with Roman
  593.        .RB     Roman alternating with bold
  594.        .RI     Roman alternating with italics
  595.        .SM     Small (scaled 9/10 of the regular size)
  596.        .SB     Small bold (NOT small alternating with bold)
  597.  
  598.   X alternating with Y means that the odd arguments are typeset in X
  599.   while the even arguments are typeset in Y. For example
  600.   .BI "Arg 1 is Bold, " "Arg 2 is Italics, " "and Bold, " "and Italics."
  601.   The double quotes are needed to include white space into an argument.
  602.  
  603.   So much for what's available. Here's how you should make use of the
  604.   different typefaces: (portions shamelessly stolen from man(7))
  605.  
  606.   Although there are many arbitrary conventions for man pages in the
  607.   UNIX world, the existence of several hundred Linux-specific man pages
  608.   defines our standards:
  609.  
  610.   For functions, the arguments are always specified using italics, even
  611.   in the SYNOPSIS section, where the rest of the function is specified
  612.   in bold:
  613.  
  614.       .BI "myfunction(int " argc ", char **" argv );
  615.  
  616.   Filenames are always in italics, except in the SYNOPSIS section, where
  617.   included files are in bold. So you should use
  618.  
  619.       .I /usr/include/stdio.h and
  620.       .B #include <stdio.h>
  621.  
  622.   Special macros, which are usually in upper case, are in bold:
  623.  
  624.       .B MAXINT
  625.  
  626.   When enumerating a list of error codes, the codes are in bold. This
  627.   list usually uses the .TP (paragraph with hanging tag) macro as follows:
  628.  
  629.       .TP
  630.       .B EBADF
  631.       .I fd
  632.       is not a valid file descriptor.
  633.       .TP
  634.       .B EINVAL
  635.       .I fd
  636.       is unsuitable for reading
  637.  
  638.   Any reference to another man page (or to the subject of the current
  639.   man page) is in bold. If the manual section number is given, it is
  640.   given in roman, without any spaces:
  641.  
  642.       .BR man (7)
  643.  
  644.   Acronyms look best when typeset in small type face. So I recommend
  645.       .SM UNIX     .SM ASCII     .SM TAB      .SM NFS      .SM LALR(1)
  646.  
  647.   8)   Polishing your man page
  648.   ============================
  649.  
  650.   Following are some guidelines that increase reliability, readability
  651.   and 'formatability' of your documentation.
  652.  
  653.   + Test examples if they work (use cut and paste to give your shell the
  654.     exact wording from the man page) read output of your command into
  655.     your man page, don't type what you THINK your program will print.
  656.  
  657.   + Proof read, ispell, have someone else read it, especially if you are
  658.     not a native English speaker. The HOWTO you are reading by now has
  659.     not yet passed the latter test. Do you want to volunteer?
  660.  
  661.   + Test your man page: Does groff complain when you format your man page?
  662.     It's nice to have the groff command line in a comment.  Does the
  663.     man(1) command complain when you call `man yourprog'?  Does the way
  664.     how man(1) uses the formatting system produce the expected result?
  665.     Will xman(1x) and tkman(1tk) cope with your manual?  XFree86 3.1
  666.     has xman 3.1.6 - X11R6, it will try to uncompress using
  667.  
  668.         gzip -c -d < %s > %s
  669.         zcat < %s > %s
  670.  
  671.   + Will makewhatis(8) be able to extract the one-line description
  672.     from the NAME section?
  673.  
  674.  
  675.  
  676.   9)  How do I get a plain text man page without all that ^H^_ stuff?
  677.       ===============================================================
  678.  
  679.   Have a look at col(1), col can filter out backspace sequences. Just in
  680.   case you can't wait that long: 
  681.  
  682.   funnyprompt% groff -t -e -mandoc -Tascii manpage.1 | col -bx > manpage.txt
  683.  
  684.   The -t and -e switches tell groff to preprocess using tbl and eqn.
  685.   This is overkill for man pages that don't require preprocessing but it
  686.   doesn't harm apart from a few CPU cycles wasted. On the other hand,
  687.   not using -t when it is actually required does harm: the table is
  688.   terribly formatted.  You can even find out (well, "guess" is a better
  689.   word) what command is needed to format a certain groff document (not
  690.   just man pages) by issuing
  691.  
  692.   funnyprompt% grog /usr/man/man7/signal.7
  693.   groff -t -man /usr/man/man7/signal.7
  694.  
  695.   "Grog" stands for "GROff Guess", and it does what it says--guess, if
  696.   it were perfect we wouldn't need options any more. I've seen it guess
  697.   wrong on macro packages, but never on preprocessors.
  698.  
  699.   Here is a little perl script I wrote that can delete the page headers
  700.   and footers, therefore saving you a few pages when printing long and
  701.   elaborate man pages. Save it in a file named strip-header & chmod 755.
  702.  
  703.     #!/usr/bin/perl -n
  704.     #  make it slurp the whole file at once:
  705.     undef $/; 
  706.     #  delete page breaks:
  707.     s/\n{4}\S.{50,}\n{6}\S.{50,}\n{3}/\n/g;            
  708.     #  delete first header & last footer:
  709.     s/\n\S.{50,}\n//g;
  710.     #  collapse two or more blank lines into a single one:
  711.     s/\n{3,}/\n\n/g;
  712.     #  see what's left...
  713.     print;
  714.  
  715.  You have to use it as the first filter after the 'man' command as it relies
  716.  on the number of newlines being output by groff. For example:
  717.  
  718.     funnyprompt% man bash | strip-headers | col -bx > bash.txt
  719.  
  720.  
  721.  
  722.  10)  How do I get a high quality PostScript man page?
  723.       ===================================================
  724.  
  725.   funnyprompt% groff -t -e -mandoc -Tps manpage.1 > manpage.ps
  726.  
  727.   Print that using your favorite PostScript printer/interpreter.
  728.   See question 9) for explanation of options.
  729.  
  730.  
  731.  
  732.  11)  How do I get `apropos' and `whatis' to work?
  733.       ============================================
  734.  
  735.   Suppose you wonder what compilers are installed on your system and how
  736.   these can be invoked. To answer this (frequently asked) question you say
  737.  
  738.   funnyprompt% apropos compiler
  739.   f77 (1) - Fortran 77 compiler
  740.   gcc (1) - GNU C and C++ compiler
  741.   pc (1) - Pascal compiler
  742.   
  743.   Apropos and whatis are used to give a quick response which man page
  744.   has information on a certain topic. Both programs search a number
  745.   of files named `whatis' that may be found in each of the manual base
  746.   directories.  Like I said before, the whatis data base files contain
  747.   a one line entry for any man page in the respective directory tree. In
  748.   fact, that line is exactly the NAME section (to be precise: joined on
  749.   one line and with hyphenation removed, also note that the section is
  750.   mentioned within parentheses). The whatis data base files are created
  751.   with the makewhatis(8) program. There are several versions around,
  752.   so please refer to the man page what options are available. In order
  753.   for makewhatis to be able to extract the NAME sections correctly it
  754.   is important that you, the manual writer, adhere to the NAME section
  755.   format described under paragraph 2).  The difference between apropos
  756.   and whatis is where in the line and what they are looking for. Apropos
  757.   (which is equivalent to man -k) searches the argument string anywhere on
  758.   the line whereas whatis (equivalent to man -f) tries to match a complete
  759.   command name only on the part before the dash. Consequently, `whatis
  760.   cc' will report if there is a cc manual and remain quiet for gcc.
  761.  
  762.  
  763.                  Corrections and suggestions welcome!
  764.  
  765.  
  766.  
  767.  
  768.  
  769.  A)  Copying conditions
  770.      ==================
  771.  
  772.  Copyright 1995 by Jens Schweikhardt
  773.  <jens@kssun3.rus.uni-stuttgart.de>
  774.  Voice: ++49 7151 690270
  775.  
  776. Unless otherwise stated, Linux HOWTO documents are copyrighted by
  777. their respective authors. Linux HOWTO documents may be reproduced and
  778. distributed in whole or in part, in any medium physical or electronic,
  779. as long as this copyright notice is retained on all copies. Commercial
  780. redistribution is allowed and encouraged; however, the author would like
  781. to be notified of any such distributions.
  782.  
  783. All translations, derivative works, or aggregate works incorporating
  784. any Linux HOWTO documents must be covered under this copyright notice.
  785. That is, you may not produce a derivative work from a HOWTO and impose
  786. additional restrictions on its distribution. Exceptions to these rules
  787. may be granted under certain conditions; please contact the Linux HOWTO
  788. coordinator at the address given below.
  789.  
  790. In short, we wish to promote dissemination of this information through
  791. as many channels as possible. However, we do wish to retain copyright
  792. on the HOWTO documents, and would like to be notified of any plans to
  793. redistribute the HOWTOs.
  794.  
  795. If you have questions, please contact Greg Hankins, the Linux HOWTO
  796. coordinator, at gregh@sunsite.unc.edu via email, or at +1 404 853 9989.
  797.  
  798.