LinuxCommandLibrary
GitHubF-DroidGoogle Play Store

help2man

generates man pages from program --help and --version output

TLDR

Generate a man page from a program's help output
$ help2man [program] > [program.1]
copy
Generate with a specific man page section number
$ help2man -s [1] [program] > [program.1]
copy
Add a name/description for the NAME section
$ help2man -n "program description" [program] > [program.1]
copy
Include additional text from an include file
$ help2man --include [extra.h2m] [program] > [program.1]
copy
Write output directly to a file
$ help2man -o [program.1] [program]
copy
Suppress "info" pointer in the generated page
$ help2man -N [program] > [program.1]
copy

SYNOPSIS

help2man [options] executable

DESCRIPTION

help2man generates man pages from a program's `--help` and `--version` output. It parses the structured help text and formats it as troff-style man page source, creating basic documentation automatically.The tool produces minimal man pages suitable for programs that follow GNU conventions for help output. Additional content can be added via include files (`.h2m`), which support inserting text before or after automatically generated sections using `[section]` headers.

PARAMETERS

EXECUTABLE

Program whose --help and --version output will be used to generate the man page.
-n, --name STRING
Short description for the NAME section.
-s, --section NUM
Man page section number (default: 1).
-i, --include FILE
Include extra material from file. The file uses `[section]` headers to place text.
-I, --opt-include FILE
Like -i but does not fail if file is missing.
-N, --no-info
Suppress the "see also info page" pointer.
-o, --output FILE
Write output to file instead of stdout.
-m, --manual TEXT
Name of the manual (e.g., "User Commands").
-S, --source TEXT
Source of the program (e.g., "FSF", "Debian").
-L, --locale STRING
Set locale for fetching help output (default: "C").
-l, --libtool
Drop libtool `lt-` prefix from program name.
-p, --info-page TEXT
Name of Texinfo manual to reference.
-h, --help-option STRING
Alternative help option string to use instead of --help.
-v, --version-option STRING
Alternative version option string to use instead of --version.
--version-string STRING
Use this version string instead of running the program's version option.
--no-discard-stderr
Include stderr output when parsing option output.
--version
Show help2man version.

CAVEATS

Output quality depends heavily on the format of the program's `--help` output. Works best with GNU-style option formatting (leading dashes, aligned descriptions). Programs with non-standard help text may produce poorly formatted man pages that require manual editing. Does not document features not mentioned in `--help` output.

HISTORY

help2man was created by Brendan O'Dea as part of the GNU project to automate man page generation for GNU utilities during the build process.

SEE ALSO

man(1), pod2man(1), ronn(1)

Copied to clipboard
Kai