An MkDocs extension to generate documentation for Click command line applications
Project description
mkdocs-click
An MkDocs extension to generate documentation for Click command line applications.
Installation
This package is not available on PyPI yet, but you can install it from git:
pip install git+https://github.com/DataDog/mkdocs-click.git
Quickstart
Add mkdocs-click
to Markdown extensions in your mkdocs.yml
configuration:
site_name: Example
theme: readthedocs
markdown_extensions:
- mkdocs-click
Add a CLI application, e.g.:
# app/cli.py
import click
@click.group()
def cli():
"""Main entrypoint."""
@cli.command()
@click.option("-d", "--debug", help="Include debug output.")
def build(debug):
"""Build production assets."""
Add a mkdocs-click
block in your Markdown:
# CLI Reference
This page provides documentation for our command line tools.
::: mkdocs-click
:module: app.cli
:command: cli
Start the docs server:
mkdocs serve
Tada! 💫
Usage
Documenting commands
To add documentation for a command, add a mkdocs-click
block where the documentation should be inserted.
Example:
::: mkdocs-click
:module: app.cli
:command: main
For all available options, see the Block syntax.
Multi-command support
When pointed at a group (or any other multi-command), mkdocs-click
will also generate documentation for sub-commands.
This allows you to generate documentation for an entire CLI application by pointing mkdocs-click
at the root command.
Tweaking header levels
By default, mkdocs-click
generates Markdown headers starting at <h1>
for the root command section. This is generally what you want when the documentation should fill the entire page.
If you are inserting documentation within other Markdown content, you can set the :depth:
option to tweak the initial header level.
By default it is set to 0
, i.e. headers start at <h1>
. If set to 1
, headers will start at <h2>
, and so on.
Reference
Block syntax
The syntax for mkdocs-click
blocks is the following:
::: mkdocs-click
:module: <MODULE>
:command: <COMMAND>
:depth: <DEPTH>
Options:
module
: path to the module where the command object is located.command
: name of the command object.depth
: (Optional, default:0
) Offset to add when generating headers.
Changelog
All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog.
0.1.1 - 2020-06-05
Fixed
- Raise proper error when processing unnamed commands. (Pull #4)
0.1.0 - 2020-06-04
Initial implementation.
Added
- Add
::: mkdocs-click
block with:module:
,:command:
and:depth:
options.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file mkdocs_click-0.1.1.tar.gz
.
File metadata
- Download URL: mkdocs_click-0.1.1.tar.gz
- Upload date:
- Size: 11.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d7bda303383cf48e0dab57bb69b4ec6cac83148f68c422da690f41860cb58fba |
|
MD5 | 2df2697033703866707063d0786fa2f6 |
|
BLAKE2b-256 | d197f4581f67309a2aa18bc85c3211f0fcf3a48553427db1eba8c9bb466ac4a3 |
File details
Details for the file mkdocs_click-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: mkdocs_click-0.1.1-py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f4affa6c1aed22c360a954ab9730ffd20dc7edb1dc7429e8c0583dcee17d2357 |
|
MD5 | 4e47190e07624f71bed606ac90551d95 |
|
BLAKE2b-256 | 917a3a6d8bcd66ee9c4d88123cbaa856cd70707dc41fb73d255a11eb0721a329 |