Skip to main content

Markdownizer

Extract existing documentation from Python projects into Markdown.

CI PyPI Python License: MIT

Markdownizer never generates, rewrites, summarizes, or improves documentation. It only extracts what is already present in your source code: docstrings, comments, decorators, and source.

Installation

pip install markdownizer

Or with pipx for an isolated CLI:

pipx install markdownizer

Requires Python 3.9+. No runtime dependencies.

Usage

CLI

markdownizer /path/to/project -o ./docs

This recursively scans the project, parses every Python file with the AST, builds a deterministic Project IR, and writes one Markdown file per package into ./docs.

The compiler-style form is equivalent and supports format selection:

markdownizer build /path/to/project -o ./docs --format markdown
markdownizer build /path/to/project -o ./docs --format json
markdownizer build /path/to/project -o ./docs --format compact

Common options:

markdownizer . -o ./docs \
  --exclude "tests/*" --exclude "migrations" \
  --only-documented --no-source
Option Description
-o, --output DIR Output directory (default: ./docs)
--root-name NAME Filename for files at the project root (default: _root)
--exclude GLOB Skip matching paths; may be repeated
--format FMT Output backend: markdown, json, or compact
--no-source Omit the ## Source Code section
--no-comments Omit the ## Comments section
--only-documented Only include objects with a docstring
-v, --verbose Increase logging verbosity
-q, --quiet Suppress non-error output
--version Show the version

Run markdownizer --help for the full list.

Python API

from pathlib import Path
from markdownizer import extract_project, build_project_ir

written = extract_project(
    Path("."),
    Path("docs"),
    exclude=["tests/*"],
    include_source=False,
)
print(written)  # list of written output files

# Or build the Project IR directly:
ir = build_project_ir(Path("."), exclude=["tests/*"])
print(ir.ir_version, ir.hash, ir.stats.symbol_count)

Output formats

The pipeline builds a deterministic Project IR (packages → modules → symbols, plus import/inherit/define edges) and renders it through a backend:

Format Command Output
markdown (default) markdownizer build . -o ./docs One .md file per package
json markdownizer build . -o ./docs --format json project.json — full IR serialization
compact markdownizer build . -o ./docs --format compact context.compact.md — signatures, docstrings, inheritance, decorators (no bodies)

The legacy invocation markdownizer <project> -o <out> is kept as a compatibility alias for markdownizer build <project> --format markdown.

Signature mode

Instead of full source or no source, extract_project() accepts include_source="signature" to emit only declaration lines:

extract_project(Path("."), Path("docs"), include_source="signature")

Functions render as def foo(x: int = 1) -> str:, async functions as async def ..., classes as class User(models.Model): (with base classes), and methods with their parameters. Modules render without source. The boolean modes (True/False) are unchanged.

Project IR

build_project_ir(project_root, exclude=None) returns a ProjectIR with:

  • ir_version — schema version (currently 1), independent of the package version
  • packages, modules, symbols — the project hierarchy
  • imports, inherits, defines — relationship edges
  • stats — file/module/symbol counts
  • hash — deterministic blake2b of the canonical IR content

The hash and JSON serialization are deterministic: the same repository content always produces the same hash and the same project.json, making the output suitable for version control and caching. Machine-specific metadata (root, python_version, git) is excluded from the hash.

Import resolution is conservative and fully static: project code is never imported or executed. Imports that cannot be resolved to a project module are marked external.

What is extracted

For every documented object (modules, packages, classes, dataclasses, enums, functions, async functions, methods, properties, Django models, Django forms, Django admin classes, DRF serializers, DRF viewsets, signals, middleware, management commands, URL configuration, and any other object with a docstring):

  • The docstring, verbatim
  • Comments that belong to the object (preceding and inline)
  • Decorators
  • The complete source code

Output format

Each generated Markdown file groups all modules inside a single package and uses specialized headers such as:

# Django Model: User
# DRF Serializer: UserSerializer
# DRF ViewSet: UserViewSet
# Enum: Status
# Dataclass: Point
# Async Function: fetch_data

Every section preserves the original formatting of the source documentation.

Development

See CONTRIBUTING.md for setup, checks, and release steps. Changes are recorded in CHANGELOG.md.

License

MIT — see LICENSE.

Release files for markdownizer 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for markdownizer 0.3.0
File Size Uploaded
markdownizer-0.3.0.tar.gz 33.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for markdownizer 0.3.0
File Interpreter ABI Platform
markdownizer-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 59.6 kB

Release files / markdownizer-0.3.0.tar.gz

Download URL markdownizer-0.3.0.tar.gz
Size 33.1 kB
Tags Source
SHA-256 checksum
How to use checksums
2909b1d6097c82380b570e86f50f44574cdb3812ece70b7d5a540eda98b1c61c
BLAKE2b-256 checksum
How to use checksums
b45e727eea63afeff52802db491a1cfa2c551567d0d3f097316d191d20203503
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release files / markdownizer-0.3.0-py3-none-any.whl

Download URL markdownizer-0.3.0-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fd32d1a89e4c097c169cd7161df62ffc20f524d989ec79170d536808c04cfe32
BLAKE2b-256 checksum
How to use checksums
04fa9084d40345939a1acf22bb0d7c535a1c0b6ac9cde796961a5de66bfbdb51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 8, 2026.

Transparency log

Release history Release notifications | RSS feed

0.4.5

2 release files

0.4.4

2 release files

0.4.3

2 release files

0.4.2

2 release files

0.4.1

2 release files

0.4.0

2 release files

0.3.1

2 release files

This release

0.3.0 This release

2 release files

0.2.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page