Skip to main content

Generate MDX API documentation from Python source code

Project description

api2mdx

api2mdx is a Python tool that generates mdx documentation for Python APIs. Under the hood, it uses Griffe.

api2mdx is designed to work in tandem with custom components like <ParametersTable>, <ApiSignature>, etc. Currently they live in @mirascope/website or @mirascope/docs-viewer, but later they will be extracted to @mirascope/ui.

Usage

Generate API documentation from Python source code:

python -m api2mdx.main --source-path ./src --package mypackage --output ./docs/api

Options

  • --source-path: Path to the source code directory
  • --package: Python package name to document
  • --output: Path where generated documentation should be written
  • --docs-path: Path within the package where docs are located (default: docs/api)
  • --pattern: Optional pattern to regenerate only matching files
  • --output-directives: Optional path to output intermediate directive files for debugging

Example

python -m api2mdx.main \
  --source-path ./snapshots \
  --package mirascope_v2_llm \
  --output ./snapshots/mdx \
  --output-directives ./snapshots/directives

Snapshot Regeneration

The project includes test snapshots for validation. To regenerate all snapshots:

uv run regenerate-snapshots

This will:

  1. Generate MDX documentation files in snapshots/mdx/
  2. Generate intermediate directive files in snapshots/directives/ (useful for debugging)
  3. Process documentation links and generate metadata

Snapshot Structure

snapshots/
├── mirascope_v2_llm/        # Source Python code
├── mdx/                     # Generated MDX documentation  
└── directives/              # Intermediate directive files (for debugging)

How It Works

  1. API Discovery: Scans Python modules and respects __all__ exports as the source of truth
  2. Path Generation: Uses export structure for file organization (e.g., responses/__init__.py exports Responseresponses/Response.mdx)
  3. Directive Processing: Generates Griffe directives and processes them into MDX
  4. Metadata Generation: Creates TypeScript metadata files for navigation

Project details


Download files

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

Source Distribution

api2mdx-0.1.0.tar.gz (39.8 kB view details)

Uploaded Source

Built Distribution

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

api2mdx-0.1.0-py3-none-any.whl (47.1 kB view details)

Uploaded Python 3

File details

Details for the file api2mdx-0.1.0.tar.gz.

File metadata

  • Download URL: api2mdx-0.1.0.tar.gz
  • Upload date:
  • Size: 39.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.11

File hashes

Hashes for api2mdx-0.1.0.tar.gz
Algorithm Hash digest
SHA256 4c1cf4cf659f2b38e85f31cbd55cf3fa9b19ad823a189cccee263b61cd98deb2
MD5 30a3105c43ce8b21fdd0daaf7c6fc290
BLAKE2b-256 58376809a34f8d809a6d4cfd6d881715ed63909695d6de619089cfa282c71e29

See more details on using hashes here.

File details

Details for the file api2mdx-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: api2mdx-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 47.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.6.11

File hashes

Hashes for api2mdx-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 74740d6beb11389a9f110f1bb1b3687fea19a3b9624bccb0f5e29dedaae033c9
MD5 df672c06a0dd750e44221aca04ef85ee
BLAKE2b-256 803d0199c1909c53533be93e3a47e22b0d9fa92729a6898ad5293dccd0b9ac4a

See more details on using hashes here.

Supported by

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