mkdocstrings

1.0.3 · active · verified Thu Apr 09

mkdocstrings is an MkDocs plugin that generates automatic documentation from source code, providing an alternative to Sphinx. It leverages 'handlers' (like mkdocstrings-python) to parse different language sources and render them within your MkDocs site. The current version is 1.0.3, with frequent patch releases and occasional minor/major feature releases.

Warnings

Install

Imports

Quickstart

To quickly get started, install mkdocstrings with the Python handler. Create a `mkdocs.yml` file, add the `mkdocstrings` plugin, and configure the Python handler to point to your source code directory (e.g., `src`). Then, in your Markdown files, use the `:::` syntax to reference your Python objects. This example shows how to document a function `greet` from `src/my_module.py`.

# mkdocs.yml
site_name: My Awesome Project
theme: material

plugins:
  - mkdocstrings: # Enable the mkdocstrings plugin
      handlers:
        python:
          paths: [src] # Tell the Python handler where to find your code

# src/my_module.py
def greet(name: str) -> str:
    """
    Greets a person by their name.

    Parameters:
        name: The name of the person to greet.

    Returns:
        A personalized greeting string.
    """
    return f"Hello, {name}!"

# docs/index.md
# Welcome

This is the main documentation page.

## API Reference

::: src.my_module.greet
    options:
      show_source: false

view raw JSON →