Skip to content

Extract docs with mkdocstrings

mkdocs.yml

# You can even use this with other plugins, like 
# [mkdocstrings](https://pypi.org/project/mkdocstrings/), to achieve advanced 
# configurations.
site_name: ok-with-mkdocstrings
plugins:
  - simple
  - mkdocstrings

Input

ok-with-mkdocstrings/
├── example.md
├── mkdocs.yml
├── module.py
└── README.md

module.py

"""md

## Python Version

You can put _markdown_ in triple-quoted strings in Python.

You can even combine it with mkdocstrings to automatically generate your source
documentation!

::: module.main
    handler: python
    options:
        show_root_heading: true
        show_source: false
        heading_level: 3
"""


def main():
    """Test function which takes no parameters.

    It says "Hello, world!"
    """
    print("Hello, world!")
    return 0

Output

site/
├── example/
│   └── index.html
├── index.html
├── module/
│   └── index.html
└── objects.inv

module

Python Version

You can put markdown in triple-quoted strings in Python.

You can even combine it with mkdocstrings to automatically generate your source documentation!

module.main()

Test function which takes no parameters.

It says "Hello, world!"


Last update: August 25, 2023