Skip to main content

Sphinx extension for generating Mintlify-compatible MDX documentation

Project description

Sphinx Mintlify Extension

A Sphinx extension that generates Mintlify-compatible MDX documentation from Python docstrings, creating organized documentation with a folder per class and a file per method.

Features

  • Generates Mintlify-compatible MDX documentation
  • Creates a folder per class with individual method documentation
  • Supports class inheritance documentation
  • Preserves type hints and parameter descriptions
  • Supports async methods and properties
  • Generates proper frontmatter
  • Customizable templates and metadata
  • Method grouping and ordering options

Installation

pip install sphinx-mintlify

Usage

  1. Add the extension to your Sphinx project's conf.py:
extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.viewcode',
    'sphinx.ext.napoleon',
    'sphinx_mintlify',
]

# Configure the extension
classmd_output_dir = 'docs/api'  # Output directory for generated MDX files

# List classes to document
classmd_classes = [
    'myproject.models.User',
    {
        'path': 'myproject.utils.Helper',
        'name': 'HelperClass'
    }
]

# Optional: Configure method documentation
classmd_method_options = {
    'include_source': True,
    'include_examples': True,
    'group_by_type': True
}

# Optional: Configure method ordering
classmd_method_order = [
    '__init__',
    'public_methods',
    'private_methods',
    'static_methods',
    'class_methods'
]

# Optional: Custom templates
classmd_templates = {
    'class_index': '_templates/class_index.mdx',
    'method': '_templates/method.mdx'
}

# Optional: Additional metadata
classmd_metadata = {
    'api_version': '1.0.0',
    'api_status': 'stable',
    'sidebar_label': 'API Reference',
    'sidebar_position': 2
}
  1. Run Sphinx to generate the documentation:
sphinx-build -b dirhtml source/ _build/dirhtml

The extension will automatically create a folder structure in your classmd_output_dir like this:

docs/api/
├── User/
│   ├── index.mdx
│   ├── __init__.mdx
│   ├── authenticate.mdx
│   └── update_profile.mdx
└── HelperClass/
    ├── index.mdx
    ├── utility_method1.mdx
    └── utility_method2.mdx
  1. Copy the generated MDX files to your Mintlify documentation folder:
cp -r docs/api/* docs/

Example Output

For a class like this:

class User:
    def authenticate(self, password: str) -> bool:
        """Authenticate the user with the given password.
        
        Args:
            password: The password to verify
            
        Returns:
            bool: True if authentication successful, False otherwise
            
        Raises:
            ValueError: If password is empty
        """
        pass

The extension will generate an MDX file (authenticate.mdx) like this:

---
title: "User.authenticate"
description: "Authenticate the user with the given password"
---

# authenticate

Authenticate the user with the given password.

## Signature

```python
def authenticate(self, password: str) -> bool

Parameters

The password to verify

Returns

True if authentication successful, False otherwise

Raises

  • ValueError: If password is empty

Example

user = User()
is_authenticated = user.authenticate("my_password")

## Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

## License

This project is licensed under the MIT License. 

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

sphinx_mintlify-0.1.0.tar.gz (19.3 kB view details)

Uploaded Source

Built Distribution

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

sphinx_mintlify-0.1.0-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file sphinx_mintlify-0.1.0.tar.gz.

File metadata

  • Download URL: sphinx_mintlify-0.1.0.tar.gz
  • Upload date:
  • Size: 19.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.13

File hashes

Hashes for sphinx_mintlify-0.1.0.tar.gz
Algorithm Hash digest
SHA256 ae18ee42407d0ab66d33a7ca7ea0fd7c10d5d0210d6124bf3efcd89ed20055a7
MD5 ffdfe2e5c5a7342cd27b4a5a37221296
BLAKE2b-256 158e7f126175cf1352c8f8382bbb11a14fbe61ed35b735e2e99e9665f3ed9f30

See more details on using hashes here.

File details

Details for the file sphinx_mintlify-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for sphinx_mintlify-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 32655b1cfbd90fc257c15d7831ff7bd54805ece80f60cfa5646117afa84448fb
MD5 9bbef01a87e007e81802c58de2d6ca36
BLAKE2b-256 87196d930cdab3c8f10b1f51a4d53bc837860c91fbc742a902fc2d222799348b

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