help2man is a tool for automatically generating simple manual pages from program output.
Although manual pages are optional for GNU programs other projects, such as Debian require them (see Man Pages)
This program is intended to provide an easy way for software authors to include a manual page in their distribution without having to maintain that document.
Given a program which produces reasonably standard `--help' and `--version' outputs, help2man can re-arrange that output into something which resembles a manual page.
The format for running the help2man program is:
help2man [option]... executable
help2man supports the following options:
By default (for want of anything better) this paragraph contains `manual page for program version'.
This option overrides an include file `[name]' section
(see Including text).
stdout.
By default help2man passes the standard `--help' and `--version' options to the executable although alternatives may be specified using:
Here are some recommendations for what to include in your --help output. Including these gives help2man the best chance at generating a respectable man page, as well as benefitting users directly.
See Command-Line Interfaces, and Man Pages, for the official GNU standards relating to --help and man pages.
Usage: cp [OPTION]... SOURCE DEST
or: cp [OPTION]... SOURCE... DIRECTORY
...
Use argv[0] for the program name in these synopses, just as it
is, with no directory stripping. This is in contrast to the canonical
(constant) name of the program which is used in --version.
Copy SOURCE to DEST, or multiple SOURCE(s) to DIRECTORY.
Here again is an (edited) excerpt from cp, showing a short option with an equivalent long option, a long option only, and a short option only:
-a, --archive same as -dpR
--backup[=CONTROL] make a backup of each ...
-b like --backup but ...
For programs that take many options, it may be desirable to split the option list into sections such as `Global', `Output control', or whatever makes sense in the particular case. It is usually best to alphabetize (by short option name first, then long) within each section, or the entire list if there are no sections.
The argp and popt programming interfaces let you specify
option descriptions for --help in the same structure as the
rest of the option definition; you may wish to consider using these
routines for option parsing instead of getopt.
Additional static text may be included in the generated manual page by using the `--include' and `--opt-include' options (see Invoking help2man).
The format for files included with these option is simple:
[section]
text
/pattern/
text
Blocks of verbatim *roff text are inserted into the output either at the start of the given `[section]' (case insensitive), or after a paragraph matching `/pattern/'.
Patterns use the Perl regular expression syntax and may be followed by the `i', `s' or `m' modifiers (see perlre(1))
Lines before the first section or pattern which begin with `-' are processed as options. Anything else is silently ignored and may be used for comments, RCS keywords and the like.
The section output order is:
NAME
SYNOPSIS
DESCRIPTION
OPTIONS
EXAMPLES
other
AUTHOR
REPORTING BUGS
COPYRIGHT
SEE ALSO
Any `[name]' or `[synopsis]' sections appearing in the include file will replace what would have automatically been produced (although you can still override the former with `--name' if required).
Other sections are prepended to the automatically produced output for the standard sections given above, or included at other (above) in the order they were encountered in the include file.
A suggested use of help2man in Makefiles is to have the manual page depend not on the binary, but on the source file(s) in which the `--help' and `--version' output are defined.
This usage allows a manual page to be generated by the maintainer and included in the distribution without requiring the end-user to have help2man installed.
An example rule for the program prog could be:
prog.1: $(srcdir)/main.c
-$(HELP2MAN) --output=$@ --name='an example program' ./prog
The value of HELP2MAN may be set in configure.in using
either of:
AM_MISSING_PROG(HELP2MAN, help2man, $missing_dir)
for automake, or something like:
AC_PATH_PROG(HELP2MAN, help2man, false // No help2man //)
for autoconf alone.
Manual pages may be produced for any locale supported by both the program and help2man1 with the `--locale' (`-L') option.
help2man -L fr_FR@euro -o cp.fr.1 cp
When creating localised manual pages from a program's build directory it is probable that the translations installed in the standard location will not be (if installed at all) correct for the version of the program being built.
A preloadable library is provided with help2man which will
intercept open(2) calls for message catalogs for the domain
given by $TEXTDOMAIN and re-map the requests to the appropriate
file under ./po (or $LOCALEDIR if given).
So for example:
LD_PRELOAD="hacklocaledir.so preloadable_libintl.so" TEXTDOMAIN=prog \
help2man -L fr_FR@euro -i prog.fr.h2m -o prog.fr.1 prog
will translate requests by prog for `/usr/share/locale/fr/LC_MESSGAES/PROG.mo' to `po/fr.gmo'.
Notes:
gettext, if a more specific match were available
it would also have been re-mapped.
preloadable_libintl.so in $LD_PRELOAD is
required only for cases (such as glibc) where gettext is
built into libc (where __open would otherwise be satisfied
internally).
If you find problems or have suggestions about this program or manual, please report them to bug-help2man@gnu.org.
Note to translators: when submitting new translations for
po/help2man.pot please additionally translate
help2man.h2m (used to augment the manual pages for
help2man).
The latest version of this distribution is available on-line from:
ftp://ftp.gnu.org/gnu/help2man/