From 11b0ec79a33a67a16375550d64b3cb86f11cdc72 Mon Sep 17 00:00:00 2001 From: ppenguin Date: Wed, 2 Apr 2025 21:02:20 +0200 Subject: [PATCH 1/3] rebase on master --- Makefile | 4 +++ testdata/examples/Makefile | 14 +++++++++++ testdata/examples/themex.d2 | 50 +++++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 testdata/examples/Makefile create mode 100644 testdata/examples/themex.d2 diff --git a/Makefile b/Makefile index 346e9649a..d70ed76e2 100644 --- a/Makefile +++ b/Makefile @@ -24,3 +24,7 @@ race: fmt .PHONY: js js: gen cd d2js/js && NPM_VERSION="${NPM_VERSION}" prefix "$@" ./make.sh all + +.PHONY: themesdemo +themesdemo: + $(MAKE) -C ./testdata/examples/ diff --git a/testdata/examples/Makefile b/testdata/examples/Makefile new file mode 100644 index 000000000..8cbc835b1 --- /dev/null +++ b/testdata/examples/Makefile @@ -0,0 +1,14 @@ +D2 := ../../d2 + +SVGS = $(shell $(D2) themes | gawk -F':' '/^-/{ printf "out/themex-%03d.svg ",$$2 }' || :) + +.PHONY: +all: $(D2) $(SVGS) + +$(D2): + cd $(dir $@) && go build + $(MAKE) $(SVGS) +# D2 as dependency to expire results if recompiled +out/themex-%.svg: themex.d2 $(D2) + $(info Building $@ from $< ...) + $(D2) -t $$(( 10#$* )) $< $@ diff --git a/testdata/examples/themex.d2 b/testdata/examples/themex.d2 new file mode 100644 index 000000000..4dba20d83 --- /dev/null +++ b/testdata/examples/themex.d2 @@ -0,0 +1,50 @@ + +vars: { + d2-config: { + layout-engine: elk + } +} +network: { + cell tower: { + satellites: { + shape: stored_data + style.multiple: true + } + + transmitter + + satellites -> transmitter: send + satellites -> transmitter: send + satellites -> transmitter: send + } + + online portal: { + ui: {shape: hexagon} + } + + data processor: { + storage: { + shape: cylinder + style.multiple: true + } + } + + cell tower.transmitter -> data processor.storage: phone logs +} + +user: { + shape: person + width: 130 +} + +user -> network.cell tower: make call +user -> network.online portal.ui: access { + style.stroke-dash: 3 +} + +api server -> network.online portal.ui: display +api server -> logs: persist +logs: {shape: page; style.multiple: true} + +network.data processor -> api server + From b338ea5da07d65c80959795e94782c99e0c32adc Mon Sep 17 00:00:00 2001 From: ppenguin Date: Wed, 2 Apr 2025 20:47:16 +0200 Subject: [PATCH 2/3] add demothemes generator to Makefile minor improvements --- .gitignore | 13 ++++++++++++- Makefile | 16 ++++++++++++++-- testdata/examples/Makefile | 14 -------------- 3 files changed, 26 insertions(+), 17 deletions(-) delete mode 100644 testdata/examples/Makefile diff --git a/.gitignore b/.gitignore index a24ac39c1..0e864ec32 100644 --- a/.gitignore +++ b/.gitignore @@ -6,6 +6,17 @@ e2e_report.html bin out d2 +# generated svg examples (from make themesdemo) +testdata/examples/svg/ # https://github.com/golang/go/blob/8b67cf0bc6ad657fddcbaaa10729d0086f08f9a9/src/cmd/go/internal/test/test.go#L415-L416 -e2etests.test \ No newline at end of file +e2etests.test + +# nix/devenv related +# .envrc +devenv.* +!devenv.nix +.devenv* +.direnv +.pre-commit-config.yaml + diff --git a/Makefile b/Makefile index d70ed76e2..8e2bdda2d 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,18 @@ race: fmt js: gen cd d2js/js && NPM_VERSION="${NPM_VERSION}" prefix "$@" ./make.sh all +SVGDIR := testdata/examples/svg +SVGS = $(shell ./d2 themes | gawk -F':' '/^-/{ printf "$(SVGDIR)/themex-%03d.svg ",$$2 }' || :) + +.PHONY: clean +clean: + rm -f $(SVGS) d2 + .PHONY: themesdemo -themesdemo: - $(MAKE) -C ./testdata/examples/ +themesdemo: $(SVGS) d2 + +$(SVGDIR)/themex-%.svg: testdata/examples/themex.d2 + $(info Building $@ from $< ...) + ./d2 -t $$(( 10#$* )) $< $@ + +# d2: build diff --git a/testdata/examples/Makefile b/testdata/examples/Makefile deleted file mode 100644 index 8cbc835b1..000000000 --- a/testdata/examples/Makefile +++ /dev/null @@ -1,14 +0,0 @@ -D2 := ../../d2 - -SVGS = $(shell $(D2) themes | gawk -F':' '/^-/{ printf "out/themex-%03d.svg ",$$2 }' || :) - -.PHONY: -all: $(D2) $(SVGS) - -$(D2): - cd $(dir $@) && go build - $(MAKE) $(SVGS) -# D2 as dependency to expire results if recompiled -out/themex-%.svg: themex.d2 $(D2) - $(info Building $@ from $< ...) - $(D2) -t $$(( 10#$* )) $< $@ From 755da3d1310cd65ccd2abd4b9367406f1c51018a Mon Sep 17 00:00:00 2001 From: ppenguin Date: Wed, 2 Apr 2025 21:07:29 +0200 Subject: [PATCH 3/3] simplify/improve demo themes builder --- Makefile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 8e2bdda2d..94e0dfe50 100644 --- a/Makefile +++ b/Makefile @@ -31,6 +31,7 @@ SVGS = $(shell ./d2 themes | gawk -F':' '/^-/{ printf "$(SVGDIR)/themex-%03d.svg .PHONY: clean clean: rm -f $(SVGS) d2 + rmdir $(SVGDIR) .PHONY: themesdemo themesdemo: $(SVGS) d2 @@ -39,4 +40,4 @@ $(SVGDIR)/themex-%.svg: testdata/examples/themex.d2 $(info Building $@ from $< ...) ./d2 -t $$(( 10#$* )) $< $@ -# d2: build +d2: build