https://github.com/landmaj/mkdocs-d2-plugin
A plugin for embedding D2 diagrams in MkDocs.
https://github.com/landmaj/mkdocs-d2-plugin
diagrams mkdocs mkdocs-plugin text-to-diagram
Last synced: 14 days ago
JSON representation
A plugin for embedding D2 diagrams in MkDocs.
- Host: GitHub
- URL: https://github.com/landmaj/mkdocs-d2-plugin
- Owner: landmaj
- License: mit
- Created: 2023-09-22T20:56:00.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2025-03-01T14:32:47.000Z (about 2 months ago)
- Last Synced: 2025-04-04T08:47:42.789Z (18 days ago)
- Topics: diagrams, mkdocs, mkdocs-plugin, text-to-diagram
- Language: Python
- Homepage: https://landmaj.github.io/mkdocs-d2-plugin/
- Size: 238 KB
- Stars: 28
- Watchers: 1
- Forks: 6
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# mkdocs-d2-plugin
A plugin for embedding D2 diagrams in MkDocs.
**Documentation and live demo can be found
[here](https://landmaj.github.io/mkdocs-d2-plugin/).**## Requirements
* [Python](https://www.python.org/) >= 3.9
* [MkDocs](https://www.mkdocs.org/) >= 1.6.0
* [D2](https://d2lang.com) >= 0.6.3## Installation
Install the plugin using pip:
```bash
pip install mkdocs-d2-plugin
```And add it to your `mkdocs.yml`:
```yaml
plugins:
- d2
```## Usage
### Fenced code block
````md
```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!
```
````### Image tag
```md

```## Demo app
You can find demo app in the `docs` directory.
Live version is available [here](https://landmaj.github.io/mkdocs-d2-plugin/).To run in locally:
```bash
cd docs
python3 -m venv .venv
source .venv/bin/activate
pip install mkdocs-material mkdocs-d2-plugin
mkdocs serve
```To run it using Docker:
```bash
cd docs
docker build --tag mkdocs-d2-plugin:latest .
docker run --rm -it -p 8000:8000 -v ${PWD}:/docs mkdocs-d2-plugin:latest
```