Skip to content

Latest commit

 

History

History
31 lines (28 loc) · 2.13 KB

README.md

File metadata and controls

31 lines (28 loc) · 2.13 KB

Examples

Each script builds one diagram and writes it next to where you run it. Install the d2 binary with the bin extra, then run any example:

uv sync --extra bin
uv run python examples/shapes.py
Example What it shows
basic.py Shapes, labels and a connection
shapes.py Shape types such as cylinder, queue and person, and icons
containers.py Shapes inside shapes, and connections to nested shapes with dotted paths
styles.py Fill, stroke, font, bold, opacity, 3d, shadow and border radius
connections.py Labels, directions, styles and arrowheads, including crow's foot
tooltips_and_links.py Tooltips on shapes and connections, and shape links
text_blocks.py Markdown and code text inside a shape
grids.py Grid layout with columns and gap
classes.py Reusable style classes
sql_tables.py SQL tables with constraints and a foreign key
uml_classes.py UML class shapes with fields, methods and inheritance
boards.py Layers, scenarios and steps, rendering the root board and one layer
config.py Layout engine, theme, direction and sketch mode through vars
ascii.py ASCII output printed with d2.render(diagram, "txt")
validation.py d2.validate, d2.fmt and a glob shape that styles every shape
labels_and_positions.py Markdown labels on shapes and connections, label_near, icon_near, connection icons and links
fixed_positions.py top and left positions (tala) and grid vertical_gap and horizontal_gap
c4_and_sequence.py The c4-person shape and a sequence diagram
variables_and_legend.py variables with ${name} substitution, gradients, a legend and a board label
render_options.py Sketch, dark theme, pad, scale, salt, gif and pptx output, ASCII mode