Skip to content

Commit

Permalink
Add mdbook-mermaid (#26426)
Browse files Browse the repository at this point in the history
  • Loading branch information
t3chguy authored Oct 26, 2023
1 parent de2d3ff commit 588e056
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 66 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ jobs:
with:
mdbook-version: "0.4.10"

- name: Install mdbook-combiner
run: cargo install mdbook-combiner
- name: Install mdbook extensions
run: cargo install mdbook-combiner mdbook-mermaid

- name: Prepare docs
run: |
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,5 @@ electron/pub
/src/modules.ts
/build_config.yaml
/book
/mermaid*
/index.html
6 changes: 6 additions & 0 deletions book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,9 @@ git-repository-url = "https://github.com/vector-im/element-web"

# The path that the docs are hosted on
site-url = "/element-web/"
additional-js = ["mermaid.min.js", "mermaid-init.js"]

[preprocessor]

[preprocessor.mermaid]
command = "mdbook-mermaid"
147 changes: 83 additions & 64 deletions docs/app-load.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,78 +4,67 @@
been kept untouched for posterity.

Old slow flow:
![image](https://user-images.githubusercontent.com/2403652/73848963-00a2a080-4821-11ea-97d4-1200fc2638f3.png)

Current more parallel flow:
![image](https://user-images.githubusercontent.com/2403652/83146440-303a2900-a0ee-11ea-806b-4f53f039b957.png)

<details><summary>Code</summary>
<p>
<pre><code>
digraph G {
node [shape=box];

subgraph cluster_0 {
color=orange;
node [style=filled];
label = "index.ts";

entrypoint, s0, ready [shape=point];
rageshake, config, i18n, theme, skin, olm [shape=parallelogram];
mobile [shape=diamond, label="mobile"];
modernizr [shape=diamond];
redirect, incompatible [shape=egg];

entrypoint -> rageshake;
rageshake -> mobile [color=blue];
mobile -> s0 [label="No"];
mobile -> redirect [label="Yes"];

s0 -> platform;
s0 -> olm;
platform -> config;

config -> i18n [color=blue];
config -> theme [color=blue];
config -> skin [color=blue];

i18n -> modernizr [color=blue];
theme -> modernizr [color=blue];
skin -> modernizr [color=blue];
```mermaid
flowchart TD
A1(((load_modernizr))) --> B
A2((rageshake)) --> B
B(((skin))) --> C
C(((olm))) --> D
D{mobile} --> E
E((config)) --> F
F((i18n)) --> G
style F stroke:lime
G(((theme))) --> H
H(((modernizr))) --> app
style H stroke:red
```

modernizr -> ready [label="Yes"];
modernizr -> incompatible [label="No"];
incompatible -> ready [label="user ignore"];

olm -> ready [color=red];
config -> ready [color=red];
skin -> ready [color=red];
theme -> ready [color=red];
i18n -> ready [color=red];

}

subgraph cluster_1 {
color = green;
node [style=filled];
label = "init.tsx";

ready -> loadApp;
loadApp -> matrixchat;

}
}
</code></pre>
Current more parallel flow:

</p>
</details>
```mermaid
flowchart TD
subgraph index.ts
style index.ts stroke:orange
A[/rageshake/] --> B{mobile}
B-- No -->C1(.)
B-- Yes -->C2((redirect))
C1 --> D[/olm/] --> R
C1 --> E[platform] --> F[/config/]
F --> G1[/skin/]
F --> R
G1 --> H
G1 --> R
F --> G2[/theme/]
G2 --> H
G2 --> R
F --> G3[/i18n/]
G3 --> H
G3 --> R
H{modernizr}-- No --> J((incompatible))-- user ignore --> R
H-- Yes --> R
linkStyle 0,7,9,11,12,14,15 stroke:blue;
linkStyle 4,8,10,13,16 stroke:red;
end
R>ready] --> 2A
style R stroke:gray
subgraph init.tsx
style init.tsx stroke:lime
2A[loadApp] --> 2B[matrixchat]
end
```

Key:

- Parallelogram: async/await task
- Box: sync task
- Diamond: conditional branch
- Egg: user interaction
- Circle: user interaction
- Blue arrow: async task is allowed to settle but allowed to fail
- Red arrow: async task success is asserted

Expand All @@ -86,4 +75,34 @@ Notes:
- Everything is awaited to be settled before the Modernizr check, to allow it to make use of things like i18n if they are successful.

Underlying dependencies:
![image](https://user-images.githubusercontent.com/2403652/73848977-08624500-4821-11ea-9830-bb0317c41086.png)

```mermaid
flowchart TD
A((rageshake))
B{mobile}
C((config))
D(((olm)))
E((i18n))
F(((load_modernizr)))
G(((modernizr)))
H(((skin)))
I(((theme)))
X[app]
A --> G
A --> B
A-- assert -->X
F --> G --> X
G --> H --> X
C --> I --> X
C --> E --> X
E --> G
B --> C-- assert -->X
B --> D --> X
style X stroke:red
style G stroke:red
style E stroke:lime
linkStyle 0,11 stroke:yellow;
linkStyle 2,13 stroke:red;
```

0 comments on commit 588e056

Please sign in to comment.