Repository navigation
Add newer D2 features, validate and fmt - #13
Merged
Merged
Conversation
…ables and render options Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Matches the d2 fmt command and stops shadowing the format builtin, which removes two lint suppressions. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds the D2 features released since py-d2 stopped (v0.6.7 to v0.9.0), plus older ones the library never had. Existing names, parameters and test expectations don't change. Every new parameter is keyword-only.
New functions
d2.validate(diagram_or_source)runsd2 validateand raisesD2Errorwith d2's message. It helps code or an LLM that writes D2 check it.d2.fmt(diagram_or_source)returns the source formatted byd2 fmt.Render options
gifandpptx.dark_theme,sketch,pad,scale,center,omit_version,no_xml_tag,salt,animate_interval,ascii_modeandtimeout.Object model
Text.label_nearandicon_nearplace them, andLabelPositionis a typed set of positions.topandleftpositions, which need TALA.vertical_gapandhorizontal_gap.icon,linkandclasses.ShapeType.c4_person.d2.Legend, with a title and a typednearposition.Diagram(variables=...), which you use with${name}substitution.Layer(label=...)titles scenarios and steps.Not modeled yet:
&connected,level)suspendandunsuspend(a -> b)[0]theme-overridestala-seedsPlain globs already work through
Shape(name="*").There are six new examples, 20 in total, and new tests for each feature.
Checked locally: all 133 tests pass, ruff, ty and
uv lock --checkare clean, and all 20 examples run. That includes the GIF, PPTX and TALA outputs.🤖 Generated with Claude Code