A Python module and CLI that walks a Python package/directory and outputs a Markdown file from all docstrings in the package.
Tools like mkdocs and readthedocs are overkill for many small Python projects. This project exists to provide a simple way to generate Markdown documentation that can be stored alongside your code in Github.
- Crawls the packages, modules, classes, functions, and methods using the
ast
module - Auto-detects ReST, Google, Numpydoc-style and Epydoc docstrings using
docstring-parser-fork
- Generates a table of contents with anchor links
- Tracks and documents module exports (
__all__
) - Preserves module hierarchy in documentation
- Handles nested classes and functions
pip install python-docstring-markdown
python -m python_docstring_markdown <package_dir> <output_file>
Arguments:
package_dir
: Path to your Python package directoryoutput_file
: Path where the Markdown documentation file will be saved
Example:
python -m python_docstring_markdown ./src/my_package docs/api.md
from python_docstring_markdown import crawl
# Generate documentation for a package
docs_content = crawl("./src/my_package")
# Save to a file
with open("docs/api.md", "w") as f:
f.write(docs_content)
See the DOCUMENTATION.md file for more information. It also serves as an example of how the documentation is generated.
I welcome feedback and contributions!
CC-0 1.0 Universal. See the LICENSE file for more information.