Skip to content

Commit 8f7b0dd

Browse files
committed
Documentation
1 parent 479b60e commit 8f7b0dd

File tree

1 file changed

+36
-5
lines changed

1 file changed

+36
-5
lines changed

docs/reference/diagrams.md

Lines changed: 36 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ popular and flexible solution for drawing diagrams.
1616
<!-- md:version 8.2.0 -->
1717

1818
This configuration enables native support for [Mermaid.js] diagrams. Material
19-
for MkDocs will automatically initialize the JavaScript runtime when a page
19+
for MkDocs will automatically initialize the JavaScript runtime when a page
2020
includes a `mermaid` code block:
2121

2222
``` yaml
@@ -38,7 +38,7 @@ No further configuration is necessary. Advantages over a custom integration:
3838
[^1]:
3939
While all [Mermaid.js] features should work out-of-the-box, Material for
4040
MkDocs will currently only adjust the fonts and colors for flowcharts,
41-
sequence diagrams, class diagrams, state diagrams and entity relationship
41+
sequence diagrams, class diagrams, state diagrams and entity relationship
4242
diagrams. See the section on [other diagrams] for more information why this
4343
is currently not implemented for all diagrams.
4444

@@ -82,7 +82,7 @@ graph LR
8282

8383
### Using sequence diagrams
8484

85-
[Sequence diagrams] describe a specific scenario as sequential interactions
85+
[Sequence diagrams] describe a specific scenario as sequential interactions
8686
between multiple objects or actors, including the messages that are exchanged
8787
between those actors:
8888

@@ -194,7 +194,7 @@ classDiagram
194194
+int postalCode
195195
+String country
196196
-validate()
197-
+outputAsLabel()
197+
+outputAsLabel()
198198
}
199199
```
200200
````
@@ -226,7 +226,7 @@ classDiagram
226226
+int postalCode
227227
+String country
228228
-validate()
229-
+outputAsLabel()
229+
+outputAsLabel()
230230
}
231231
```
232232

@@ -283,3 +283,34 @@ we don't consider them a good choice, mostly as they don't work well on mobile.
283283
[user journeys]: https://mermaid.js.org/syntax/userJourney.html
284284
[git graphs]: https://mermaid.js.org/syntax/gitgraph.html
285285
[requirement diagrams]: https://mermaid.js.org/syntax/requirementDiagram.html
286+
287+
## Customization
288+
289+
If you want to customize Mermaid.js, e.g. to bring in support for [ELK layouts],
290+
you can do so by adding a custom JavaScript file to your `mkdocs.yml`:
291+
292+
=== ":octicons-file-code-16: `docs/javascripts/mermaid.mjs`"
293+
294+
``` js
295+
import mermaid from 'https://cdn.jsdelivr.net/npm/mermaid@11/dist/mermaid.esm.min.mjs';
296+
import elkLayouts from 'https://cdn.jsdelivr.net/npm/@mermaid-js/layout-elk@0/dist/mermaid-layout-elk.esm.min.mjs';
297+
298+
mermaid.registerLayoutLoaders(elkLayouts);
299+
mermaid.initialize({
300+
startOnLoad: false,
301+
securityLevel: "loose",
302+
layout: "elk",
303+
});
304+
305+
// Important: necessary to make it visible to Material for MkDocs
306+
window.mermaid = mermaid;
307+
```
308+
309+
=== ":octicons-file-code-16: `mkdocs.yml`"
310+
311+
``` yaml
312+
extra_javascript:
313+
- javascripts/mermaid.mjs
314+
```
315+
316+
[ELK layouts]: https://www.npmjs.com/package/@mermaid-js/layout-elk

0 commit comments

Comments
 (0)