package cmdliner
Install
dune-project
Dependency
Authors
Maintainers
Sources
sha512=a7bd4eeb0cef7c08bca73b0077a65f748c19a230544133b39fc3360feb2cf0af08416a8b84031c94a2f4a007d5920a4db1368d87b9eeca561671828e2dad2885
doc/tool_man.html
Tool man pages
See also the section about man pages in the command line interface manual.
Man page generation
Man page sections for a command are printed in the order specified by the man
value given to Cmdliner.Cmd.info
. Unless specified explicitly in the man
value the following sections are automatically created and populated for you:
The various doc
documentation strings specified by the command's term arguments get inserted at the end of the documentation section they respectively mention in their docs
argument:
- For commands, see
Cmdliner.Cmd.info
. - For positional arguments, see
Cmdliner.Arg.info
. Those are listed iff both thedocv
anddoc
string is specified byCmdliner.Arg.info
. - For optional arguments, see
Cmdliner.Arg.info
. - For exit statuses, see
Cmdliner.Cmd.Exit.info
. - For environment variables, see
Cmdliner.Cmd.Env.info
.
If a docs
section name is mentioned and does not exist in the command's man
value, an empty section is created for it, after which the doc
strings are inserted, possibly prefixed by boilerplate text (e.g. for Cmdliner.Manpage.s_environment
and Cmdliner.Manpage.s_exit_status
).
If the created section is:
- standard, it is inserted at the right place in the order specified here, but after a possible non-standard section explicitly specified by the command's
man
value since the latter get the order number of the last previously specified standard section or the order ofCmdliner.Manpage.s_synopsis
if there is no such section. - non-standard, it is inserted before the
Cmdliner.Manpage.s_commands
section or the first subsequent existing standard section if it doesn't exist. Taking advantage of this behaviour is discouraged, you should declare manually your non standard section in the command's manual page.
Finally note that the header of empty sections are dropped from the output. This allows you to share section placements among many commands and render them only if something actually gets inserted in it.
Documentation markup language
Manpage blocks and the doc strings of the various info
values support the following markup language.
- Markup directives
$(i,text)
and$(b,text)
, wheretext
is raw text respectively rendered in italics and bold. - Outside markup directives, context dependent variables of the form
$(var)
are substituted by marked up data. For example in a command man page$(cmd)
is substituted by the command's invocation in bold. - Characters '$', '(', ')' and '\' can respectively be escaped by \$, \(, \) and \\ . In OCaml strings this will be
"\\$"
,"\\("
,"\\)"
,"\\\\"
. Escaping '$' and '\' is mandatory everywhere. Escaping ')' is mandatory only in markup directives. Escaping '(' is only here for your symmetric pleasure. Any other sequence of characters starting with a '\' is an illegal character sequence. - Referring to unknown markup directives or variables will generate errors on standard error during documentation generation.