A MkDocs plugin that automatically generates beautiful documentation for your Typer CLI applications.
You might be wondering why there are two plugins for Typer. The mkdocs-typer plugin is great, but it hasn't been updated in over a year, and there have been a number of changes to Typer since then. One important change is that Typer now has its own documentation generation system via the typer <module> utils docs command. This plugin simply leverages that system to generate the documentation for your Typer CLIs.
I created this plugin because the original plugin was no longer working for me, and I wanted to have a simple plugin that would work with the latest version of Typer. If the original mkdocs-typer plugin still works for you, there probably isn't a reason to switch. However, if you are looking for a plugin that will work with the latest version of Typer, this plugin is for you!
- Seamlessly integrates with MkDocs and Material theme
- Automatically generates CLI documentation from your Typer commands
- Supports all Typer command features including arguments, options, and help text
- Easy to configure and use
prettyfeature for formatting arguments & options as tablesengineoption to select legacy markdown parsing or native Click walking- Global plugin configuration or per-documentation block configuration
The plugin can either parse Typer's generated markdown (legacy) or walk the Click command tree directly (native). Both approaches are rendered as Markdown and integrated into your MkDocs site.
The plugin works by:
- Registering a Markdown extension that processes special directive blocks
- Resolving the command tree (legacy:
typer <module> utils docs, native: Click walk) - Formatting arguments and options as lists or tables based on
pretty - Integrating the resulting HTML into your MkDocs site
Install using pip:
pip install mkdocs-typer2Install using uv:
uv add mkdocs-typer2- Python 3.10 or higher
- MkDocs 1.6.1 or higher
- Typer 0.12.5 or higher
- Pydantic 2.9.2 or higher
Add the plugin to your mkdocs.yml file:
plugins:
- mkdocs-typer2The plugin offers a pretty option that can be set in your mkdocs.yml file to enable table-based formatting for options and arguments:
plugins:
- mkdocs-typer2:
pretty: trueOptions when :pretty: false:
Options:
--name: The name of the project [required]
Options when :pretty: true:
| Name | Description | Required | Default |
|---|---|---|---|
--name |
The name of the project | Yes | - |
Use engine to select how the command tree is built:
plugins:
- mkdocs-typer2:
engine: native # or legacyIn your Markdown files, use the ::: mkdocs-typer2 directive to generate documentation for your Typer CLI:
::: mkdocs-typer2
:module: my_module
:name: mycli:module:- The module containing your Typer CLI application. This is the installed module, not the directory path. For example, if your app is located insrc/my_module/cli.py, your:module:should typically bemy_module.cli.
:name:- The name of the CLI. If left blank, your CLI will simply be namedCLIin your documentation.:pretty:- Set totrueto enable pretty formatting for this specific documentation block, overriding the global setting.:engine:-legacyparses Typer markdown (deprecated).nativewalks Click and renders lists or tables based onpretty.
You can override the global pretty setting for individual documentation blocks:
::: mkdocs-typer2
:module: my_module.cli
:name: mycli
:pretty: true
:engine: nativeYou can document multiple CLIs in the same MkDocs site by using multiple directive blocks:
# Main CLI
::: mkdocs-typer2
:module: my_module.cli
:name: mycli
# Admin CLI
::: mkdocs-typer2
:module: my_module.admin
:name: admin-cliThis repository is a good example of how to use the plugin. We have a simple CLI located in src/mkdocs_typer2/cli/cli.py.
The CLI's documentation is automatically generated using the block level directive in docs/cli.md:
::: mkdocs-typer2
:module: mkdocs_typer2.cli.cli
:name: mkdocs-typer2
:engine: legacyAnd the pretty versions in docs/cli-pretty-legacy.md and docs/cli-pretty-native.md:
::: mkdocs-typer2
:module: mkdocs_typer2.cli.cli
:name: mkdocs-typer2
:pretty: true
:engine: legacy:::: mkdocs-typer2
:module: mkdocs_typer2.cli.cli
:name: mkdocs-typer2
:pretty: true
:engine: nativeContributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.