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:
- Generate MDX documentation files in
snapshots/mdx/ - Generate intermediate directive files in
snapshots/directives/(useful for debugging) - 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
- API Discovery: Scans Python modules and respects
__all__exports as the source of truth - Path Generation: Uses export structure for file organization (e.g.,
responses/__init__.pyexportsResponse→responses/Response.mdx) - Directive Processing: Generates Griffe directives and processes them into MDX
- 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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26248828aee5c6bcc416c24c1b329c469054896079f44edbbd8d9f9d04d1b1de
|
|
| MD5 |
fbe86bd2c41555ff92b171bf4342a0dc
|
|
| BLAKE2b-256 |
59619fb1c9f9e067aafc9c18b10d77d7be2dc148b3f1f04b1903deaa7cd76cb9
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a75925f4f62b471195c40b51e291bad8f18db38616e11d82f5c3faaacb9c1c41
|
|
| MD5 |
d1e53ef442b9f6c1c68679036b561097
|
|
| BLAKE2b-256 |
98f665476f9da0f0526b3ed40beb478e233c52cd2a05c71da1f1d2a54bdceccd
|