Documenting groups

Consider the following sample application, using Groups:

# file: cli.py
import click


@click.group()
@click.option(
    '--debug',
    default=False,
    is_flag=True,
    help="Output more information about what's going on.",
)
def cli(debug: bool) -> None:
    """A sample command group."""
    pass


@cli.command()
@click.option('--param', envvar='PARAM', help='A sample option')
@click.option('--another', metavar='[FOO]', help='Another option')
def hello(param: str, another: str) -> None:
    """A sample command."""
    pass

This can be documented using sphinx-click like so:

.. click:: groups.cli:cli
  :prog: cli
  :nested: full

The rendered example is shown below.


cli

A sample command group.

cli [OPTIONS] COMMAND [ARGS]...

Options

--debug

Output more information about what’s going on.

hello

A sample command.

cli hello [OPTIONS]

Options

--param <param>

A sample option

--another <FOO>

Another option

Environment variables

PARAM

Provide a default for --param