Skip to main content

python-docstring-markdown

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.

Features

  • 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

Installation

pip install python-docstring-markdown

Usage

Command Line

python -m python_docstring_markdown <package_dir> <output_path>

Arguments:

  • package_dir: Path to your Python package directory.
  • output_path: Path where the Markdown documentation file will be saved. A path that ends in .md will result in a single file. A directory path will result in one .md per-module.

Example:

python -m python_docstring_markdown ./src/my_package docs/api.md

Python API

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)

Documentation

See the DOCUMENTATION.md file for more information. It also serves as an example of how the documentation is generated.

Contributing

I welcome feedback and contributions!

License

CC-0 1.0 Universal. See the LICENSE file for more information.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

python_docstring_markdown-0.4.0.tar.gz (17.8 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

python_docstring_markdown-0.4.0-py3-none-any.whl (12.2 kB view details)

Uploaded Python 3

File details

Details for the file python_docstring_markdown-0.4.0.tar.gz.

File metadata

  • Download URL: python_docstring_markdown-0.4.0.tar.gz
  • Upload date:
  • Size: 17.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: pdm/2.25.9 CPython/3.12.3 Linux/6.11.0-1018-azure

File hashes

Hashes for python_docstring_markdown-0.4.0.tar.gz
Algorithm Hash digest
SHA256 99796187d1dd80cde4e370f30dcba5697f5dac0fcd7d06e56a91481b4b695cbc
MD5 0b603d8b8e06c9129a47dffd0b901a48
BLAKE2b-256 45113db44578271a53a4ed784917a6507e262574a28c896fbdf9729ee3524907

See more details on using hashes here.

File details

Details for the file python_docstring_markdown-0.4.0-py3-none-any.whl.

File metadata

File hashes

Hashes for python_docstring_markdown-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 69ae4610f6feee2f28649210340dc715bfb0412639fb8db309bbfdd599edcc5b
MD5 8e290ad4fdbc08486e7c96af15a4fc36
BLAKE2b-256 2307b46a725cd0bac304381cf39277c0bb26c454956cf15e5db2aae57e398a33

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 files

0.3.1

2 files

0.3.0

2 files

0.2.2

2 files

0.2.1

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page