CLI reference
Command-line API can be easily and automatically documented by including an RST block. The code looks like this:
{eval-rst}
.. autoprogram:: rs_template._command_line:create_parser()
:prog: rs.template
note that you need to direct autoprogram
to a specific file and function which returns an argparse.ArgumentParser
object (or to an argparse.ArgumentParser
object itself).
This will be rendered into your documentation:
rs.template
This is a basic parser, showing how command-line options are displayed in online documentation.
usage: rs.template [-h] --first-arg FIRST_ARG --second-arg SECOND_ARG
[--third-arg THIRD_ARG]
- -h, --help
show this help message and exit
- --first-arg <first_arg>
First command line argument. This argument is required.
- --second-arg <second_arg>
Second command line argument. This argument is required and must be a float.
- --third-arg <third_arg>
Third command line argument. This argument is optional, defaults to ‘typical value’