Skip to content

Commit a8a075a

Browse files
committed
Update docs
1 parent 5678df9 commit a8a075a

File tree

2 files changed

+80
-20
lines changed

2 files changed

+80
-20
lines changed

docs/_docset.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ toc:
8686
- file: code.md
8787
- file: comments.md
8888
- file: conditionals.md
89+
- file: diagrams.md
8990
- file: dropdowns.md
9091
- file: definition-lists.md
9192
- file: example_blocks.md

docs/syntax/diagram.md renamed to docs/syntax/diagrams.md

Lines changed: 79 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
1-
# Diagram Directive
1+
# Diagrams
22

33
The `diagram` directive allows you to render various types of diagrams using the [Kroki](https://kroki.io/) service. Kroki supports many diagram types including Mermaid, D2, Graphviz, PlantUML, and more.
44

5-
## Basic Usage
5+
## Basic usage
66

77
The basic syntax for the diagram directive is:
88

@@ -14,7 +14,7 @@ The basic syntax for the diagram directive is:
1414

1515
If no diagram type is specified, it defaults to `mermaid`.
1616

17-
## Supported Diagram Types
17+
## Supported diagram types
1818

1919
The diagram directive supports the following diagram types:
2020

@@ -35,8 +35,12 @@ The diagram directive supports the following diagram types:
3535

3636
## Examples
3737

38-
### Mermaid Flowchart (Default)
38+
### Mermaid flowchart (default)
3939

40+
::::::{tab-set}
41+
42+
:::::{tab-item} Source
43+
```markdown
4044
::::{diagram}
4145
flowchart LR
4246
A[Start] --> B{Decision}
@@ -45,35 +49,101 @@ flowchart LR
4549
C --> E[End]
4650
D --> E
4751
::::
52+
```
53+
:::::
54+
55+
:::::{tab-item} Rendered
56+
::::{diagram}
57+
flowchart LR
58+
A[Start] --> B{Decision}
59+
B -->|Yes| C[Action 1]
60+
B -->|No| D[Action 2]
61+
C --> E[End]
62+
D --> E
63+
::::
64+
:::::
65+
66+
::::::
4867

49-
### Mermaid Sequence Diagram
68+
### Mermaid sequence diagram
5069

70+
::::::{tab-set}
71+
72+
:::::{tab-item} Source
73+
```markdown
74+
::::{diagram} mermaid
75+
sequenceDiagram
76+
participant A as Alice
77+
participant B as Bob
78+
A->>B: Hello Bob, how are you?
79+
B-->>A: Great!
80+
::::
81+
```
82+
:::::
83+
84+
:::::{tab-item} Rendered
5185
::::{diagram} mermaid
5286
sequenceDiagram
5387
participant A as Alice
5488
participant B as Bob
5589
A->>B: Hello Bob, how are you?
5690
B-->>A: Great!
5791
::::
92+
:::::
93+
94+
::::::
5895

59-
### D2 Diagram
96+
### D2 diagram
6097

98+
::::::{tab-set}
99+
100+
:::::{tab-item} Source
101+
```markdown
61102
::::{diagram} d2
62103
x -> y: hello world
63104
y -> z: nice to meet you
64105
::::
106+
```
107+
:::::
65108

66-
### Graphviz Diagram
109+
:::::{tab-item} Rendered
110+
::::{diagram} d2
111+
x -> y: hello world
112+
y -> z: nice to meet you
113+
::::
114+
:::::
67115

116+
::::::
117+
118+
### Graphviz diagram
119+
120+
::::::{tab-set}
121+
122+
:::::{tab-item} Source
123+
```markdown
68124
::::{diagram} graphviz
69125
digraph G {
70126
rankdir=LR;
71127
A -> B -> C;
72128
A -> C;
73129
}
74130
::::
131+
```
132+
:::::
75133

76-
## How It Works
134+
:::::{tab-item} Rendered
135+
::::{diagram} graphviz
136+
digraph G {
137+
rankdir=LR;
138+
A -> B -> C;
139+
A -> C;
140+
}
141+
::::
142+
:::::
143+
144+
::::::
145+
146+
## How it works
77147

78148
The diagram directive:
79149

@@ -83,17 +153,6 @@ The diagram directive:
83153
4. **Generates** a Kroki URL in the format: `https://kroki.io/{type}/svg/{encoded-content}`
84154
5. **Renders** an HTML `<img>` tag that loads the diagram from Kroki
85155

86-
## Error Handling
156+
## Error handling
87157

88158
If the diagram content is empty or the encoding fails, an error message will be displayed instead of the diagram.
89-
90-
## Implementation Details
91-
92-
The diagram directive is implemented using:
93-
94-
- **DiagramBlock**: Parses the directive and extracts content
95-
- **DiagramEncoder**: Handles compression and encoding using the same algorithm as the Kroki documentation
96-
- **DiagramView**: Renders the final HTML with the Kroki URL
97-
- **Kroki Service**: External service that generates SVG diagrams from encoded content
98-
99-
The encoding follows the Kroki specification exactly, ensuring compatibility with all supported diagram types.

0 commit comments

Comments
 (0)