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.1.tar.gz (40.4 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.1-py3-none-any.whl (47.5 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for api2mdx-0.2.1.tar.gz
Algorithm Hash digest
SHA256 26248828aee5c6bcc416c24c1b329c469054896079f44edbbd8d9f9d04d1b1de
MD5 fbe86bd2c41555ff92b171bf4342a0dc
BLAKE2b-256 59619fb1c9f9e067aafc9c18b10d77d7be2dc148b3f1f04b1903deaa7cd76cb9

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for api2mdx-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a75925f4f62b471195c40b51e291bad8f18db38616e11d82f5c3faaacb9c1c41
MD5 d1e53ef442b9f6c1c68679036b561097
BLAKE2b-256 98f665476f9da0f0526b3ed40beb478e233c52cd2a05c71da1f1d2a54bdceccd

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