UPS/UPD Doc Home page | Computing Division| Fermilab at
Work | Fermilab
Home
|
||||||||||||
![]() |
Complete Guide and Reference Manual for UPS, UPD and UPP v4 | |||||||||||
Chapter 39: Creating and Formatting Man Pages
39.1 Creating the Source Document (Unformatted)
39.1.1 Source File Format
39.1.2 Man Page Information Categories
39.1.3 Example Source File
39.2 Formatting the Source File
39.2.1 nroff
39.2.2 groff
39.3 Converting your Man Page to html Format
Chapter 39: Creating and Formatting Man Pages
In this chapter we show you how to create man pages, format them, and even create html documents from them. This is not a comprehensive man page reference, but it contains sufficient information for most purposes.
For further information, from the UNIX Resources Web page, see "How to Create Man Pages" under Software Development.
- The man pages for a UPS product can go anywhere, as long as the location is specified in the table file. A recommended location is ${UPS_PROD_DIR}/man for the formatted pages and ${UPS_PROD_DIR}/catman for the unformatted pages. The UPS backwards-compatible default, however, is ${UPS_UPS_DIR}/toman/man for the formatted pages and ${UPS_UPS_DIR}/toman/catman for the unformatted pages.
- Man page file names should consist of the product name, a period, and the section number as described in the following note. This applies to both formatted and unformatted files, which are distinguished by residing in separate directories.
- Man pages for commands are generally maintained as section 1, and library and system calls as section 3. The section number should appear as an extension of the man page file name (e.g., hello.1 for the command hello). Here is a full listing of categories by section:
- We recommend using either of the utilities nroff or groff with the -man option to format your man pages in a standard way. These utilities are documented in many standard UNIX texts, and you can also find man pages for them.
39.1 Creating the Source Document (Unformatted)
39.1.1 Source File Format
We recommend writing man pages in the source form using simple macros from the nroff macro package -man. Most of these macros require a dot (.) in the first column. The following list of macros is sufficient for writing standard man pages:
Title Heading; specify product name, man page section (usually 1), and date, in this order, to produce a man page format of this type:
Section Heading; if no blanks in text, quotes are not needed.
Subsection Heading; if no blanks in text, quotes are not needed.
Starts an indented paragraph where "item" is put to the left of it; if no blanks in "item", quotes are not needed.
Starts a paragraph with a hanging indent; i.e. lines after the first are indented
Bold; if no blanks in text, quotes are not needed.
Italic; this shows up as underlined on most terminals. If no blanks in text, quotes are not needed.
Term/paragraph format; columns specify how many columns to allocate to the term column. As an example, this input:
produces this output under nroff -man:
where "is" starts in column 6. Notice that the first .TP sets the column value of the term, and the second one picks it up.
Nofill (used to suppress normal line filling; used for preformatted text)
Fill (used to resume normal line filling, usually after a .nf)
39.1.2 Man Page Information Categories
Categories of information that you may want to include as section headings (.SH) are:
This should be the product name followed by a short description. The text on this line is also used as the keyword list for man -k and apropos.
Document here the complete syntax of the command used to invoke the product.
Document here the OS flavors for which the program is available.
Document here a full but succinct description of the use of the product.
Document here all the options available for the invoking command.
Document here situations in which the program can be used, if there are uses that are not obvious.
Document here any information the user should be aware of when using the command.
Document here all errors and other messages returned to the user. Include the cause and the recovery actions whenever appropriate and possible.
Document here the product coordinator and/or the major developers and contributors, along with their particular areas of expertise, as appropriate.
Document here the significant changes in each release of the product.
If your product is designed to work under X windows, document here any X resources that affect the product's behavior.
Document here all files, or at least their directories if there are too many files. Also mention here any files in the user's home area that are needed/accessed (e.g., $HOME/.mh_profile, $HOME/Mail/components for the mh and exmh products).
Document here things that do not (yet!) work as designed. Provide work-arounds whenever possible.
Document here things that work as designed but which may be unclear or surprising to the user. (This is the System V replacement for the BUGS category; you too can pretend your product has no bugs!)
Document here other related commands and manual sections, especially if not obvious.
39.1.3 Example Source File
In section 17.1.5 we presented a simple example for the product hello showing how to create a formatted man page from a simple unformatted nroff input file. We will expand upon it here to illustrate the macros listed above. The nroff source is created in $HELLO_DIR/man/hello.1. Sample contents:
hello - print "Hello world" on stdout
hello prints the string "Hello world" on standard output.
39.2 Formatting the Source File
39.2.1 nroff
To create an ascii-formatted man page, you can run the utility nroff with the -man macro package as follows:
% nroff -man <input_file> > <output_file>We recommend following the prescription for unformatted and formatted man page locations as stated above and in section 16.3. This ensures that the source file always gets run through the formatter and the formatted file is never run through it again, which would produce odd results. First, cd to the source file directory:
% cd $HELLO_DIR/manThe following command creates the formatted man page for our hello example in the correct directory:
% nroff -man hello.1 > ../catman/hello.1Once it is formatted, the example above will look like this:
hello - print "Hello world" on stdout
hello [options] option option [" -yy -zz ..."]
hello prints the string "Hello world" on standard output.
39.2.2 groff
You can also use groff to format your man page source file. You must setup groff before use (not necessary for nroff). The command:
% groff -man -Tascii <input_file> > <ascii_output_file>produces ascii-formatted man pages (the same output as the nroff command above). If you want to produce a PostScript output file, enter:
% groff -man <input_file> > <ps_output_file>39.3 Converting your Man Page to html Format
An ascii-formatted man page can be run through the utility man2html and then accessed via a Web browser. First setup conv2html, then run the command:
% man2html -title '<manpage_title>' < <ascii_output_file> > <html_file>
UPS/UPD Doc Home page | Computing Division| Fermilab at
Work | Fermilab
Home
|
|||||||||||
This page generated on: 10/15/02 14:10:18