Supported Diagram Types¶
sphinx-oceanid uses beautiful-mermaid (an ELK.js-based rendering engine) instead of standard Mermaid.js. beautiful-mermaid supports 6 diagram types with high-quality layout. Standard Mermaid.js supports 20+ types, so diagrams outside these 6 types are not rendered.
Supported types¶
Type |
Alias |
Description |
|---|---|---|
|
|
Flow charts and directed graphs |
|
Interaction between processes over time |
|
|
UML class diagrams |
|
|
|
State machine diagrams |
|
Entity-relationship diagrams |
|
|
XY charts (bar, line) |
Examples¶
flowchart / graph¶
.. mermaid::
flowchart LR
A[Start] --> B{Decision}
B -->|Yes| C[OK]
B -->|No| D[Cancel]
```{mermaid}
flowchart LR
A[Start] --> B{Decision}
B -->|Yes| C[OK]
B -->|No| D[Cancel]
```
Note
Known limitations
clickevents are not supportedBidirectional arrow (
<-->) has an SVG rendering bug (beautiful-mermaid#58)
The graph keyword is an alias for flowchart:
.. mermaid::
graph TD
A --> B
B --> C
```{mermaid}
graph TD
A --> B
B --> C
```
Subgraphs¶
Nested subgraphs with direction override:
.. mermaid::
flowchart TB
subgraph Frontend
direction LR
A[Browser] --> B[React App]
end
subgraph Backend
direction LR
C[API Server] --> D[(Database)]
end
Frontend --> Backend
```{mermaid}
flowchart TB
subgraph Frontend
direction LR
A[Browser] --> B[React App]
end
subgraph Backend
direction LR
C[API Server] --> D[(Database)]
end
Frontend --> Backend
```
Node shapes, edge styles, and classDef¶
Various node shapes, edge styles (dotted -.->, thick ==>), and classDef styling:
.. mermaid::
flowchart LR
classDef accent fill:#f9f,stroke:#333
A([Terminal]) ==> B{Diamond}
B -.->|Option 1| C[(Cylinder)]
B -->|Option 2| D{{Hexagon}}
A & B --> E((Circle))
class A accent
```{mermaid}
flowchart LR
classDef accent fill:#f9f,stroke:#333
A([Terminal]) ==> B{Diamond}
B -.->|Option 1| C[(Cylinder)]
B -->|Option 2| D{{Hexagon}}
A & B --> E((Circle))
class A accent
```
sequenceDiagram¶
.. mermaid::
sequenceDiagram
participant Alice
participant Bob
Alice->>Bob: Hello Bob
Bob-->>Alice: Hi Alice
Alice->>Bob: How are you?
Bob-->>Alice: Fine, thanks!
```{mermaid}
sequenceDiagram
participant Alice
participant Bob
Alice->>Bob: Hello Bob
Bob-->>Alice: Hi Alice
Alice->>Bob: How are you?
Bob-->>Alice: Fine, thanks!
```
TCP handshake and connection lifecycle¶
participant aliases, activation via +/- shorthand, Note, loop, and alt/else blocks — modeled on TCP 3-way handshake, data transfer, and connection teardown:
.. mermaid::
sequenceDiagram
participant C as Client
participant S as Server
Note over C, S: 3-way handshake
C ->>+ S: SYN
S -->>- C: SYN-ACK
C ->> S: ACK
loop Data transfer
C ->>+ S: Request
alt Success
S -->>- C: 200 OK
else Error
S -->> C: 500
end
end
Note over C, S: Connection teardown
C ->> S: FIN
S -->> C: FIN-ACK
```{mermaid}
sequenceDiagram
participant C as Client
participant S as Server
Note over C, S: 3-way handshake
C ->>+ S: SYN
S -->>- C: SYN-ACK
C ->> S: ACK
loop Data transfer
C ->>+ S: Request
alt Success
S -->>- C: 200 OK
else Error
S -->> C: 500
end
end
Note over C, S: Connection teardown
C ->> S: FIN
S -->> C: FIN-ACK
```
Note
Known limitations
autonumberis not supportedboxgroups are not supportedcreate/destroy(dynamic actor lifecycle) are not supportedExplicit
activate/deactivatecommands are not supported (+/-shorthand only)A note placed before the first message is silently dropped (beautiful-mermaid#53)
classDiagram¶
.. mermaid::
classDiagram
Animal <|-- Duck
Animal <|-- Fish
Animal : +String name
Animal : +move()
Duck : +swim()
Fish : +swim()
```{mermaid}
classDiagram
Animal <|-- Duck
Animal <|-- Fish
Animal : +String name
Animal : +move()
Duck : +swim()
Fish : +swim()
```
Class blocks, annotations, relationships, and generics¶
Class blocks with visibility markers, <<abstract>> annotation, generics (~T~), and multiple relationship types with cardinality:
.. mermaid::
classDiagram
class Animal {
<<abstract>>
+String name
+move()* void
}
class List~T~ {
+get(index int) T
}
Animal <|-- Duck
Animal *-- "1" Heart
Duck ..|> Swimmable
```{mermaid}
classDiagram
class Animal {
<<abstract>>
+String name
+move()* void
}
class List~T~ {
+get(index int) T
}
Animal <|-- Duck
Animal *-- "1" Heart
Duck ..|> Swimmable
```
Auto-generated from Python code¶
The autoclasstree directive generates class diagrams from Python class hierarchies automatically. This example visualizes the Sphinx role class hierarchy:
.. autoclasstree:: sphinx.roles
:strict:
:caption: Sphinx role class hierarchy
:zoom:
```{autoclasstree} sphinx.roles
:strict:
:caption: Sphinx role class hierarchy
:zoom:
```
Sphinx role class hierarchy
See sphinx-oceanid documentation for full autoclasstree options (:full:, :strict:, :namespace:).
Note
Known limitations
click/note/linkare not supportedclassDefassignments are not reflected in SVG output (beautiful-mermaid#80)
stateDiagram / stateDiagram-v2¶
.. mermaid::
stateDiagram-v2
[*] --> Active
Active --> Inactive : timeout
Inactive --> Active : input
Active --> [*] : quit
```{mermaid}
stateDiagram-v2
[*] --> Active
Active --> Inactive : timeout
Inactive --> Active : input
Active --> [*] : quit
```
Composite states and aliases¶
Composite (nested) states with direction override, and state aliases using state "Description" as id:
.. mermaid::
stateDiagram-v2
state "Waiting for input" as waiting
state Active {
direction LR
[*] --> Running
Running --> Paused : pause
Paused --> Running : resume
}
[*] --> waiting
waiting --> Active : start
Active --> [*] : stop
```{mermaid}
stateDiagram-v2
state "Waiting for input" as waiting
state Active {
direction LR
[*] --> Running
Running --> Paused : pause
Paused --> Running : resume
}
[*] --> waiting
waiting --> Active : start
Active --> [*] : stop
```
Both stateDiagram and stateDiagram-v2 keywords are supported.
Note
Known limitations
<<fork>>/<<join>>/<<choice>>pseudo-states are not supportedConcurrent states (
--separator) are not supportednoteis not supported
erDiagram¶
.. mermaid::
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
PRODUCT ||--o{ LINE-ITEM : "is in"
```{mermaid}
erDiagram
CUSTOMER ||--o{ ORDER : places
ORDER ||--|{ LINE-ITEM : contains
PRODUCT ||--o{ LINE-ITEM : "is in"
```
Entity attributes and relationship styles¶
Entity blocks with typed attributes (PK, FK, UK markers), all four cardinality types, and identifying (--) vs non-identifying (..) relationships:
.. mermaid::
erDiagram
CUSTOMER {
int id PK
string name
string email UK
}
ORDER {
int id PK
int customer_id FK
}
CUSTOMER ||--o{ ORDER : places
CUSTOMER |o..o| ADDRESS : "lives at"
```{mermaid}
erDiagram
CUSTOMER {
int id PK
string name
string email UK
}
ORDER {
int id PK
int customer_id FK
}
CUSTOMER ||--o{ ORDER : places
CUSTOMER |o..o| ADDRESS : "lives at"
```
Note
Known limitations
Entity aliases (
CUSTOMER["Customer"]) are not supported
xychart-beta¶
.. mermaid::
xychart-beta
title "Monthly Sales"
x-axis [Jan, Feb, Mar, Apr, May]
y-axis "Revenue (USD)" 0 --> 5000
bar [1200, 2400, 1800, 3600, 4200]
line [1200, 2400, 1800, 3600, 4200]
```{mermaid}
xychart-beta
title "Monthly Sales"
x-axis [Jan, Feb, Mar, Apr, May]
y-axis "Revenue (USD)" 0 --> 5000
bar [1200, 2400, 1800, 3600, 4200]
line [1200, 2400, 1800, 3600, 4200]
```
Numeric x-axis and horizontal orientation¶
Numeric x-axis range, axis titles, and horizontal orientation with multiple series:
.. mermaid::
xychart-beta horizontal
title "Score by Iteration"
x-axis "Iteration" 1 --> 5
y-axis "Score" 0 --> 100
bar [45, 62, 78, 85, 92]
line [40, 58, 73, 82, 90]
```{mermaid}
xychart-beta horizontal
title "Score by Iteration"
x-axis "Iteration" 1 --> 5
y-axis "Score" 0 --> 100
bar [45, 62, 78, 85, 92]
line [40, 58, 73, 82, 90]
```
Note
Known limitations
Named series labels are not supported (minor)
Unsupported diagram types¶
The following Mermaid diagram types are not supported by beautiful-mermaid and cannot be rendered by sphinx-oceanid:
Type |
Description |
|---|---|
|
Gantt charts |
|
Pie charts |
|
Git branch/commit graphs |
|
User journey maps |
|
Mind maps |
|
Timeline diagrams |
|
Sankey diagrams |
|
Quadrant charts |
|
Requirement diagrams |
|
C4 context diagrams |
|
C4 container diagrams |
|
C4 component diagrams |
|
C4 deployment diagrams |
|
Block diagrams |
|
Packet diagrams |
|
Kanban boards |
|
Architecture diagrams |
|
ZenUML sequence diagrams |
Behavior with unsupported types¶
When sphinx-oceanid encounters an unsupported diagram type, the behavior depends on the oceanid_unsupported_action configuration:
"warning" (default)¶
Sphinx outputs a warning message during the build, listing the unsupported type and the supported types
The build continues
In the output HTML, the diagram is replaced with an error message box showing:
The unsupported type name
The list of supported types
The original Mermaid source code
<div class="oceanid-unsupported">
<p class="oceanid-unsupported-message">
Diagram type "gantt" is not supported by sphinx-oceanid.
Supported types: flowchart, graph, sequenceDiagram, classDiagram,
stateDiagram, stateDiagram-v2, erDiagram, xychart-beta.
</p>
<pre class="oceanid-unsupported-code">gantt
title Project
...</pre>
</div>
"error"¶
Sphinx raises an error and the build fails immediately
# conf.py
oceanid_unsupported_action = "error"
sphinx-oceanid never silently degrades or falls back to standard Mermaid.js. Unsupported diagrams always produce explicit feedback.
Limitations¶
beautiful-mermaid limitations¶
6 diagram types only: beautiful-mermaid renders 6 types (listed above) vs 20+ types in standard Mermaid.js. This is a design choice for high-quality ELK.js-based layout
No server-side rendering: beautiful-mermaid is a client-side JavaScript library. Diagrams require a browser to render. LaTeX/PDF output is not supported
Silent failure on some syntax errors: beautiful-mermaid may render an incomplete diagram without raising an error if the Mermaid code contains certain syntax errors. Always verify your diagrams visually after building
sphinx-oceanid limitations¶
HTML output only: sphinx-oceanid produces HTML output. Other Sphinx builders (LaTeX, epub) are not supported
JavaScript required: Diagrams are rendered client-side. The
<noscript>element shows the raw Mermaid source code when JavaScript is disabled