Skip to content

Commit 7c0ccd4

Browse files
committed
Added documentation for native Mermaid integration (experimental)
1 parent 9203255 commit 7c0ccd4

File tree

12 files changed

+122
-22
lines changed

12 files changed

+122
-22
lines changed
34.4 KB
Loading

docs/insiders.md

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,7 @@ The following features are currently exclusively available to sponsors:
104104
- [x] [Versioning][14]
105105
- [x] [Site language selection][13]
106106
- [x] [Sticky navigation tabs][19]
107+
- [x] [Native Mermaid.js integration][21]
107108
- [x] [Admonition inline blocks][12]
108109
- [x] [Search suggestions][16]
109110
- [x] [Search highlighting][17]
@@ -162,9 +163,15 @@ the public for general availability.
162163
[19]: setup/setting-up-navigation.md#sticky-navigation-tabs
163164
[20]: setup/setting-up-the-footer.md#remove-generator
164165

166+
#### $ 5,000 - Aji Panca
167+
168+
- [x] [Native Mermaid.js integration][21]
169+
170+
[21]: reference/diagrams.md
171+
165172
#### Future
166173

167-
- [ ] [Material for MkDocs Live Edit][21]
174+
- [ ] [Material for MkDocs Live Edit][22]
168175
- [ ] Improved search result summaries
169176
- [ ] List of last searches
170177
- [ ] Table of contents follows active anchor
@@ -174,7 +181,7 @@ the public for general availability.
174181
- [ ] New layouts and styles (e.g. vertical)
175182
- [ ] ... and much more ...
176183

177-
[21]: https://twitter.com/squidfunk/status/1338252230265360391
184+
[22]: https://twitter.com/squidfunk/status/1338252230265360391
178185

179186
### Goals completed
180187

@@ -210,10 +217,10 @@ implemented behind feature flags; all configuration changes are
210217
backward-compatible. This means that your users will be able to build the
211218
documentation locally with Material for MkDocs and when they push their changes,
212219
it can be built with Insiders (e.g. as part of GitHub Actions). Thus, it's
213-
recommended to [install Insiders][22] only in CI, as you don't want to expose
220+
recommended to [install Insiders][23] only in CI, as you don't want to expose
214221
your `GH_TOKEN` to users.
215222

216-
[22]: publishing-your-site.md#github-pages
223+
[23]: publishing-your-site.md#github-pages
217224

218225
### Terms
219226

@@ -222,7 +229,7 @@ commercial project. Can we use Insiders under the same terms and conditions?_
222229

223230
Yes. Whether you're an individual or a company, you may use _Material for MkDocs
224231
Insiders_ precisely under the same terms as Material for MkDocs, which are given
225-
by the [MIT license][23]. However, we kindly ask you to respect the following
232+
by the [MIT license][24]. However, we kindly ask you to respect the following
226233
guidelines:
227234

228235
- Please __don't distribute the source code__ of Insiders. You may freely use
@@ -233,7 +240,7 @@ guidelines:
233240
- If you cancel your subscription, you're removed as a collaborator and will
234241
miss out on future updates of Insiders. However, you may __use the latest
235242
version__ that's available to you __as long as you like__. Just remember that
236-
[GitHub deletes private forks][24].
243+
[GitHub deletes private forks][25].
237244

238-
[23]: license.md
239-
[24]: https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/removing-a-collaborator-from-a-personal-repository
245+
[24]: license.md
246+
[25]: https://docs.github.com/en/github/setting-up-and-managing-your-github-user-account/removing-a-collaborator-from-a-personal-repository

docs/reference/diagrams.md

Lines changed: 99 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,99 @@
1+
---
2+
template: overrides/main.html
3+
---
4+
5+
# Diagrams
6+
7+
Diagrams help to communicate complex relationships and interconnections between
8+
different technical components, and are a great addition to project
9+
documentation. Material for MkDocs integrates with [Mermaid.js][1], a very
10+
popular and flexible solution for drawing diagrams.
11+
12+
[1]: https://mermaid-js.github.io/mermaid/
13+
14+
## Configuration
15+
16+
### SuperFences
17+
18+
[:octicons-file-code-24: Source][2] ·
19+
:octicons-beaker-24: Experimental ·
20+
[:octicons-heart-fill-24:{: .tx-heart } Insiders only][2]{: .tx-insiders }
21+
22+
The [SuperFences][3] extension, which is part of [Python Markdown
23+
Extensions][4], allows for adding __custom fences__, which can be used to
24+
render [Mermaid.js][1] diagrams with zero effort:
25+
26+
``` yaml
27+
markdown_extensions:
28+
- pymdownx.superfences
29+
custom_fences:
30+
- name: mermaid
31+
class: mermaid-experimental
32+
format: !!pymdownx.superfences.fence_code_format
33+
```
34+
35+
No further configuration is necessary. Material for MkDocs will automatically
36+
load and initialize the [Mermaid.js][1] runtime when a page includes a [fenced
37+
`mermaid` block][5]. Furthermore:
38+
39+
- [x] Works with [instant loading][6] without any additional effort
40+
- [x] Diagrams automatically use fonts and colors defined in `mkdocs.yml`[^1]
41+
- [x] Fonts and colors can be customized with [additional stylesheets][7]
42+
- [x] Support for both, light and dark color schemes
43+
44+
_While it's also possible to integrate [Mermaid.js][1] using existing
45+
third-party solutions[^2], the new native integration is recommended as it
46+
ensures interoperability with all Material for MkDocs features._
47+
48+
[^1]:
49+
While all [Mermaid.js][1] features should work out-of-the-box, Material for
50+
MkDocs will currently only adjust the fonts and colors for flow charts,
51+
class and state diagrams. Support for further diagram types will be added
52+
gradually.
53+
54+
[^2]:
55+
If you don't want to use the native integration, [mkdocs-mermaid2-plugin][8]
56+
might be a good alternative. However, note that this plugin cannot be used
57+
in conjunction with the [mkdocs-minify-plugin][9] and doesn't integrate
58+
natively.
59+
60+
[2]: ../insiders.md
61+
[3]: https://facelessuser.github.io/pymdown-extensions/extensions/superfences/
62+
[4]: https://facelessuser.github.io/pymdown-extensions/
63+
[5]: #usage
64+
[6]: ../setup/setting-up-navigation.md#instant-loading
65+
[7]: ../customization.md#additional-css
66+
[8]: https://github.com/fralau/mkdocs-mermaid2-plugin
67+
[9]: https://github.com/byrnereese/mkdocs-minify-plugin
68+
69+
## Usage
70+
71+
### Using diagrams
72+
73+
Mermaid diagrams are written as [code blocks][10] with the help of the
74+
[SuperFences][11] extension. They must be enclosed with two separate lines
75+
containing three backticks:
76+
77+
_Example_:
78+
79+
```` markdown
80+
``` mermaid
81+
graph LR
82+
A[Start] --> B{Error?};
83+
B -->|Yes| C[Hmm...];
84+
C --> D[Debug];
85+
D --> B;
86+
B ---->|No| E[Yay!];
87+
```
88+
````
89+
90+
_Result_:
91+
92+
[![Diagram][12]{: style="width: 100%; max-width: 594px" }][12]
93+
94+
_See the [official documentation][1] to learn about all available diagram
95+
types._
96+
97+
[10]: code-blocks.md
98+
[11]: #superfences
99+
[12]: ../assets/screenshots/diagram.png

docs/reference/mathjax.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ information._
6767
!!! tip "Using MathJax with [instant loading][9]"
6868

6969
There's no additional effort necessary to integrate _MathJax 3_ with
70-
[instant loading][7] – it's expected to work straight away. However, a
70+
[instant loading][9] – it's expected to work straight away. However, a
7171
previous version of this document explained how to integrate Material for
7272
MkDocs with _MathJax 2_, which doesn't exhibit this behavior. It's therefore
7373
highly recommended to switch to _MathJax 3_.

material/assets/javascripts/bundle.ab328eb8.min.js renamed to material/assets/javascripts/bundle.83e5331e.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.83e5331e.min.js.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

material/assets/javascripts/bundle.ab328eb8.min.js.map

Lines changed: 0 additions & 1 deletion
This file was deleted.

material/assets/manifest.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
2-
"assets/javascripts/bundle.js": "assets/javascripts/bundle.ab328eb8.min.js",
3-
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.ab328eb8.min.js.map",
2+
"assets/javascripts/bundle.js": "assets/javascripts/bundle.83e5331e.min.js",
3+
"assets/javascripts/bundle.js.map": "assets/javascripts/bundle.83e5331e.min.js.map",
44
"assets/javascripts/vendor.js": "assets/javascripts/vendor.93c04032.min.js",
55
"assets/javascripts/vendor.js.map": "assets/javascripts/vendor.93c04032.min.js.map",
66
"assets/javascripts/worker/search.js": "assets/javascripts/worker/search.8c7e0a7e.min.js",

material/base.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ <h1>{{ page.title | d(config.site_name, true)}}</h1>
185185
</div>
186186
{% block scripts %}
187187
<script src="{{ 'assets/javascripts/vendor.93c04032.min.js' | url }}"></script>
188-
<script src="{{ 'assets/javascripts/bundle.ab328eb8.min.js' | url }}"></script>
188+
<script src="{{ 'assets/javascripts/bundle.83e5331e.min.js' | url }}"></script>
189189
{%- set translations = {} -%}
190190
{%- for key in [
191191
"clipboard.copy",

mkdocs.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ nav:
176176
- Code blocks: reference/code-blocks.md
177177
- Content tabs: reference/content-tabs.md
178178
- Data tables: reference/data-tables.md
179+
- Diagrams: reference/diagrams.md
179180
- Footnotes: reference/footnotes.md
180181
- Formatting: reference/formatting.md
181182
- Icons + Emojis: reference/icons-emojis.md

0 commit comments

Comments
 (0)