Skip to content

Commit df581f0

Browse files
authored
chore: add small how to diagram section (AztecProtocol#3804)
Adding a small section on how to add diagrams to the yellow-paper.
1 parent 3030cc8 commit df581f0

File tree

1 file changed

+64
-0
lines changed

1 file changed

+64
-0
lines changed

yellow-paper/docs/intro.md

+64
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,70 @@ The details should be sufficient for some other engineering team to implement th
2424

2525
Some of the info we need to populate this document might have already been written in the top-level `docs/` dir of the monorepo. But the target audience is different. Reduce verbose prose. Remove monorepo code snippets (but note that simple pseudocode snippets to explain a protocol concept are fine). Don't describe components of the sandbox (that's an implementation detail and doesn't belong in this doc).
2626

27+
## Diagrams
28+
To increase the probability of diagrams being up to date we encourage you to write them in `mermaid`. Mermaid is a markdown-like language for generating diagrams and is supported by Docusaurus, so it will be rendered automatically for you.
29+
You simply create a codeblock specifying the language as `mermaid` and write your diagram in the codeblock. For example:
30+
```txt
31+
```mermaid
32+
graph LR
33+
A --> B
34+
B --> C
35+
C --> A
36+
```
37+
38+
```mermaid
39+
graph LR
40+
A --> B
41+
B --> C
42+
C --> A
43+
```
44+
Mermaid supports multiple types of diagrams, so finding one that suits your needs should be possible. Consult their [documentation](https://mermaid.js.org/intro/getting-started.html) or try out their [live editor](https://mermaid.live/) to see if they've got what you need.
45+
46+
When writing class diagrams, we recommend using the `classDiagram` type and composition arrows `*--` to represent extensions. Also for the sake of readability, add all the components in the class itself, including composite types. For example:
47+
48+
```txt
49+
```mermaid
50+
classDiagram
51+
class A{
52+
foo: Bar
53+
}
54+
class B{
55+
hip: Hap
56+
zap: Zip
57+
}
58+
class C{
59+
a: A
60+
b: B
61+
flip: Flap
62+
}
63+
C *-- A: a
64+
C *-- B: b
65+
```
66+
67+
```mermaid
68+
classDiagram
69+
class A{
70+
foo: Bar
71+
}
72+
class B{
73+
hip: Hap
74+
zap: Zip
75+
}
76+
class C{
77+
a: A
78+
b: B
79+
flip: Flap
80+
}
81+
C *-- A: a
82+
C *-- B: b
83+
```
84+
85+
### Mermaid doesn't cover my case, what should I do?
86+
If mermaid doesn't cover your case, please add both the rendered image and the source code to the documentation. Most of the tools for diagramming can export a non-rendered representation that can then be updated by other people. Please name it such that it is clear what tool was used.
87+
88+
This should allow us to keep the diagrams up to date, by allowing others to update them.
89+
90+
2791
## For each protocol feature
2892

2993
Describe the requirements.

0 commit comments

Comments
 (0)