Sphinxcontrib Mermaid (version 2.0.1) is a Sphinx extension that enables embedding Mermaid.js diagrams directly into reStructuredText or Markdown documentation. It allows authors to create various diagrams like flowcharts, sequence diagrams, class diagrams, and Gantt charts using a simple text-based syntax. This approach ensures diagrams are version-controlled, easy to maintain, and rendered consistently with the Sphinx theme. The library is actively maintained, supports Python >=3.10, and is distributed via PyPI.
pip install sphinxcontrib-mermaidVerified import paths — ran on the pinned version, not inferred.
After installing the package, add 'sphinxcontrib.mermaid' to your `extensions` list in `conf.py`. Then, use the `.. mermaid::` directive in your reStructuredText or Markdown files to embed Mermaid code. For image output (SVG/PNG) or PDF builds, `mermaid-cli` must also be installed via npm.
Install `mermaid-cli` globally or locally via npm (`npm install -g @mermaid-js/mermaid-cli`) and optionally configure `mermaid_cmd` in `conf.py` (e.g., `mermaid_cmd = 'npx mmdc'`).
Add `mermaid_output_format = 'svg'` (or 'png') to your `conf.py`. Remember this also requires `mermaid-cli`.
Resolve conflicts by adding `nbsphinx_requirejs_path = ''` or `jupyter_sphinx_require_url = ''` to your `conf.py` as appropriate.
Monitor the GitHub repository for updates on maintenance status and consider contributing if possible.