Generate MkDocs documentation sites with Material theme, mkdocstrings for API docs, and versioning. Use when setting up or extending project documentation.
Generate professional documentation sites using MkDocs Material theme with automatic API reference generation.
Add to pyproject.toml (optional extras group):
[project.optional-dependencies]
docs = [
"mkdocs>=1.5",
"mkdocs-material>=9.4",
"mkdocstrings[python]>=0.24",
"mike>=2.0",
]
Or requirements.txt:
mkdocs>=1.5
mkdocs-material>=9.4
mkdocstrings[python]>=0.24
mike>=2.0
Simple (flat):
docs/
āāā index.md # Home/overview
āāā getting-started.md # Installation and quickstart
āāā configuration.md # Config options
āāā tools.md # Feature reference
Complex (nested):
docs/
āāā index.md
āāā compatibility.md
āāā guide/
ā āāā getting-started.md
ā āāā cli.md
ā āāā advanced.md
āāā api/
āāā panel.md # ::: module.Class
āāā entities/
āāā area.md
āāā zone.md
See templates/mkdocs.yml for the full configuration template.
Key sections:
Create minimal markdown files that reference Python modules:
# Panel API
::: mypackage.panel.Panel
::: mypackage.panel.PanelSync
mkdocstrings auto-generates documentation from docstrings. Configure in mkdocs.yml:
docstring_style: google - Use Google-style docstringsshow_source: false - Hide source codemerge_init_into_class: true - Combine __init__ with class docsfilters: ["!^_"] - Exclude private members# Serve locally with hot-reload
mkdocs serve
# Build static site
mkdocs build
# Deploy to GitHub Pages
mkdocs gh-deploy
# Version management (mike)
mike deploy --push --update-aliases 0.1.0 latest
mike set-default --push latest
templates/mkdocs.yml - Configuration filetemplates/index.md - Home pagetemplates/getting-started.md - Quickstart guidetemplates/api-reference.md - API doc page using mkdocstrings