LikeC4 for MkDocs
MkDocs plugin for embedding LikeC4 diagrams.
Requirements
Check out the sample Dockerfile for how you can provide the likec4 and graphviz dependencies.
Installation
- Install the plugin via
pip:pip install mkdocs-likec4 - Add the plugin to your
mkdocs.yml:plugins: - search - likec4
That's it! The plugin automatically:
- Discovers all projects by scanning for
likec4.config.jsonfiles (other configs formats are not supported yet!) - Generates separate web components for each project
- Loads web components into the document as required
Configuration
use_dot
By default mkdocs-likec4 uses the bundled WASM layout engine, matching the behaviour of the likec4 preview server.
You can opt into local graphviz binaries (which avoids known WASM memory issues) with use_dot: true. Note that this might result in a different layout than what the LikeC4 preview renders.
plugins:
- search
- likec4:
use_dot: true
color_scheme
Sets the default color scheme for all diagrams. Possible values:
auto(default): diagrams follow the current MkDocs theme and react instantly when the palette toggle is switched.light/dark: pins all diagrams to the chosen scheme.
plugins:
- search
- likec4:
color_scheme: light
Individual diagrams can override the global setting (see color-scheme below).
Usage
Use the likec4-view code block and specify the view-id in the body to embed a LikeC4 diagram:
```likec4-view
index
```
This will embed the diagram from the current LikeC4 project, or the root project if this is a single project setup.
View Options
You may provide the following options on the opening fence line:
-
browser=true|falseWhether to show views browser popup/Whether the view is interactive. Possible values:
trueorfalse(default:true) -
dynamic-variant=diagram|sequenceHow a dynamic view should be rendered. Possible values: diagram or sequence (default:
diagram) -
project=<project-name>The LikeC4 project to use for this view (for multi-project setups)
-
color-scheme=auto|light|darkOverrides the global color_scheme for this diagram.
autokeeps the diagram in sync with the MkDocs theme;light/darkpin it to that scheme.
Examples
Specify project
If you want to embed a diagram from a specific project outside the projects scope,
use the project parameter:
```likec4-view project=deployment
index
```
Danger
If you don't specify a project in a multi-project setup, and the page it not under a
likec4.config.json file, the build will fail:
Error: Specify exact project, known: [...]