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.0.tar.gz (40.6 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.0-py3-none-any.whl (48.1 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for api2mdx-0.2.0.tar.gz
Algorithm Hash digest
SHA256 f25092e2192d3db8c43e738c456e8632939041d96bb25f14883ac8609cd8cc4a
MD5 18364046ccae1da2f2539f827beafe95
BLAKE2b-256 d1e6ba5186c9b3d1af5a37fd2502f23a49e5dd81d90a0f0902a9adc53c7956dc

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for api2mdx-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 96e60875824759c32ad44e2b4ddc67541512b99adf9acd72095e046e4ff1185f
MD5 2f03913ba8a4c934c9170ecd6d6f1eb3
BLAKE2b-256 044b2a33e7a85854da856a04369bdca70725ec3133f8a65f11194a6d23ad33eb

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