Welcome to npdoc-cli’s documentation!

Welcome to npdoc-cli’s documentation!#

npdoc-cli is a wrapper for argparse that utilizes the numpy style guide to generate a command line interface (CLI). Paired with auto-generated documentation with sphinx, it allows the definitions of a functions source code, source code documentation, and command line interface definition to be tied together all in the same block of code. Maintaining the source code, documentation, and the CLI interface all happens in the same place!

For example, a simple CLI can be made:

from npdoc_cli import cli

@cli.program
def hello(name: str):
    """
    Say hello!

    Parameters
    ----------
    name : str
        Who is being greeted.
    """
    print('hello', name)

cli.build()
cli.print_help()

Which produces a help message:

usage: hello [-h] name

Say hello!

positional arguments:
  name        Who is being greeted.

options:
  -h, --help  show this help message and exit

Command line arguments can be parsed and dispatched to the right function by:

args = cli.parse_args()
cli.dispatch(args)

Installation#

Intall with pip.

pip install npdoc-cli

Indices and tables#