MkDocs-Click

0.9.0 · active · verified Sat Apr 11

MkDocs-Click is an MkDocs extension designed to automatically generate comprehensive documentation for Click command-line applications. It parses Click command structures and renders them directly into MkDocs pages, including options, arguments, and subcommands. The current version is 0.9.0, and it maintains an active release cadence, adapting to changes in both MkDocs and Click.

Warnings

Install

Imports

Quickstart

To use mkdocs-click, first install it alongside MkDocs. Then, configure your `mkdocs.yml` to include the `mkdocs-click` extension. Create a Python file containing your Click application and reference it in your Markdown file using the `mkdocs-click` directive. The example shows a basic Click CLI and its integration into an MkDocs project.

mkdocs new my-click-docs
cd my-click-docs
pip install mkdocs mkdocs-click click

# --- my_cli.py ---
import click

@click.group()
def cli():
    """My super CLI tool."""
    pass

@cli.command()
@click.option('--count', default=1, help='Number of greetings.')
@click.argument('name')
def hello(count, name):
    """Greets the NAME for a COUNT times."""
    for x in range(count):
        click.echo(f"Hello {name}!")

# --- mkdocs.yml ---
site_name: My Click Documentation

extensions:
  - mkdocs-click

# --- docs/index.md ---
# My Click Application Documentation

```python
# my_cli.py
import click

@click.group()
def cli():
    """My super CLI tool."""
    pass

@cli.command()
@click.option('--count', default=1, help='Number of greetings.')
@click.argument('name')
def hello(count, name):
    """Greets the NAME for a COUNT times."""
    for x in range(count):
        click.echo(f"Hello {name}!")
```

:::{.mkdocs-click}
#:
  :module: my_cli
  :command: cli
:::

# Building and serving
mkdocs build
mkdocs serve

view raw JSON →