Online Book Reader

Home Category

Running Linux, 5th Edition - Matthias Kalle Dalheimer [374]

By Root 1331 0
.TP request; the line after .TP is the tag, after which follows the item text itself. For example, the source on lines 12 to 14:

.TP

\fB-h\fP

Brew hot coffee. Cold is the default.

will appear as the following in the output:

-h Brew hot coffee. Cold is the default.

You should document each command-line option for your program in this way.

Lines 23 to 26 make up the FILES section of the manual page, which describes any files the command might use to do its work. A tagged list using the .TP request is used for this as well.

On lines 27 and 28, the SEE ALSO section is given, which provides cross references to other manual pages of note. Notice that the string "SEE ALSO" following the .SH request on line 27 is in quotation marks; this is because .SH uses the first whitespace-delimited argument as the section title. Therefore, any section titles that are composed of more than one word need to be enclosed in quotation marks to make up a single argument. Finally, on lines 29 and 30, the BUGS section is presented.

Formatting and Installing the Manual Page

To format this manual page and view it on your screen, use the following command:

eggplant$ groff -Tascii -man coffee.man | more

The -Tascii option tells groff to produce plain-ASCII output; -man tells groff to use the manual-page macro set. If all goes well, the manual page should be displayed:

COFFEE(1) COFFEE(1)

NAME

coffee - Control remote coffee machine

SYNOPSIS

coffee [ -h | -b ] [ -t type ] amount

DESCRIPTION

coffee queues a request to the remote coffee machine at

the device /dev/cf0. The required amount argument speci-

fies the number of cups, generally between 0 and 12 on ISO

standard coffee machines.

Options

-h Brew hot coffee. Cold is the default.

-b Burn coffee. Especially useful when executing cof-

fee on behalf of your boss.

-t type

Specify the type of coffee to brew, where type is

one of colombian, regular, or decaf.

FILES

/dev/cf0

The remote coffee machine device

SEE ALSO

milk(5), sugar(5)

BUGS

May require human intervention if coffee supply is

exhausted.

As mentioned before, groff is capable of producing other types of output. Using the -Tps option in place of -Tascii produces PostScript output that you can save to a file, view with Ghostview, or print on a PostScript printer. -Tdvi produces device-independent .dvi output similar to that produced by TEX.

If you wish to make the manual page available for others to view on your system, you need to install the groff source in a directory that is present on the users' MANPATH. The location for standard manual pages is /usr/share/man, although some systems also use /usr/man or /usr/local/man. The source for section 1 manual pages should therefore go in /usr/man/man1. The command:

eggplant$ cp coffee.man /usr/man/man1/coffee.1

installs this manual page in /usr/man for all to use (note the use of the .1 filename extension, instead of .man). When man coffee is subsequently invoked, the manual page will be automatically reformatted, and the viewable text saved in /usr/man/ cat1/coffee.1.gz.

If you can't copy manual page sources directly to /usr/man, you can create your own manual page directory tree and add it to your MANPATH. See the section "Manual Pages" in Chapter 4.

Texinfo

Texinfo is a text-formatting system used by the GNU Project to produce both online documentation in the form of hypertext Info pages, and printed manuals through TEX from a single-source file. By providing Texinfo source, users can convert the documentation to Info, HTML, DVI, PostScript, PDF, or plain text files.

Texinfo is documented completely through its own Info pages, which are readable within Emacs (using the C-h i command) or a separate Info reader, such as info. If the GNU Info pages are installed in your system, complete Texinfo documentation is contained therein. Just as you'll find yourself using groff to write a manual page, you'll use Texinfo to write an Info document.

Writing the Texinfo Source

In this section, we present a simple Texinfo

Return Main Page Previous Page Next Page

®Online Book Reader