MkDocs plugin for D2
Project description
mkdocs-d2-plugin
A plugin for the MkDocs documentation site generator which automatically generates and embeds D2 diagrams.
Requirements
Installation
Install the plugin using pip:
pip install mkdocs-d2-plugin
And add it to your mkdocs.yml
:
plugins:
- d2
Usage
The plugin will automatically generate and embed D2 diagrams from code blocks
with the d2
language tag.
Example
```d2
shape: sequence_diagram
Alice -> John: Hello John, how are you?
Alice -> John.ack: John, can you hear me?
John.ack -> Alice: Hi Alice, I can hear you!
John -> Alice: I feel great!
```
Configuration
The plugin can be configured in your mkdocs.yml
file.
plugins:
- d2:
executable: d2
layout: dagre
theme: 0
dark_theme: False
sketch: False
pad: 100
scale: -1.0
force_appendix: False
Run d2 --help
for more information about the options.
Everything (except executable path) can be overriden locally.
```d2 sketch=true force_appendix=True
shape: sequence_diagram
Alice -> John: Hello John, how are you?
Alice -> John.ack: John, can you hear me?
John.ack -> Alice: Hi Alice, I can hear you!
John -> Alice: I feel great!
```
<rant>
Why this fenced code block format?
```d2 key=value
[...]
```
MkDocs uses python-markdown library, which expects key-value pairs in a following format:
```{ .d2 key="value" }
[...]
```
This breaks syntax highlighting in most editors. The format used by this plugin breaks python-markdown library instead, however the entire code block is replaced anyway, so it doesn't matter. And according to CommonMark specification it is a valid Markdown.
</rant>
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for mkdocs_d2_plugin-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 061d49e8f7ef6e24f40e285c9c5cff700e4e585a6659d706dfb1a8c1cd553ac2 |
|
MD5 | 22598767b547f1b65c324d182f1bb59c |
|
BLAKE2b-256 | 5c73874793496e3452dbd8dc5771e4bb95baa3bf4aea16d805581476221785f0 |