griffe2md: Output API docs to Markdown using Griffe
griffe2md is a Python library that generates API documentation in Markdown format. It leverages Griffe for parsing Python source code and uses Jinja templates to render the extracted API data into Markdown, similar to how mkdocstrings-python generates HTML but for Markdown output. It primarily provides a command-line interface for ease of use. The library is actively maintained, currently at version 1.5.0, with regular updates addressing features and bug fixes.
Common errors
-
ModuleNotFoundError: No module named 'griffe' (or similar errors related to griffelib)
cause In `griffe2md` versions 1.3.4 and later, the underlying parsing library `griffe` was replaced by `griffelib`. Older environments or explicit dependency pinning might lead to `griffe` being sought.fixEnsure `griffelib` is installed: `pip install griffelib`. It is recommended to upgrade `griffe2md` to the latest version to get the correct dependency automatically: `pip install --upgrade griffe2md`. -
Generated Markdown output is not formatted or pretty-printed.
cause As of `griffe2md` version 1.4.0, automatic formatting with `mdformat` is no longer enabled by default. Prior versions might have applied formatting automatically.fixIf automatic formatting is desired, run an external formatter like `mdformat` on the output file after `griffe2md` has generated it: `griffe2md markdown my_package > docs.md && mdformat docs.md`. -
Markdown tables in generated documentation appear broken or incorrectly rendered.
cause Earlier versions of `griffe2md` had bugs in handling Markdown table syntax, such as not properly escaping pipe characters or newlines within table cells.fixUpgrade `griffe2md` to the latest version (`1.3.3` or newer) to include fixes for table rendering issues: `pip install --upgrade griffe2md`.
Warnings
- breaking Changed core dependency from `griffe` to `griffelib`.
- gotcha Markdown output is no longer formatted by default using `mdformat`.
- gotcha Older versions may produce malformed Markdown tables due to improper escaping of pipes or handling of newlines.
Install
-
pip install griffe2md -
uv tool install griffe2md
Quickstart
griffe2md markdown path/to/my/src/package -o api_docs.md