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.2.2.tar.gz (37.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.2.2-py3-none-any.whl (43.8 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for api2mdx-0.2.2.tar.gz
Algorithm Hash digest
SHA256 cb8b0e968f8700558805923ae9789d0305f627f4cfa5d219426d8f37215ca850
MD5 951e2f9349a4f26984a8b5f38851d32b
BLAKE2b-256 0ff3250962d73de9400f79444d17ccbf68b888613a7ac4f6b957ab09f921fb0f

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for api2mdx-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 7ca58dabb747592e1a560d69cb36ae3f903003b92ba8ad452c2f2a7760ce37e7
MD5 c8ba31698273bbb8c8575fcf5c985f08
BLAKE2b-256 f9f9bb46e7c7609fbd028aa4aa1e9e976630c0290255e28f4d13e4bfc97a89a0

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