Sphinx extension that beautifully integrates Doxygen-generated documentation into Sphinx-based documentation systems
npx @tessl/cli install tessl/pypi-breathe@4.36.0A Sphinx extension that beautifully integrates Doxygen-generated documentation into Sphinx-based documentation systems. Breathe serves as a bridge between Doxygen's excellent technical understanding of code bases (particularly C/C++ code) and Sphinx's superior long-form documentation capabilities.
pip install breatheExtension registration (in conf.py):
extensions = ['breathe']Programmatic access:
import breathe
from breathe.project import ProjectInfo, ProjectInfoFactory
from breathe.parser import DoxygenParserFactory
from breathe.file_state_cache import setup as file_state_cache_setup
from breathe.renderer.sphinxrenderer import setup as renderer_setup# Add breathe to extensions
extensions = ['breathe']
# Configure breathe projects
breathe_projects = {
"myproject": "path/to/doxygen/xml/output"
}
breathe_default_project = "myproject"Basic class documentation:
.. doxygenclass:: MyClass
:members:
:private-members:
Function documentation:
.. doxygenfunction:: myFunction
File documentation:
.. doxygenfile:: myheader.h# Generate reStructuredText files from Doxygen XML
breathe-apidoc -o output_dir -f -m path/to/doxygen/xmlBreathe operates through several key components:
The extension integrates deeply with Sphinx's configuration system, directive framework, and build process to provide seamless documentation generation while maintaining full control over output formatting and organization.
Core functionality accessed through reStructuredText directives for documenting C/C++ code elements. Includes directives for classes, functions, files, namespaces, and more with extensive customization options.
# Main entry point
def setup(app: Sphinx) -> dict[str, bool | str]:
"""
Initialize Breathe extension with Sphinx.
Returns:
Dictionary with version and parallel processing flags:
{"version": __version__, "parallel_read_safe": True, "parallel_write_safe": True}
"""Configuration options:
breathe_projects: Dict[str, str]
breathe_default_project: str
breathe_projects_source: Dict
breathe_build_directory: strCommand-line tool for batch generation of reStructuredText files from Doxygen XML output, supporting various output types and customization options.
def main() -> None # Entry point for breathe-apidoc commandAvailable types: class, interface, struct, union, file, namespace, group
Classes for managing Doxygen projects, handling XML paths, source paths, and project-specific configuration. Supports both manual project setup and automatic XML generation.
class ProjectInfo:
def __init__(app: Sphinx, name: str, path: str, source_path: str, reference: str)
def name() -> str
def project_path() -> str
def relative_path_to_xml_file(file_: str) -> str
class ProjectInfoFactory:
def __init__(app: Sphinx)
def create_project_info(options: dict) -> ProjectInfoXML parsing system for processing Doxygen's XML output, with caching support and comprehensive error handling for index files and compound definitions.
class DoxygenParserFactory:
def __init__(app: Sphinx)
def create_index_parser() -> DoxygenIndexParser
def create_compound_parser(project_info: ProjectInfo) -> DoxygenCompoundParser
class DoxygenIndexParser:
def parse(project_info: ProjectInfo)
class DoxygenCompoundParser:
def parse(refid: str)Breathe provides extensive configuration through Sphinx's config system:
breathe_projects - Map project names to XML directoriesbreathe_default_project - Default project when none specifiedbreathe_projects_source - Source paths for auto-generationbreathe_build_directory - Build directory for auto-generationbreathe_default_members - Default member inclusion settingsbreathe_show_define_initializer - Show preprocessor define valuesbreathe_show_enumvalue_initializer - Show enum value initializersbreathe_show_include - Show include statements in file docsbreathe_separate_member_pages - Create separate pages for membersbreathe_domain_by_extension - File extension to Sphinx domain mapping (default: {"py": "py", "cs": "cs"})breathe_domain_by_file_pattern - File pattern to domain mappingbreathe_use_project_refids - Use project-specific reference IDsbreathe_order_parameters_first - Order parameters before descriptionsbreathe_implementation_filename_extensions - File extensions for implementation files (default: [".c", ".cc", ".cpp"])breathe_separate_member_pages - Create separate pages for members (default: False)breathe_doxygen_config_options - Doxygen configuration overridesbreathe_doxygen_aliases - Doxygen command aliasesclass BreatheError(Exception): ...
class ProjectError(BreatheError): ...
class NoDefaultProjectError(ProjectError): ...
# Parser exceptions
class ParserError(Exception):
def __init__(self, error: Exception, filename: Path): ...
@property
def error(self) -> Exception: ...
@property
def filename(self) -> Path: ...
class FileIOError(Exception):
def __init__(self, error: Exception, filename: Path): ...
@property
def error(self) -> Exception: ...
@property
def filename(self) -> Path: ...
# Cache and processing exceptions
class MTimeError(Exception): ...
class UnrecognisedKindError(Exception): ...
# Function-specific exceptions
class _NoMatchingFunctionError(BreatheError): ...
class _UnableToResolveFunctionError(BreatheError): ...