Exhale: Automatic C++ API Documentation Generator

0.3.7 · active · verified Thu Apr 16

Exhale is a Sphinx extension designed to automatically generate C++ library API documentation. It integrates Doxygen's XML output with Sphinx, providing features like class, file, and page hierarchies within Sphinx-generated websites. Currently at version 0.3.7, Exhale is actively maintained with releases focusing on bug fixes and dependency updates.

Common errors

Warnings

Install

Imports

Quickstart

To quickly integrate Exhale, first run `sphinx-quickstart` in your documentation directory. Then, modify your `conf.py` to include `breathe` and `exhale` in your extensions. Configure `breathe_projects`, `breathe_default_project`, and the `exhale_args` dictionary. Ensure Doxygen XML output is correctly configured. Finally, link the generated API root file (`api/library_root.rst` by default) into your main `index.rst` using a `toctree` directive.

import os
import sys

# Add these to your conf.py after `extensions` list and other configurations
# Assuming your Doxygen XML output is in `_build/doxyoutput/xml` relative to docs/conf.py
# and your C++ source is in `../include` relative to docs/

extensions = [
    'sphinx.ext.autodoc',
    'sphinx.ext.autosummary',
    'sphinx.ext.doctest',
    'sphinx.ext.intersphinx',
    'sphinx.ext.viewcode',
    'breathe',
    'exhale'
]

# Breathe configuration
breathe_projects = {"My Project": "_build/doxyoutput/xml"}
breathe_default_project = "My Project"

# Exhale configuration
exhale_args = {
    "doxygenIndexXMLPath": "_build/doxyoutput/xml/index.xml",
    "containmentFolder": "./api",
    "rootFileName": "library_root.rst",
    "rootFileTitle": "Library API",
    "doxygenStripFromPath": "..",
    "createTreeView": True,
    "exhaleExecutesDoxygen": True,
    "exhaleDoxygenStdin": "INPUT = ../../include"
}

# Tell sphinx what the primary language being documented is.
primary_domain = 'cpp'
# Tell sphinx what the pygments highlight language should be.
highlight_language = 'cpp'

# If you choose to execute Doxygen separately, remove 'exhaleExecutesDoxygen' and 'exhaleDoxygenStdin'
# and ensure Doxygen output is generated before Sphinx build.

# Add 'api/library_root' to a toctree directive in your index.rst, e.g.:
#
# .. toctree::
#    :maxdepth: 2
#    :caption: Contents:
#
#    api/library_root

view raw JSON →