Skip to main content

Generate MDX API documentation from Python modules

Project description

mdxify

Generate MDX API documentation from Python modules with automatic navigation structure.

Installation

pip install mdxify

Usage

Generate documentation for all modules in a package:

mdxify --all --root-module mypackage --output-dir docs/python-sdk

Generate documentation for specific modules:

mdxify mypackage.core mypackage.utils --output-dir docs/python-sdk

Exclude internal modules from documentation:

mdxify --all --root-module mypackage --exclude mypackage.internal --exclude mypackage.tests

Options

  • modules: Specific modules to document
  • --all: Generate documentation for all modules under the root module
  • --root-module: Root module to generate docs for (required when using --all)
  • --output-dir: Output directory for generated MDX files (default: docs/python-sdk)
  • --update-nav/--no-update-nav: Update docs.json navigation (default: True)
  • --skip-empty-parents: Skip parent modules that only contain boilerplate (default: False)
  • --anchor-name / --navigation-key: Name of the navigation anchor or group to update (default: 'SDK Reference')
  • --exclude: Module to exclude from documentation (can be specified multiple times). Excludes the module and all its submodules.
  • --repo-url: GitHub repository URL for source code links (e.g., https://github.com/owner/repo). If not provided, will attempt to detect from git remote.
  • --branch: Git branch name for source code links (default: main)

Navigation Updates

mdxify can automatically update your docs.json navigation by finding either anchors or groups:

  1. First run: Add a placeholder in your docs.json using either format:

Anchor format (e.g., FastMCP):

{
  "navigation": [
    {
      "anchor": "SDK Reference",
      "pages": [
        {"$mdxify": "generated"}
      ]
    }
  ]
}

Group format (e.g., Prefect):

{
  "navigation": [
    {
      "group": "SDK Reference",
      "pages": [
        {"$mdxify": "generated"}
      ]
    }
  ]
}
  1. Subsequent runs: mdxify will find and update the existing anchor or group directly - no placeholder needed!

The --anchor-name parameter (or its alias --navigation-key) identifies which anchor or group to update.

Source Code Links

mdxify can automatically add links to source code on GitHub for all functions, classes, and methods:

# Auto-detect repository from git remote
mdxify --all --root-module mypackage

# Or specify repository explicitly
mdxify --all --root-module mypackage --repo-url https://github.com/owner/repo --branch develop

This adds source links next to each function/class/method that link directly to the code on GitHub.

Customizing Source Link Text

You can customize the link text/symbol using the MDXIFY_SOURCE_LINK_TEXT environment variable:

# Use custom text
export MDXIFY_SOURCE_LINK_TEXT="[src]"
mdxify --all --root-module mypackage

# Use emoji
export MDXIFY_SOURCE_LINK_TEXT="🔗"
mdxify --all --root-module mypackage

# Use different Unicode symbol (default is "view on GitHub ↗")
export MDXIFY_SOURCE_LINK_TEXT="⧉"
mdxify --all --root-module mypackage

Features

  • Fast AST-based parsing - No module imports required
  • MDX output - Compatible with modern documentation frameworks
  • Automatic navigation - Generates hierarchical navigation structure
  • Google-style docstrings - Formats docstrings using Griffe
  • Smart filtering - Excludes private modules and known test patterns

Development

# Install development dependencies
uv sync

# Run tests
uv run pytest

# Run type checking
uv run ty check

# Run linting
uv run ruff check src/ tests/

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

mdxify-0.2.21.tar.gz (54.2 kB view details)

Uploaded Source

Built Distribution

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

mdxify-0.2.21-py3-none-any.whl (18.5 kB view details)

Uploaded Python 3

File details

Details for the file mdxify-0.2.21.tar.gz.

File metadata

  • Download URL: mdxify-0.2.21.tar.gz
  • Upload date:
  • Size: 54.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mdxify-0.2.21.tar.gz
Algorithm Hash digest
SHA256 da9a13347d5cfe57bbc4547758e217b59ee00869128eee87bf8e08192db88a64
MD5 46edbfb323852ed75c56f8cbc5f48db7
BLAKE2b-256 176777374401d770f2b55d2c9082dff717e0f10885c72cdcf1bd91493654d6de

See more details on using hashes here.

File details

Details for the file mdxify-0.2.21-py3-none-any.whl.

File metadata

  • Download URL: mdxify-0.2.21-py3-none-any.whl
  • Upload date:
  • Size: 18.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for mdxify-0.2.21-py3-none-any.whl
Algorithm Hash digest
SHA256 750abe1ea4c3bab9e7f8364e20a182ae9df49cccc2a4f11118930f973b873493
MD5 0ce60dc8ff383ce0d3fe45b2425f151f
BLAKE2b-256 98924bd76280d81c84ebb539a9f0b54c61c27a7df0f669de26f2cb47b40e8df6

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