D2
v0.10.1Look up D2 syntax, render diagrams locally, and review animations with storyboards and motion lint.
These tools were reported by the server itself during our smoke test (tools/list), not copied from the README.
guide D2 language guide
Return the D2 language guide for the D2 version this server runs. Call it once before writing D2 if you have not read it in this conversation. Topic "core" covers syntax, house style and common mistakes. Topic "reference" lists every shape, style keyword, arrowhead, theme and layout engine.
| Parameter | Type | Description |
|---|---|---|
topic | string | core: syntax, house style and common mistakes. reference: every shape, style keyword, arrowhead, theme and layout engine. Default core. |
check Check D2 source
Check D2 source without rendering. Returns errors and advisory warnings with source positions. Warnings include a rule code. Set fmt to true to also get the canonically formatted source.
| Parameter | Type | Description |
|---|---|---|
fmt | boolean | Also return the canonically formatted source. Default false. |
layout | string | Override the diagram's layout engine for layout-dependent warnings. No layout is run. |
path | string | Path to a .d2 file, absolute or relative to the server root. Available only when the server was started with --root. Pass exactly one of source and path. |
source | string | D2 source text. Pass exactly one of source and path. |
warn | array | Enable optional source warnings in addition to the defaults. |
lint_motion Lint D2 motion
Review the animation timeline for motion and readability issues. Returns advisory diagnostics with board paths, source positions, rule codes, and suggestions. Use storyboard to inspect the result after editing.
| Parameter | Type | Description |
|---|---|---|
animate_duration | integer | Transition duration in milliseconds for steps, scenarios, and linked-layer zooms. Omit to use the source setting. Zero disables interpolation. |
animate_interval | integer | Minimum milliseconds per board. Omit to use the source setting. The default is 1000 ms. |
layout | string | Layout engine. Omit to use the diagram's own setting, which defaults to dagre. Use tala for software architecture diagrams with containers. |
path | string | Path to a .d2 file, absolute or relative to the server root. Available only when the server was started with --root. Pass exactly one of source and path. |
sketch | boolean | Hand-drawn look. |
source | string | D2 source text. Pass exactly one of source and path. |
theme | integer | Theme ID. Omit to use the diagram's own setting. Call guide with topic reference for the list. |
render Render D2 diagram
Compile D2 source and return the rendered diagram. By default returns a PNG image you can look at. If the source has errors, returns them with line and column so you can fix the source and call render again. Always look at the result before telling the user the diagram is done: check that nothing overlaps, that text is readable, and that the flow reads in the direction you intended.
| Parameter | Type | Description |
|---|---|---|
format | string | png (default) returns an image you can look at. txt returns a text drawing, the cheapest way to check structure. svg returns the full SVG source, which is large: ask for it only to save a file. |
layout | string | Layout engine. Omit to use the diagram's own setting, which defaults to dagre. Use tala for software architecture diagrams with containers. |
max_dimension | integer | png only. Longest side of the image in pixels, from 256 to 4096. Default 1568. |
path | string | Path to a .d2 file, absolute or relative to the server root. Available only when the server was started with --root. Pass exactly one of source and path. |
sketch | boolean | Hand-drawn look. |
source | string | D2 source text. Pass exactly one of source and path. |
target | string | Board to render, for example layers.api or scenarios.failover. Omit for the root board. |
theme | integer | Theme ID. Omit to use the diagram's own setting. Call guide with topic reference for the list. |
storyboard Review a D2 animation
Return one PNG contact sheet sampled from the animation timeline. Inspect the labeled frames in playback order. Frame metadata gives the board path and timestamp in milliseconds for each panel.
| Parameter | Type | Description |
|---|---|---|
animate_duration | integer | Transition duration in milliseconds for steps, scenarios, and linked-layer zooms. Omit to use the source setting. Zero disables interpolation. |
animate_interval | integer | Minimum milliseconds per board. Omit to use the source setting. The default is 1000 ms. |
layout | string | Layout engine. Omit to use the diagram's own setting, which defaults to dagre. Use tala for software architecture diagrams with containers. |
path | string | Path to a .d2 file, absolute or relative to the server root. Available only when the server was started with --root. Pass exactly one of source and path. |
sketch | boolean | Hand-drawn look. |
source | string | D2 source text. Pass exactly one of source and path. |
theme | integer | Theme ID. Omit to use the diagram's own setting. Call guide with topic reference for the list. |