Plantuml metrics - #2935
Closed
pavlo-alkhimov wants to merge 5 commits into
Closed
Plantuml metrics#2935pavlo-alkhimov wants to merge 5 commits into
pavlo-alkhimov wants to merge 5 commits into
Conversation
Upstream sizes a shape as text + 45px per axis with a 1.5 markdown line height; PlantUML uses text + 20px and ~1.36. The result is that most of a D2 box is padding, which reads as a small font in a large rectangle. Three constants close the gap, leaving diagram sources untouched: lib/shape/shape.go defaultPadding 40. -> 15. lib/textmeasure/markdown.go MarkdownLineHeight 1.5 -> 1.36 d2renderers/d2fonts/... FONT_SIZE_M 16 -> 14 Every shape derives its padding from defaultPadding as a multiple or a fraction, so one constant rescales them all consistently. Box heights now land within 1px of PlantUML at one, two and three lines. Line height drives both measurement and rendering, so baselines and boxes stay in agreement. Version is set to v0.9.0-plantuml-metrics.1 so it cannot be mistaken for an upstream release. Adds a workflow that cross-compiles Windows, Linux and macOS binaries and re-asserts the three constants after every build, and PLANTUML-METRICS.md documenting the rationale and how to rebase. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Tag pattern becomes v*-plantuml-metrics* so a tagged build reports the same string the source defaults to, instead of a bare "v1". Adds a four-line banner at the top of README pointing at PLANTUML-METRICS.md, and documents releases plus the upstream remote needed before a rebase. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…rror
Compiling this panics with an invalid memory address:
**.shape: rectangle
b
LINK -> b
Field.LastPrimaryKey() returns a nil *d2ast.Key for a field that was created
by an edge or a glob rather than written as `KEY: value`. compileReserved
passes that result straight to errorf, and d2parser.Errorf calls GetRange()
on the nil pointer, so the crash happens inside the code that was trying to
report an ordinary compile error. Around sixty call sites in d2compiler pass
LastPrimaryKey() the same way, so the crash is reachable by other routes.
errorf now substitutes a zero-range node when handed a nil one, which covers
every call site. It still delegates to d2parser.Errorf rather than
formatting the message itself, so go vet does not begin treating errorf as a
printf wrapper and flagging pre-existing non-constant format strings in this
file. The site in the traceback additionally falls back to LastRef().AST(),
keeping an accurate source position like the sibling error just below it.
The panic becomes:
reserved field LINK does not accept composite
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
d2compiler: fix nil-pointer panic when reporting a reserved-keyword e…
This fork deliberately changes the geometry of every rendered diagram, so upstream's end-to-end tests cannot pass: verified, they fail on exactly the coordinates the metrics change moves. Keeping those workflows means a permanently red master and a thirty-minute job on every push to prove something already known. Removes ci.yml, release-archives.yml, weekly-race.yml, tala-fuzz.yml, the docker and npm staging jobs, and windows-msi.yml, leaving only plantuml-metrics-build.yml. Dropping release-archives.yml also stops a second, differently named set of binaries being built for every v* tag, which was a source of confusion about which download to install. The build workflow now triggers on master rather than the patch branch, since the work is being consolidated there. Docs updated accordingly: the rebase recipe no longer assumes a pristine mirror branch, and the compiler crash fix is documented again after the branch split dropped that section. What still guards correctness: the build asserts the three metric constants on every run, and go test ./d2compiler/ covers the panic fix. Co-Authored-By: Claude Opus 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.
No description provided.