Skip to content

Commit bda06fe

Browse files
committed
Edit docs
1 parent 6be1f37 commit bda06fe

File tree

1 file changed

+135
-67
lines changed

1 file changed

+135
-67
lines changed

docs/syntax/diagrams.md

Lines changed: 135 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,52 @@
11
# Diagrams
22

3-
You can embedd diagrams using [mermaid.js](https://mermaid.js.org)
3+
You can create and embed diagrams using Mermaid.js, a docs-as-code diagramming tool.
44

5-
## Flowcharts
5+
Using Mermaid diagrams has several advantages:
6+
7+
- Diagrams as code: You can version and edit diagrams without having to use third-party tools.
8+
- Easier contribution: External contributors can add or edit new diagrams easily.
9+
- Consistent look and feel: All Mermaid diagrams are rendered using the same style.
10+
- Improved accessibility: Text can be copied and read by a text-to-speech engine.
11+
12+
## Create Mermaid diagrams
13+
14+
To create a Mermaid, you can use the following editors:
15+
16+
- [Mermaid Live Editor](https://mermaid.live/): Instantly previews Mermaid diagrams.
17+
- [Mermaid Chart](https://www.mermaidchart.com/app/dashboard): Visual editor for Mermaid.
18+
- Create diagrams in Visual Studio Code and preview them using the [VS Code extension](https://docs.mermaidchart.com/plugins/visual-studio-code).
19+
- Other tools, including AI tools, can generate Mermaid diagrams.
20+
21+
For reference documentation on the Mermaid language, refer to [mermaid.js](https://mermaid.js.org).
22+
23+
## Syntax guidelines
24+
25+
When creating Mermaid diagrams, keep these guidelines in mind:
26+
27+
- Use clear, descriptive node names.
28+
- Use comments (`%% comment text`) to document complex diagrams.
29+
- Break complex diagrams into smaller, more manageable ones.
30+
- Use consistent naming conventions throughout your diagrams.
31+
32+
## Supported Diagram Types
33+
34+
Mermaid.js supports various diagram types to visualize different kinds of information:
35+
36+
- Flowcharts: Visualize processes and workflows.
37+
- Sequence Diagrams: Show interactions between components over time.
38+
- Gantt Charts: Illustrate project schedules and timelines.
39+
- Class Diagrams: Represent object-oriented structures.
40+
- Entity Relationship Diagrams: Model database structures.
41+
- State Diagrams: Illustrate state machines and transitions.
42+
- Pie Charts: Display proportional data.
43+
- User Journey Maps: Visualize user experiences.
44+
45+
For a full list of supported diagrams, see the [Mermaid.js](https://mermaid.js.org/intro/) documentation.
46+
47+
### Flowcharts
48+
49+
This is an example flowchart made with Mermaid:
650

751
:::::{tab-set}
852

@@ -43,8 +87,13 @@ D <--> J[JATS]
4387
:::::
4488

4589

46-
## Sequence Diagram
90+
### Sequence diagrams
4791

92+
This is an example sequence diagram made with Mermaid:
93+
94+
:::::{tab-set}
95+
96+
::::{tab-item} Output
4897

4998
```mermaid
5099
sequenceDiagram
@@ -60,7 +109,35 @@ sequenceDiagram
60109
Bob-->>John: Jolly good!
61110
```
62111

63-
## Gant charts
112+
::::
113+
114+
::::{tab-item} Markdown
115+
````markdown
116+
```mermaid
117+
sequenceDiagram
118+
participant Alice
119+
participant Bob
120+
Alice->>John: Hello John, how are you?
121+
loop HealthCheck
122+
John->>John: Fight against hypochondria
123+
end
124+
Note right of John: Rational thoughts <br/>prevail!
125+
John-->>Alice: Great!
126+
John->>Bob: How about you?
127+
Bob-->>John: Jolly good!
128+
```
129+
````
130+
::::
131+
132+
:::::
133+
134+
### Gantt charts
135+
136+
This is an example Gantt chart made with Mermaid:
137+
138+
:::::{tab-set}
139+
140+
::::{tab-item} Output
64141

65142
```mermaid
66143
gantt
@@ -75,7 +152,34 @@ Future task : des3, after des2, 5d
75152
Future task2 : des4, after des3, 5d
76153
```
77154

78-
## Class Diagram
155+
::::
156+
157+
::::{tab-item} Markdown
158+
````markdown
159+
```mermaid
160+
gantt
161+
dateFormat YYYY-MM-DD
162+
title Adding GANTT diagram to mermaid
163+
excludes weekdays 2014-01-10
164+
165+
section A section
166+
Completed task :done, des1, 2014-01-06,2014-01-08
167+
Active task :active, des2, 2014-01-09, 3d
168+
Future task : des3, after des2, 5d
169+
Future task2 : des4, after des3, 5d
170+
```
171+
````
172+
::::
173+
174+
:::::
175+
176+
### Class diagrams
177+
178+
This is an example class diagram made with Mermaid:
179+
180+
:::::{tab-set}
181+
182+
::::{tab-item} Output
79183

80184
```mermaid
81185
classDiagram
@@ -94,71 +198,35 @@ Class01 : int gorilla
94198
Class08 <--> C2: Cool label
95199
```
96200

97-
## Git Graph
98-
99-
```mermaid
100-
gitGraph
101-
commit
102-
commit
103-
branch develop
104-
commit
105-
commit
106-
commit
107-
checkout main
108-
commit
109-
commit
110-
```
111-
112-
113-
## Entity Relation Diagram
114-
115-
```mermaid
116-
erDiagram
117-
CUSTOMER ||--o{ ORDER : places
118-
ORDER ||--|{ LINE-ITEM : contains
119-
CUSTOMER }|..|{ DELIVERY-ADDRESS : uses
120-
```
121-
122-
## User Journey
201+
::::
123202

124-
```mermaid
125-
journey
126-
title My working day
127-
section Go to work
128-
Make tea: 5: Me
129-
Go upstairs: 3: Me
130-
Do work: 1: Me, Cat
131-
section Go home
132-
Go downstairs: 5: Me
133-
Sit down: 5: Me
203+
::::{tab-item} Markdown
204+
````markdown
205+
```mermaid
206+
classDiagram
207+
Class01 <|-- AveryLongClass : Cool
208+
Class03 *-- Class04
209+
Class05 o-- Class06
210+
Class07 .. Class08
211+
Class09 --> C2 : Where am i?
212+
Class09 --* C3
213+
Class09 --|> Class07
214+
Class07 : equals()
215+
Class07 : Object[] elementData
216+
Class01 : size()
217+
Class01 : int chimp
218+
Class01 : int gorilla
219+
Class08 <--> C2: Cool label
134220
```
221+
````
222+
::::
135223

136-
## Quadrant Chart
224+
:::::
137225

138-
```mermaid
139-
quadrantChart
140-
title Reach and engagement of campaigns
141-
x-axis Low Reach --> High Reach
142-
y-axis Low Engagement --> High Engagement
143-
quadrant-1 We should expand
144-
quadrant-2 Need to promote
145-
quadrant-3 Re-evaluate
146-
quadrant-4 May be improved
147-
Campaign A: [0.3, 0.6]
148-
Campaign B: [0.45, 0.23]
149-
Campaign C: [0.57, 0.69]
150-
Campaign D: [0.78, 0.34]
151-
Campaign E: [0.40, 0.34]
152-
Campaign F: [0.35, 0.78]
153-
```
226+
## Troubleshooting
154227

155-
## XY Chart
228+
These are the most common issues when creating Mermaid diagrams and their solution:
156229

157-
```mermaid
158-
xychart-beta
159-
title "Sales Revenue"
160-
x-axis [jan, feb, mar, apr, may, jun, jul, aug, sep, oct, nov, dec]
161-
y-axis "Revenue (in $)" 4000 --> 11000
162-
bar [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
163-
line [5000, 6000, 7500, 8200, 9500, 10500, 11000, 10200, 9200, 8500, 7000, 6000]
164-
```
230+
- Syntax errors: Ensure proper indentation and syntax.
231+
- Rendering issues: Check for unsupported characters or syntax.
232+
- Performance: Simplify diagrams with many nodes for better performance.

0 commit comments

Comments
 (0)