Skip to main content

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
  • YAML frontmatter — Set title and per-diagram config via Mermaid frontmatter in .mmd files and RST
  • 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 .

Claude Code Skill (Optional)

This repository ships a mermaid-diagram skill for AI coding agents. It provides proactive diagram suggestions, syntax validation, and ready-made examples for all 6 supported diagram types.

Install it with gh skill install (preview, requires GitHub CLI 2.91+):

gh skill install drillan/sphinx-oceanid mermaid-diagram --agent claude-code

Supported --agent values: claude-code, github-copilot, cursor, codex, gemini, antigravity.

Use --scope user to install globally instead of per-project. See docs/install.md for details, version pinning, and update workflow.

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: True)
oceanid_zoom = False

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

# 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

YAML Frontmatter

External .mmd files can include YAML frontmatter to set the diagram title and per-diagram rendering options:

---
title: User Authentication Flow
config:
  bg: "#1a1b26"
  fg: "#a9b1d6"
---
flowchart TD
  A[Login Page] --> B{Valid credentials?}
  B -->|Yes| C[Dashboard]
  B -->|No| D[Error Message]

Frontmatter is also supported in RST inline content. In MyST Markdown, use directive options with JSON format for config. See the documentation for details.

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.

Metadata

Release files for sphinx-oceanid 0.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sphinx-oceanid 0.2.0
File Size Uploaded
sphinx_oceanid-0.2.0.tar.gz 19.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for sphinx-oceanid 0.2.0
File Interpreter ABI Platform
sphinx_oceanid-0.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 46.5 kB

Release files / sphinx_oceanid-0.2.0.tar.gz

Download URL sphinx_oceanid-0.2.0.tar.gz
Size 19.9 kB
Tags Source
SHA-256 checksum
How to use checksums
de90f6fa90d649b7e024c8f55e5919396eb2f60135d3e948c27b86b3f01edb7a
BLAKE2b-256 checksum
How to use checksums
39bb4d3078c556ee6fd20b3d4df3d2e5f6d8d628969aeac2f8d3092530220cd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release files / sphinx_oceanid-0.2.0-py3-none-any.whl

Download URL sphinx_oceanid-0.2.0-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b19c0de332bd0de27a9bfc0221667ffce5605fe4af4e44028cd94e461c48dff7
BLAKE2b-256 checksum
How to use checksums
cf934053b2aad76147da93d0910748379a108dbc098b90ddfef001c80b50ea39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Apr 29, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.0 This release

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page