Skip to main content

Custom Sphinx extension for embedding RapiDoc in your documentation

Project description

Sphinx-RapiDoc

PyPI version Python Versions License: MIT

A Sphinx extension that integrates RapiDoc to render beautiful, customizable, and interactive API documentation from OpenAPI/Swagger specifications.

Features

  • 🚀 Quick and easy integration with Sphinx documentation
  • 🎨 Customizable themes (light/dark)
  • 🔄 Multiple rendering styles (read/view/focused)
  • 🔒 Support for authentication
  • ⚡ Interactive API testing interface
  • 📱 Responsive design
  • 🔍 Search functionality
  • 📖 Support for OpenAPI v2.0 (Swagger) and v3.0

Installation

Install the package using pip:

pip install sphinx-rapidoc

Or install directly from GitHub for the latest version:

pip install git+https://github.com/TirthS24/sphinx_rapidoc

Quick Start

  1. Add sphinx_rapidoc to your Sphinx extensions in conf.py:

    extensions = [
        # ... your other extensions
        'sphinx_rapidoc'
    ]
    
  2. Create a new RST file (e.g., api.rst) with the RapiDoc directive:

    API Documentation
    ================
    
    .. rapidoc::
        :spec-url: https://api.example.com/openapi.json
        :theme: light
        :render-style: view
    
  3. Include your RST file in index.rst:

    .. toctree::
       :maxdepth: 2
       :caption: Contents:
    
       api
    
  4. Build your documentation:

    make html
    

Configuration Options

Directive Options

Option Description Default Values
spec-url URL to OpenAPI/Swagger specification None Valid URL
theme UI theme light light, dark
render-style Documentation rendering style view view, read, focused

Examples

Basic Usage

.. rapidoc::
    :spec-url: http://127.0.0.1:5500/src/petstore.yml
    :theme: light
    :render-style: view

Dark Theme with Read Style

.. rapidoc::
    :spec-url: http://127.0.0.1:5500/src/petstore.yml
    :theme: dark
    :render-style: read

Screenshots

Endpoint and Authentication Sections

Endpoint and Authentication sections

Sample GET Request Interface

Sample GET Request

Requirements

  • Python 3.9 or higher
  • Sphinx 2.0 or higher
  • Valid OpenAPI/Swagger specification (JSON or YAML format)
  • Web browser with JavaScript enabled

Common Issues and Solutions

CORS Errors

If you encounter CORS errors, ensure that:

  1. Your API specification URL is accessible from the hosted server
  2. The server hosting your API specification has appropriate CORS headers
  3. You're using HTTPS if your documentation is hosted on HTTPS

Specification Not Loading

  • Verify that your specification URL is publicly accessible
  • Check if the URL returns valid JSON/YAML in OpenAPI/Swagger format
  • Ensure your specification follows OpenAPI standards

Contributing

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

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

This project is licensed under the MIT License - see the LICENSE file for details.

Acknowledgments

  • RapiDoc for the awesome API documentation renderer
  • Sphinx for the excellent documentation generator

Support

If you encounter any issues or have questions, please:

  1. Check the Common Issues section
  2. Open an issue on GitHub
  3. Contact the maintainers

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_rapidoc-0.1.1.tar.gz (225.9 kB view details)

Uploaded Source

Built Distribution

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

sphinx_rapidoc-0.1.1-py3-none-any.whl (225.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_rapidoc-0.1.1.tar.gz
  • Upload date:
  • Size: 225.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for sphinx_rapidoc-0.1.1.tar.gz
Algorithm Hash digest
SHA256 3f162af7d6d0e69e612f4caff08019e61166fbf336ae0b66b2745e8d8e114cc5
MD5 5fb1186d8633ee2ce15948b875b282fc
BLAKE2b-256 0ce9e13d9454021b57b458711df236dc3ea5bb4cfb7e873baee4a302515352ba

See more details on using hashes here.

File details

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

File metadata

  • Download URL: sphinx_rapidoc-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 225.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.4

File hashes

Hashes for sphinx_rapidoc-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 16498b4e20c1bbcc0a7fc693b5755d3921ebd748925b67d36a45a6b8a9769daa
MD5 68902379a60a7563c02e4be9b4297c06
BLAKE2b-256 72209dccfc7f6442fb406412992f1cc4c36f966bfeff2967321b0180a9e0d9dc

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