Skip to main content

Mermaid diagrams in Sphinx, powered by beautiful-mermaid

Project description

sphinx-oceanid

PyPI Python Documentation 日本語

Mermaid diagrams in Sphinx, powered by beautiful-mermaid.

Features

  • beautiful-mermaid rendering — Uses ELK.js-based layout engine for high-quality SVG output
  • CSS variable theming — Automatic dark/light theme detection with instant switching (no re-render)
  • Zero-config — Works out of the box with CDN-hosted beautiful-mermaid
  • sphinx-revealjs support — Lazy rendering for hidden slides via IntersectionObserver (example)
  • Pan & zoom — Native Pointer Events + SVG transform (no d3.js dependency)
  • Fullscreen modal — View diagrams in a viewport-sized overlay
  • External file support — Reference .mmd files instead of inline code
  • Auto class diagrams — Generate class hierarchy diagrams from Python code

Supported Diagram Types

Type Alias
flowchart graph
sequenceDiagram
classDiagram
stateDiagram stateDiagram-v2
erDiagram
xychart-beta

Unsupported diagram types produce explicit warnings (or errors), never silent degradation.

Installation

sphinx-oceanid requires Python 3.13+.

pip install sphinx-oceanid

From source:

pip install git+https://github.com/drillan/sphinx-oceanid.git

Or clone and install locally:

git clone https://github.com/drillan/sphinx-oceanid.git
cd sphinx-oceanid
pip install .

Quick Start

Add the extension to your conf.py:

extensions = ["sphinx_oceanid"]

Then use the mermaid directive in your reStructuredText files:

.. mermaid::

   flowchart LR
     A[Start] --> B[Process] --> C[End]

Or in Markdown (MyST) files:

```{mermaid}
sequenceDiagram
  Alice->>Bob: Hello
  Bob-->>Alice: Hi!
```

Build and preview — Mermaid diagrams require HTTP serving (file:// will not render due to CORS):

# Quick static server (no extra dependencies)
make -C docs serve

# Live reload (requires sphinx-autobuild)
pip install sphinx-oceanid[preview]
make -C docs livehtml

See docs/install.md for Makefile setup instructions.

Configuration

All configuration options use the oceanid_ prefix in conf.py:

# conf.py
extensions = ["sphinx_oceanid"]

# Theme (default: "auto" — detects dark/light from Sphinx theme)
oceanid_theme = "auto"
oceanid_theme_dark = "zinc-dark"
oceanid_theme_light = "zinc-light"

# Enable zoom on all diagrams (default: False)
oceanid_zoom = True

# Enable fullscreen modal (default: False)
oceanid_fullscreen = True

# Action for unsupported diagram types: "warning" or "error" (default: "warning")
oceanid_unsupported_action = "warning"

Directive Options

.. mermaid::
   :name: my-diagram
   :alt: Description for accessibility
   :align: center
   :caption: Diagram caption (rendered as <figcaption>)
   :title: Mermaid native title (rendered inside the diagram)
   :zoom:
   :config: {"theme": "forest"}

   flowchart LR
     A --> B --> C

Auto Class Diagrams

Generate class hierarchy diagrams from Python code:

.. autoclasstree:: mypackage.MyClass
   :full:
   :namespace: mypackage
   :caption: Class hierarchy

Documentation

Full documentation is available at drillan.github.io/sphinx-oceanid or in the docs/ directory.

License

BSD-3-Clause. See LICENSE for details.

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

Uploaded Source

Built Distribution

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

sphinx_oceanid-0.1.1-py3-none-any.whl (24.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: sphinx_oceanid-0.1.1.tar.gz
  • Upload date:
  • Size: 18.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sphinx_oceanid-0.1.1.tar.gz
Algorithm Hash digest
SHA256 2e15add21dd38de4754426bcb509e7a56cd1a5c7b9d2fd75baafbf278358540c
MD5 4bbbed8447283c5f019052f86c8d6763
BLAKE2b-256 d6302b670ad8d7abb0bb2e43ffb3d2ad48b991495deec0d55a636350d775ac0c

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_oceanid-0.1.1.tar.gz:

Publisher: publish.yml on drillan/sphinx-oceanid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

  • Download URL: sphinx_oceanid-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 24.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for sphinx_oceanid-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 80bc331040f844ff04095f8ee799e210f8f9aa91987a5a05060cbfc46bc7215e
MD5 78d848fa45d27d689473c2f31ea8d32e
BLAKE2b-256 e88ef928347d937643c55c8fa7c0ef8b612a2b1b064898c77b65fa8f82d79ad2

See more details on using hashes here.

Provenance

The following attestation bundles were made for sphinx_oceanid-0.1.1-py3-none-any.whl:

Publisher: publish.yml on drillan/sphinx-oceanid

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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