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

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_mintlify-0.1.1.tar.gz
  • Upload date:
  • Size: 20.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.1.tar.gz
Algorithm Hash digest
SHA256 e04fd6bba69c198c2965992664f2808830070839afdfa539d885fbe73d1c20e0
MD5 b292bbb203d482a4a5a2b917f51073cb
BLAKE2b-256 e8a16eb6cfbd41e520f746c762bdc0373bf6b4853b4db4a2dd635c54daf32ae5

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for sphinx_mintlify-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 618bc2ee32deb350169d6310d9b4dca6533de3dec438943368de4f9762a958cb
MD5 f125d3c01724fb97de483d1b28a3f4a7
BLAKE2b-256 9bb430f62774e9f9bd2c63b97c5834173f612970a8a56389f605f3d6c15b85fb

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