|
|
|
Man pages provide an excellent on-line resource for every Linux user, and this article shows how to built a Man page from scratch - a Man page for using Yahoo! Finance
Forty years ago the first port of call for any Unix user having problems with a program was the Man command, and today the first port of call for any Linux user having problems with a program is still the man command; and that's no wonder - it enables a vast amount of information to be available for both program developers and program users. On top of which, it's very easy for developers to add their own documentation - as this article will show. The Linux Man Page ConventionMan pages generally follow the same convention:
Although Man pages should follow the convention not all of the sections are mandatory, for example:
Creating a Man PageA developer does not need any special software to create a Man page - just a simple text editor and some formatting tags:
With these basic tags a Man page can be written quite quickly: ." Set the title
.TH Yahoo Finance
." Add a header for the name section
.SH NAME
Yahoo Finance Stock Quotes
.SH SYNOPSIS
wget -O [
." put the key words into italics
.I output file
] [
.I url
] [
.I company symbols
] [
.I fields
]
.SH DESCRIPTION
Download Yahoo Finance stock quotes directly into a CSV file.
.SH OPTIONS
." Add a sub-section
.SS FIELDS
." use bold for the field values
.B s
the company symbol
.PP
.B l1
latest stock quote
.PP
.B c1
change in stock value
.PP
.B d1
date of the stock quote
.SH FILES
http://download.finance.yahoo.com/d/quotes.csv
.SH EXAMPLE
."Add some formatted text
.nf
wget -O shares.csv \\
http://download.finance.yahoo.com/d/quotes.csv?s=RHT,MSFT,NOVL\\
&f=sl1c1d1&e=.csv
." End the formatted text
.fi
Testing a Man PageThere are two, very simple, ways to test this new man page:
Linux Man Page LocationsThe directories for storing the man pages will be found in one of two areas:
In the two directories there will be one or more sub-directories, each one named man with a number or a letter for a suffix (for example man1); each of these sub-directories is for a particular type of man page, which may vary from system to system, but typically they are:
Sometimes a letter p may be used as an additional prefix (for example man3p) in which case the sub-directory will contain POSIX versions of the man pages. Not only must the file be placed in the correct directory but it must also be given the correct suffix, for example all files placed in the man1 directory must have a suffix of 1: sudo cp yahoo.txt /usr/local/man/man1/yahoo.1
The new Man page can now be called from the command line just like any other Man page: man yahoo
ConclusionMan pages are very easy to create and to maintain, and by using this simple system program developers will always be able to keep their users completely up to date.
The copyright of the article Creating Linux Man Pages in Linux Programming is owned by Mark Alexander Bain. Permission to republish Creating Linux Man Pages in print or online must be granted by the author in writing.
Comments
Feb 24, 2009 7:31 PM
Guest :
1 Comment:
|
|
|
|
|
|
|
|