#320
gdtest_d2_diagrams
OK
CONFIG
Build-time D2 diagrams with separate light/dark SVGs
User-guide pages with `{d2}` (and plain ```d2) diagram blocks, pre-rendered at build time by the `d2` CLI. Each diagram should become a `.d2-diagram` container holding two `<img>` elements — a light-theme and a dark-theme SVG swapped via `.light-mode-only` / `.dark-mode-only` — with the generated `d2-<hash>-{light,dark}.svg` files copied into the site.
Build Mode
● Has great-docs.yml
This package ships a pre-supplied config.
The great-docs init step is skipped and
great-docs build uses the spec-defined configuration directly.
Tests specific config options and their rendered output.
Dimensions
A1 B1 C1 D1 E6 F1 G1 H7
A1Flat layoutlayout
B1Explicit __all__exports
C1Functions onlyobjects
D1NumPydocstrings
E6No directivesdirectives
F1Auto-discoveruser_guide
G1README.mdlanding
H7No extrasextras
Source Files
gdtest_d2_diagrams/
__init__.py
"""D2 diagrams demo package."""
__version__ = "1.0.0"
__all__ = ["greet"]
def greet(name: str) -> str:
"""Return a friendly greeting.
Parameters
----------
name
Who to greet.
Returns
-------
str
The greeting.
"""
return f"Hello, {name}!"user_guide/
01-basic.qmd
---
title: Basic Diagram
---
# Basic D2 Flowchart
A simple decision flow, pre-rendered to light and dark SVGs at build time.
```{d2}
Start -> Decision
Decision -> Action: Yes
Decision -> End: No
```02-options.qmd
---
title: Diagram Options
---
# D2 Options
A hand-drawn (sketch) diagram using the ELK layout engine, configured with
`#|` option lines that are stripped before rendering.
```{d2}
#| sketch: true
#| layout: elk
#| pad: 40
Idea -> Draft -> Review -> Publish
```03-sequence.qmd
---
title: Sequence Diagram
---
# D2 Sequence Diagram
Sequence diagrams use the same syntax with `shape: sequence_diagram`.
```{d2}
shape: sequence_diagram
User -> CLI: great-docs build
CLI -> Core: build()
Core -> User: site ready
```
The plain ```` ```d2 ```` fence (no braces) is also recognized:
```d2
x -> y -> z
```great-docs.yml
dark_mode: true