From 89e0e0cf6a35065ab85520c5015786d0f5d1fa39 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 17:15:51 -0800 Subject: [PATCH 001/257] install.sh: Run brew update before install Ensure formulas are up to date. --- ci/release/_install.sh | 6 +----- install.sh | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/ci/release/_install.sh b/ci/release/_install.sh index 6428f432b..fc3d716f6 100755 --- a/ci/release/_install.sh +++ b/ci/release/_install.sh @@ -348,6 +348,7 @@ install_d2_standalone() { install_d2_brew() { header "installing d2 with homebrew" sh_c brew tap terrastruct/d2 + sh_c brew update sh_c brew install d2 } @@ -502,11 +503,6 @@ fetch_gh() { sh_c mv "$file.inprogress" "$file" } -brew() { - # Makes brew sane. - HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 command brew "$@" -} - # The main function does more than provide organization. It provides robustness in that if # the install script was to only partial download into sh, sh will not execute it because # main is not invoked until the very last byte. diff --git a/install.sh b/install.sh index 07425ca70..103ae05cd 100755 --- a/install.sh +++ b/install.sh @@ -931,6 +931,7 @@ install_d2_standalone() { install_d2_brew() { header "installing d2 with homebrew" sh_c brew tap terrastruct/d2 + sh_c brew update sh_c brew install d2 } @@ -1085,11 +1086,6 @@ fetch_gh() { sh_c mv "$file.inprogress" "$file" } -brew() { - # Makes brew sane. - HOMEBREW_NO_INSTALL_CLEANUP=1 HOMEBREW_NO_AUTO_UPDATE=1 command brew "$@" -} - # The main function does more than provide organization. It provides robustness in that if # the install script was to only partial download into sh, sh will not execute it because # main is not invoked until the very last byte. From 17f45d15922cee03e67b3bb3a73d602208f6699e Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 17:35:10 -0800 Subject: [PATCH 002/257] install.sh: Update for tap rename --- ci/release/_install.sh | 5 ++--- docs/INSTALL.md | 1 - install.sh | 5 ++--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/ci/release/_install.sh b/ci/release/_install.sh index fc3d716f6..f0c653312 100755 --- a/ci/release/_install.sh +++ b/ci/release/_install.sh @@ -347,7 +347,6 @@ install_d2_standalone() { install_d2_brew() { header "installing d2 with homebrew" - sh_c brew tap terrastruct/d2 sh_c brew update sh_c brew install d2 } @@ -391,8 +390,8 @@ install_tala_standalone() { install_tala_brew() { header "installing tala with homebrew" - sh_c brew tap terrastruct/d2 - sh_c brew install tala + sh_c brew update + sh_c brew install terrastruct/tap/tala } uninstall() { diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 7d29525d2..f5ee0cd86 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -71,7 +71,6 @@ but that is coming soon. [#315](https://github.com/terrastruct/d2/issues/315) If you're on macOS, you can install with `brew`. ```sh -brew tap terrastruct/d2 brew install d2 ``` diff --git a/install.sh b/install.sh index 103ae05cd..37f4fbcbb 100755 --- a/install.sh +++ b/install.sh @@ -930,7 +930,6 @@ install_d2_standalone() { install_d2_brew() { header "installing d2 with homebrew" - sh_c brew tap terrastruct/d2 sh_c brew update sh_c brew install d2 } @@ -974,8 +973,8 @@ install_tala_standalone() { install_tala_brew() { header "installing tala with homebrew" - sh_c brew tap terrastruct/d2 - sh_c brew install tala + sh_c brew update + sh_c brew install terrastruct/tap/tala } uninstall() { From d028915b7f88db8a587efb7b00f326258b75d704 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 18:59:23 -0800 Subject: [PATCH 003/257] ci: Update --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index 79b9dadce..f668611e9 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 79b9dadce090a95b5a50d32f9ea3927845e5cce1 +Subproject commit f668611e9b1cfc335230ab6f8161cf87f74f174d From ce0e2b332638a1cc1a1e7789a68d78be4efb9c02 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:14:05 -0800 Subject: [PATCH 004/257] release: On windows use .exe and alter README Closes #388 --- ci/release/_build.sh | 16 ++++++++++------ ci/release/template/README.md.sh | 27 +++++++++++++++++++++++++++ 2 files changed, 37 insertions(+), 6 deletions(-) diff --git a/ci/release/_build.sh b/ci/release/_build.sh index 3f8b1663d..02c58f9db 100755 --- a/ci/release/_build.sh +++ b/ci/release/_build.sh @@ -4,19 +4,23 @@ cd -- "$(dirname "$0")/../.." . ./ci/sub/lib.sh sh_c mkdir -p "$HW_BUILD_DIR" -sh_c rsync --recursive --perms --delete \ - --human-readable --copy-links ./ci/release/template/ "$HW_BUILD_DIR/" -VERSION=$VERSION sh_c eval "'$HW_BUILD_DIR/README.md.sh'" \> "'$HW_BUILD_DIR/README.md'" -sh_c rm -f "$HW_BUILD_DIR/README.md.sh" -sh_c find "$HW_BUILD_DIR" -exec touch {} \\\; +sh_c cp ./ci/release/template/LICENSE.txt "$HW_BUILD_DIR" +sh_c cp ./ci/release/template/Makefile "$HW_BUILD_DIR" +sh_c cp -R ./ci/release/template/man "$HW_BUILD_DIR" +sh_c cp -Rf ./ci/release/template/scripts "$HW_BUILD_DIR" +sh_c VERSION="$VERSION" ./ci/release/template/README.md.sh \> "'$HW_BUILD_DIR/README.md'" ensure_goos ensure_goarch sh_c mkdir -p "$HW_BUILD_DIR/bin" -sh_c CGO_ENABLED=0 go build -trimpath \ +sh_c GOOS="$GOOS" GOARCH="$GOARCH" CGO_ENABLED=0 go build -trimpath \ -ldflags "'-X oss.terrastruct.com/d2/lib/version.Version=$VERSION'" \ -o "$HW_BUILD_DIR/bin/d2" . +if [ "$GOOS" = windows ]; then + sh_c mv "$HW_BUILD_DIR/bin/d2" "$HW_BUILD_DIR/bin/d2.exe" +fi + ARCHIVE=$PWD/$ARCHIVE cd "$(dirname "$HW_BUILD_DIR")" sh_c tar -czf "$ARCHIVE" "$(basename "$HW_BUILD_DIR")" diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 2c0cdfb35..99411d923 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -1,5 +1,7 @@ #!/bin/sh set -eu +cd -- "$(dirname "$0")/../../.." +. ./ci/sub/lib.sh cat < Date: Wed, 7 Dec 2022 19:21:56 -0800 Subject: [PATCH 005/257] d2dagrelayout: Fix regexp See https://github.com/terrastruct/d2/pull/394#discussion_r1042504655 --- d2layouts/d2dagrelayout/layout.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2layouts/d2dagrelayout/layout.go b/d2layouts/d2dagrelayout/layout.go index e1d29175e..ec72a91c6 100644 --- a/d2layouts/d2dagrelayout/layout.go +++ b/d2layouts/d2dagrelayout/layout.go @@ -261,7 +261,7 @@ func escapeID(id string) string { // fixes \\ id = strings.ReplaceAll(id, "\\", `\\`) // replaces \n with \\n whenever \n is not preceded by \ (does not replace \\n) - re := regexp.MustCompile(`[^\\](\n)`) + re := regexp.MustCompile(`[^\\]\n`) id = re.ReplaceAllString(id, `\\n`) // avoid an unescaped \r becoming a \n in the layout result id = strings.ReplaceAll(id, "\r", `\r`) From 1fde26789a2c47b8700d53e9a50cffd119a3d8e9 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:27:06 -0800 Subject: [PATCH 006/257] release/next.md: Update --- ci/release/changelogs/next.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 84d6618aa..3fadfa006 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -2,6 +2,8 @@ #### Improvements 🧹 +- The Windows release binary is now suffixed correctly with `.exe` [#388](https://github.com/terrastruct/d2/issues/388) + #### Bugfixes ⛑️ -- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397) \ No newline at end of file +- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397) From c2bcb3a93e1c2472b008bf7f4fb94e49c20d97e3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:30:04 -0800 Subject: [PATCH 007/257] release/template/README.md: Document easiest way to use windows --- ci/release/template/README.md.sh | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 99411d923..115bba209 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -19,14 +19,18 @@ ensure_os if [ "$OS" = windows ]; then cat < + +You can install on Windows with [MSYS2](https://www.msys2.org/) which emulates a Linux +shell for Windows. It also enables d2 to show colors in its output. But if you must install on Windows without MSYS2, for now you'll have to add the d2 binary -in \`./bin/d2.exe\` to your \`\$PATH\` manually. You can also add the \`./bin\` directory -to your \`\$PATH\`. +in \`./bin/d2.exe\` to your \`\$PATH\` manually. Or you can add the \`./bin\` directory to +your \`\$PATH\`. See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows From 31346482731fb6ad4cb605e558a5f3a99cc2f4ae Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:32:26 -0800 Subject: [PATCH 008/257] install.md: Document easiest way to use windows --- ci/release/template/README.md.sh | 5 ++++- docs/INSTALL.md | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 115bba209..6bfcfdb50 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -23,7 +23,7 @@ We currently do not have a .msi for automatic installation on Windows so this re structured the same as our Unix releases. Easiest way to use d2 on Windows is to just cd into the bin directory of this release -and invoke d2 like ./d2.exe +and invoke d2 like \`./d2.exe \` You can install on Windows with [MSYS2](https://www.msys2.org/) which emulates a Linux shell for Windows. It also enables d2 to show colors in its output. @@ -32,6 +32,9 @@ But if you must install on Windows without MSYS2, for now you'll have to add the in \`./bin/d2.exe\` to your \`\$PATH\` manually. Or you can add the \`./bin\` directory to your \`\$PATH\`. +We intend to have a \`.msi\` release installer sometime soon that handles putting \`d2\` into +your \`\$PATH\` for you. + See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows EOF diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 7d29525d2..c4c0b7cd4 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -158,8 +158,13 @@ the `d2` binary. d2 builds and runs on Windows: We have prebuilt standalone releases for Windows though they're structured in the same way -as our Unix releases. So after extracting a release, you'll have to manually put the d2 -binary into your `$PATH` or add the `bin` directory of the release into your `$PATH`. +as our Unix releases. + +Easiest way to use d2 on Windows is to just cd into the bin directory of the release after +extracting it and invoking d2 like `./d2.exe ` + +For installation, you'll have to manually put the d2 binary into your `$PATH` or add the +`bin` directory of the release into your `$PATH`. See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows From 44c11a13ce173292b488a5ab451dd7800eef23f3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 19:42:58 -0800 Subject: [PATCH 009/257] Update windows install docs --- ci/release/template/README.md.sh | 24 ++++++++++++++---------- docs/INSTALL.md | 16 ++++++++-------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 6bfcfdb50..d52d96716 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -19,23 +19,27 @@ ensure_os if [ "$OS" = windows ]; then cat <\` +Easiest way to use d2 on Windows is to just \`chdir\` into the bin directory of this release +and invoke d2 like \`./d2 \` -You can install on Windows with [MSYS2](https://www.msys2.org/) which emulates a Linux -shell for Windows. It also enables d2 to show colors in its output. +For installation you'll have to add the \`./bin/d2.exe\` binary to your \`\$PATH\`. Or add +the \`./bin\` directory of this release to your \`\$PATH\`. -But if you must install on Windows without MSYS2, for now you'll have to add the d2 binary -in \`./bin/d2.exe\` to your \`\$PATH\` manually. Or you can add the \`./bin\` directory to -your \`\$PATH\`. +See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows + +Then you'll be able to call \`d2\` from the commandline in \`cmd.exe\` or \`pwsh.exe\`. We intend to have a \`.msi\` release installer sometime soon that handles putting \`d2\` into your \`\$PATH\` for you. -See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows +You can also use \`make install\` to install on Windows after first installing +[MSYS2](https://www.msys2.org/) which emulates a Linux shell for Windows. Its terminal +also enables d2 to show colors in its output. The manpage will also become accessible +with \`man d2\`. + See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows EOF fi diff --git a/docs/INSTALL.md b/docs/INSTALL.md index c4c0b7cd4..afca4df39 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -140,7 +140,7 @@ go install oss.terrastruct.com/d2@latest ### Source Release -To install a proper release from source clone the repository and then: +To install a release from source clone the repository and then: ```sh ./ci/release/build.sh --install @@ -149,9 +149,9 @@ To install a proper release from source clone the repository and then: ``` Installing a real release will also install manpages and in the future other assets like -fonts and icons. Furthermore, when installing a non versioned commit, installing a proper -release will ensure that `d2 --version` works correctly by embedding the commit hash into -the `d2` binary. +fonts and icons. Furthermore, when installing a non versioned commit, installing a release +will ensure that `d2 --version` works correctly by embedding the commit hash into the `d2` +binary. ## Windows @@ -160,10 +160,10 @@ d2 builds and runs on Windows: We have prebuilt standalone releases for Windows though they're structured in the same way as our Unix releases. -Easiest way to use d2 on Windows is to just cd into the bin directory of the release after -extracting it and invoking d2 like `./d2.exe ` +Easiest way to use d2 on Windows is to just `chdir` into the bin directory of the release +and invoke d2 like `./d2 ` -For installation, you'll have to manually put the d2 binary into your `$PATH` or add the +For installation, you'll have to put the `bin/d2.exe` binary into your `$PATH` or add the `bin` directory of the release into your `$PATH`. See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows @@ -182,7 +182,7 @@ Bash](https://gitforwindows.org/#bash) (Git Bash is based on MSYS2) for an impro terminal experience. MSYS2 provides a unix style shell environment that is native to Windows (unlike -[Cygwin](https://www.cygwin.com/)). MSYS2 allows `install.sh` to work, enables proper +[Cygwin](https://www.cygwin.com/)). MSYS2 allows `install.sh` to work, enables automatic installation of our standalone releases via `make install` and makes the manpage accessible via `man d2`. From 472c101e502af9a90c808157382a3823cf9a4e1f Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 20:59:24 -0800 Subject: [PATCH 010/257] ci: Update --- ci/fmt.sh | 8 +------- ci/sub | 2 +- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/ci/fmt.sh b/ci/fmt.sh index 4fb39da34..90b405eab 100755 --- a/ci/fmt.sh +++ b/ci/fmt.sh @@ -3,10 +3,4 @@ set -eu . "$(dirname "$0")/sub/lib.sh" cd -- "$(dirname "$0")/.." -if is_changed README.md; then - sh_c tocsubst --skip 1 README.md -fi -if is_changed docs/INSTALL.md; then - sh_c tocsubst --skip 1 docs/INSTALL.md -fi -./ci/sub/fmt/make.sh +./ci/sub/bin/fmt.sh diff --git a/ci/sub b/ci/sub index f668611e9..8892ef430 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit f668611e9b1cfc335230ab6f8161cf87f74f174d +Subproject commit 8892ef43000921a29a1f1118c84d7eabbb9ef0c5 From eafd62555cbe17e715da19825bb1dbdc6c54d0d3 Mon Sep 17 00:00:00 2001 From: Toyam Cox Date: Tue, 6 Dec 2022 14:03:40 -0500 Subject: [PATCH 011/257] install.md: we've been packaged --- docs/INSTALL.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 7d29525d2..3bc14d9b8 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -6,6 +6,8 @@ You may install `d2` through any of the following methods. - install.sh - Security - macOS (Homebrew) +- Linux + - Void Linux - Standalone - Manual - PREFIX @@ -78,6 +80,18 @@ brew install d2 > The install script above does this automatically if you have `brew` installed and > are running it on macOS. +## Linux + +The following distributions have packages for d2: + +### Void Linux + +All supported platforms: + +```sh +xbps-install d2 +``` + ## Standalone We publish standalone release archives for every release on Github. From 8f0c3fa50262dbde1c3aa0738e268c19398da40b Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 22:49:46 -0800 Subject: [PATCH 012/257] ci: Update [ci-force] --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index 8892ef430..d66db4fa7 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 8892ef43000921a29a1f1118c84d7eabbb9ef0c5 +Subproject commit d66db4fa78a6bbd13265b6e6b76fc35e86d23620 From f76e151991b49330fb171fdf23e746e51fb918c9 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:04:20 -0800 Subject: [PATCH 013/257] ci: Update [ci-force] --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index d66db4fa7..a49f76ce4 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit d66db4fa78a6bbd13265b6e6b76fc35e86d23620 +Subproject commit a49f76ce44949ebb17506c6d2bb2c3785bf73c8d From a86e409b49e1927f4a85852bdecbd76db7758fe9 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:13:12 -0800 Subject: [PATCH 014/257] ci: Update [ci-force] --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index a49f76ce4..aac1d2b9c 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit a49f76ce44949ebb17506c6d2bb2c3785bf73c8d +Subproject commit aac1d2b9c887bc48a05337dd76a44262fc936013 From b72959a91fddd85a8f2205362add94152d7437c0 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:22:20 -0800 Subject: [PATCH 015/257] fmt --- .prettierignore | 6 ++++++ Makefile | 2 +- ci/fmt.sh | 6 ------ d2compiler/compile_test.go | 2 +- d2layouts/d2elklayout/layout.go | 1 + d2layouts/d2sequence/layout.go | 1 - d2plugin/serve.go | 2 +- d2renderers/d2latex/latex.go | 1 + lib/imgbundler/imgbundler.go | 2 +- 9 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 .prettierignore delete mode 100755 ci/fmt.sh diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..d7226ae8f --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +d2layouts/d2dagrelayout/dagre.js +d2layouts/d2elklayout/setup.js +d2renderers/d2latex/mathjax.js +d2renderers/d2latex/polyfills.js +d2renderers/d2latex/setup.js +lib/png/generate_png.js diff --git a/Makefile b/Makefile index fdc039a33..13a440c2c 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: fmt gen lint build test .PHONY: fmt fmt: - prefix "$@" ./ci/fmt.sh + prefix "$@" GOIMPORTS_LOCAL=oss.terrastruct.com, ./ci/sub/bin/fmt.sh .PHONY: gen gen: prefix "$@" ./ci/gen.sh diff --git a/ci/fmt.sh b/ci/fmt.sh deleted file mode 100755 index 90b405eab..000000000 --- a/ci/fmt.sh +++ /dev/null @@ -1,6 +0,0 @@ -#!/bin/sh -set -eu -. "$(dirname "$0")/sub/lib.sh" -cd -- "$(dirname "$0")/.." - -./ci/sub/bin/fmt.sh diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 593c139d9..b68e28644 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -7,9 +7,9 @@ import ( "testing" tassert "github.com/stretchr/testify/assert" + "oss.terrastruct.com/util-go/assert" "oss.terrastruct.com/util-go/diff" - "oss.terrastruct.com/d2/d2compiler" "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2graph" diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index 2449a9751..63b26c95f 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -12,6 +12,7 @@ import ( "math" "github.com/dop251/goja" + "oss.terrastruct.com/util-go/xdefer" "oss.terrastruct.com/util-go/go2" diff --git a/d2layouts/d2sequence/layout.go b/d2layouts/d2sequence/layout.go index 7940e13b1..c6934c051 100644 --- a/d2layouts/d2sequence/layout.go +++ b/d2layouts/d2sequence/layout.go @@ -6,7 +6,6 @@ import ( "strings" "oss.terrastruct.com/util-go/go2" - "oss.terrastruct.com/d2/d2graph" "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/lib/geo" diff --git a/d2plugin/serve.go b/d2plugin/serve.go index 4f83aa8a8..b99768e3a 100644 --- a/d2plugin/serve.go +++ b/d2plugin/serve.go @@ -8,8 +8,8 @@ import ( "io" "github.com/spf13/pflag" - "oss.terrastruct.com/util-go/xmain" + "oss.terrastruct.com/util-go/xmain" "oss.terrastruct.com/d2/d2graph" ) diff --git a/d2renderers/d2latex/latex.go b/d2renderers/d2latex/latex.go index 74fdb0759..a822b2c7b 100644 --- a/d2renderers/d2latex/latex.go +++ b/d2renderers/d2latex/latex.go @@ -8,6 +8,7 @@ import ( "strconv" "github.com/dop251/goja" + "oss.terrastruct.com/util-go/xdefer" ) diff --git a/lib/imgbundler/imgbundler.go b/lib/imgbundler/imgbundler.go index 14ff92cd8..e1b719687 100644 --- a/lib/imgbundler/imgbundler.go +++ b/lib/imgbundler/imgbundler.go @@ -17,8 +17,8 @@ import ( "time" "golang.org/x/xerrors" - "oss.terrastruct.com/util-go/xdefer" + "oss.terrastruct.com/util-go/xdefer" "oss.terrastruct.com/util-go/xmain" ) From b704c6684bc289334e472aa95c75e55061c7089d Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:40:13 -0800 Subject: [PATCH 016/257] ci: Update [ci-force] --- Makefile | 2 +- ci/sub | 2 +- d2compiler/compile_test.go | 4 ++-- d2layouts/d2sequence/layout.go | 2 +- d2plugin/serve.go | 2 +- 5 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index 13a440c2c..8fd431900 100644 --- a/Makefile +++ b/Makefile @@ -5,7 +5,7 @@ all: fmt gen lint build test .PHONY: fmt fmt: - prefix "$@" GOIMPORTS_LOCAL=oss.terrastruct.com, ./ci/sub/bin/fmt.sh + prefix "$@" ./ci/sub/bin/fmt.sh .PHONY: gen gen: prefix "$@" ./ci/gen.sh diff --git a/ci/sub b/ci/sub index aac1d2b9c..720467401 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit aac1d2b9c887bc48a05337dd76a44262fc936013 +Subproject commit 72046740162cff9799a94a8e1a8e4f4d7de73407 diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index b68e28644..c6cc1c25c 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -8,12 +8,12 @@ import ( tassert "github.com/stretchr/testify/assert" - "oss.terrastruct.com/util-go/assert" - "oss.terrastruct.com/util-go/diff" "oss.terrastruct.com/d2/d2compiler" "oss.terrastruct.com/d2/d2format" "oss.terrastruct.com/d2/d2graph" "oss.terrastruct.com/d2/d2target" + "oss.terrastruct.com/util-go/assert" + "oss.terrastruct.com/util-go/diff" ) func TestCompile(t *testing.T) { diff --git a/d2layouts/d2sequence/layout.go b/d2layouts/d2sequence/layout.go index c6934c051..42efeb174 100644 --- a/d2layouts/d2sequence/layout.go +++ b/d2layouts/d2sequence/layout.go @@ -5,11 +5,11 @@ import ( "sort" "strings" - "oss.terrastruct.com/util-go/go2" "oss.terrastruct.com/d2/d2graph" "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/label" + "oss.terrastruct.com/util-go/go2" ) // Layout runs the sequence diagram layout engine on objects of shape sequence_diagram diff --git a/d2plugin/serve.go b/d2plugin/serve.go index b99768e3a..b13680746 100644 --- a/d2plugin/serve.go +++ b/d2plugin/serve.go @@ -9,8 +9,8 @@ import ( "github.com/spf13/pflag" - "oss.terrastruct.com/util-go/xmain" "oss.terrastruct.com/d2/d2graph" + "oss.terrastruct.com/util-go/xmain" ) // Serve returns a xmain.RunFunc that will invoke the plugin p as necessary to service the From 5d93a7eff87ebc4044dd3ee98ce8cd628a73604b Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Wed, 7 Dec 2022 23:56:43 -0800 Subject: [PATCH 017/257] README: Add daily badge --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 03bd040c1..31152515b 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ [Language docs](https://d2lang.com) | [Cheat sheet](./docs/assets/cheat_sheet.pdf) | [Comparisons](https://text-to-diagram.com) [![ci](https://github.com/terrastruct/d2/actions/workflows/ci.yml/badge.svg)](https://github.com/terrastruct/d2/actions/workflows/ci.yml) +[![daily](https://github.com/terrastruct/d2/actions/workflows/daily.yml/badge.svg)](https://github.com/terrastruct/d2/actions/workflows/daily.yml) [![release](https://img.shields.io/github/v/release/terrastruct/d2)](https://github.com/terrastruct/d2/releases) [![discord](https://img.shields.io/discord/1039184639652265985?label=discord)](https://discord.gg/NF6X8K4eDq) [![twitter](https://img.shields.io/twitter/follow/terrastruct?style=social)](https://twitter.com/terrastruct) From b8df98be1c3b4ac2e65580e194a0542d2e5cc27f Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 00:03:29 -0800 Subject: [PATCH 018/257] install.md: Demonstrate installation from source with homebrew --- docs/INSTALL.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 108cdc523..aec71267f 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -77,6 +77,12 @@ brew install d2 > The install script above does this automatically if you have `brew` installed and > are running it on macOS. +You can also install from source with: + +```d2 +brew install d2 --HEAD +``` + ## Standalone We publish standalone release archives for every release on Github. From 12242b62d82e7044662e9ef7eef86d8076b16e4d Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 01:51:55 -0800 Subject: [PATCH 019/257] .github: Update --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 384cfa3f3..b9feefc85 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -27,7 +27,7 @@ jobs: steps: - uses: actions/checkout@v3 - run: git submodule update --init - - run: COLOR=1 ./ci/sub/nofixups.sh + - run: COLOR=1 ./ci/sub/bin/nofixups.sh env: GITHUB_TOKEN: ${{ secrets._GITHUB_TOKEN }} DISCORD_WEBHOOK_URL: ${{ secrets.DISCORD_WEBHOOK_URL }} From 031a1a707ef6834cb081aff9dce0dcf0d5933fac Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 02:04:52 -0800 Subject: [PATCH 020/257] deps: update [ci-force] --- ci/sub | 2 +- go.mod | 2 +- go.sum | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/sub b/ci/sub index 720467401..771dee566 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 72046740162cff9799a94a8e1a8e4f4d7de73407 +Subproject commit 771dee566d3eecca02fe937c82efb55d836952c0 diff --git a/go.mod b/go.mod index 5d9b40703..9f56acdd2 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 gonum.org/v1/plot v0.12.0 nhooyr.io/websocket v1.8.7 - oss.terrastruct.com/util-go v0.0.0-20221206181038-1ee338b0f63c + oss.terrastruct.com/util-go v0.0.0-20221208100440-d1700fe6f48c ) require ( diff --git a/go.sum b/go.sum index af8d91eb9..c2621602b 100644 --- a/go.sum +++ b/go.sum @@ -806,8 +806,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -oss.terrastruct.com/util-go v0.0.0-20221206181038-1ee338b0f63c h1:Joyhf6txaxFUFCXJvmhLpWsi/XDsLqaalSRzUEpC4fU= -oss.terrastruct.com/util-go v0.0.0-20221206181038-1ee338b0f63c/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= +oss.terrastruct.com/util-go v0.0.0-20221208100440-d1700fe6f48c h1:j1IK58Dgqi6FZxzSyWpgaFDRXvgxEeqqCEGFB+ULT/Y= +oss.terrastruct.com/util-go v0.0.0-20221208100440-d1700fe6f48c/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= From c45702520e24e39d648754903b494c80a70d85f3 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 02:24:00 -0800 Subject: [PATCH 021/257] ci: Update --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index 771dee566..e625b8d61 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 771dee566d3eecca02fe937c82efb55d836952c0 +Subproject commit e625b8d61864ec262fc9e594c89941d046baa579 From b0993c45b49828a1b556bef18c7f8325e0ee7e11 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 02:25:44 -0800 Subject: [PATCH 022/257] _build.sh: Update --- ci/release/_build.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/ci/release/_build.sh b/ci/release/_build.sh index 02c58f9db..8df5e2bd1 100755 --- a/ci/release/_build.sh +++ b/ci/release/_build.sh @@ -3,11 +3,12 @@ set -eu cd -- "$(dirname "$0")/../.." . ./ci/sub/lib.sh +sh_c rm -Rf "$HW_BUILD_DIR" sh_c mkdir -p "$HW_BUILD_DIR" sh_c cp ./ci/release/template/LICENSE.txt "$HW_BUILD_DIR" sh_c cp ./ci/release/template/Makefile "$HW_BUILD_DIR" sh_c cp -R ./ci/release/template/man "$HW_BUILD_DIR" -sh_c cp -Rf ./ci/release/template/scripts "$HW_BUILD_DIR" +sh_c cp -R ./ci/release/template/scripts "$HW_BUILD_DIR" sh_c VERSION="$VERSION" ./ci/release/template/README.md.sh \> "'$HW_BUILD_DIR/README.md'" ensure_goos From 87f811f5387fb1158a2d677411587fb61780c98c Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 02:32:09 -0800 Subject: [PATCH 023/257] releas/template: Minor fixes --- ci/release/template/README.md.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index d52d96716..7ccea6fb2 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -3,6 +3,8 @@ set -eu cd -- "$(dirname "$0")/../../.." . ./ci/sub/lib.sh +ensure_os +ensure_arch cat <\` +Easiest way to use \`d2\` on Windows is to just \`chdir\` into the bin directory of this release +and invoke \`d2\` like \`./d2 \` For installation you'll have to add the \`./bin/d2.exe\` binary to your \`\$PATH\`. Or add the \`./bin\` directory of this release to your \`\$PATH\`. @@ -32,12 +33,12 @@ See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows Then you'll be able to call \`d2\` from the commandline in \`cmd.exe\` or \`pwsh.exe\`. -We intend to have a \`.msi\` release installer sometime soon that handles putting \`d2\` into +We intend to have a \`.msi\` release installer sometime soon that handles putting \`d2.exe\` into your \`\$PATH\` for you. You can also use \`make install\` to install on Windows after first installing [MSYS2](https://www.msys2.org/) which emulates a Linux shell for Windows. Its terminal -also enables d2 to show colors in its output. The manpage will also become accessible +also enables \`d2\` to show colors in its output. The manpage will also become accessible with \`man d2\`. See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows From 771d1c2efa28065281344ecb77a0724929bc6ed2 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 02:41:04 -0800 Subject: [PATCH 024/257] template/scripts/install.sh: Fix --- ci/release/template/scripts/install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release/template/scripts/install.sh b/ci/release/template/scripts/install.sh index e6fb00720..b77991e77 100755 --- a/ci/release/template/scripts/install.sh +++ b/ci/release/template/scripts/install.sh @@ -9,7 +9,7 @@ main() { ensure_os if [ "$OS" = windows ]; then - "$sh_c" install ./bin/d2 "$PREFIX/bin/d2.exe" + "$sh_c" install ./bin/d2.exe "$PREFIX/bin/d2.exe" else "$sh_c" install ./bin/d2 "$PREFIX/bin/d2" fi From e90a71f16d29805d9e3b56551610226dfb97f3b9 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 02:41:15 -0800 Subject: [PATCH 025/257] ci: Update --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index e625b8d61..b3c841bae 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit e625b8d61864ec262fc9e594c89941d046baa579 +Subproject commit b3c841bae8c044f877b07ff2022052dd3b7e5c82 From 2307e2063a0f8e38e94e81a99277b82c2246a221 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 02:51:52 -0800 Subject: [PATCH 026/257] ci: Update --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index b3c841bae..dab464462 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit b3c841bae8c044f877b07ff2022052dd3b7e5c82 +Subproject commit dab464462bfb3818fc7d7b73d1c9b64b46894d28 From 67466f61542ae3e0b42d3cb889ead460bf96c7ab Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 02:55:36 -0800 Subject: [PATCH 027/257] deps: update [ci-force] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 9f56acdd2..f3992fe8d 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 gonum.org/v1/plot v0.12.0 nhooyr.io/websocket v1.8.7 - oss.terrastruct.com/util-go v0.0.0-20221208100440-d1700fe6f48c + oss.terrastruct.com/util-go v0.0.0-20221208105526-b395c3a8b8fa ) require ( diff --git a/go.sum b/go.sum index c2621602b..ec7d7f7ed 100644 --- a/go.sum +++ b/go.sum @@ -806,8 +806,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -oss.terrastruct.com/util-go v0.0.0-20221208100440-d1700fe6f48c h1:j1IK58Dgqi6FZxzSyWpgaFDRXvgxEeqqCEGFB+ULT/Y= -oss.terrastruct.com/util-go v0.0.0-20221208100440-d1700fe6f48c/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= +oss.terrastruct.com/util-go v0.0.0-20221208105526-b395c3a8b8fa h1:oOVEuDUTa38UGXb++mW4FSfIchXiC9VE5o0ncNcYOjY= +oss.terrastruct.com/util-go v0.0.0-20221208105526-b395c3a8b8fa/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= From 284892e531bab93074741916abcf1421c4363349 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 02:54:53 -0800 Subject: [PATCH 028/257] v0.1.1 --- ci/release/changelogs/next.md | 4 ---- ci/release/changelogs/v0.1.1.md | 7 +++++++ 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 ci/release/changelogs/v0.1.1.md diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 3fadfa006..f3c0d2a77 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -2,8 +2,4 @@ #### Improvements 🧹 -- The Windows release binary is now suffixed correctly with `.exe` [#388](https://github.com/terrastruct/d2/issues/388) - #### Bugfixes ⛑️ - -- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397) diff --git a/ci/release/changelogs/v0.1.1.md b/ci/release/changelogs/v0.1.1.md new file mode 100644 index 000000000..82704afbc --- /dev/null +++ b/ci/release/changelogs/v0.1.1.md @@ -0,0 +1,7 @@ +#### Improvements 🧹 + +- The Windows release binary is now suffixed correctly with `.exe` [#388](https://github.com/terrastruct/d2/issues/388) + +#### Bugfixes ⛑️ + +- Fixed sequence diagram span size for self-edges [#397](https://github.com/terrastruct/d2/pull/397) From d89354a8cf8824c1dbe98622ae7d467c14aee0a8 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 03:03:05 -0800 Subject: [PATCH 029/257] lib/version: Update whoops --- lib/version/version.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/version/version.go b/lib/version/version.go index b578347f7..77802c099 100644 --- a/lib/version/version.go +++ b/lib/version/version.go @@ -1,4 +1,4 @@ package version // Pre-built binaries will have version set correctly during build time. -var Version = "v0.1.0-HEAD" +var Version = "v0.1.1-HEAD" From 3fba3fbeacc19e0c3bf84c806a7c71e444c893de Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 04:00:08 -0800 Subject: [PATCH 030/257] ci: Ensure lockfile_ssh is used in a subshell --- ci/release/build.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/ci/release/build.sh b/ci/release/build.sh index 35797796a..e10426b92 100755 --- a/ci/release/build.sh +++ b/ci/release/build.sh @@ -190,7 +190,7 @@ build_local() { sh_c ./ci/release/_build.sh } -build_remote_macos() { +build_remote_macos() {( sh_c lockfile_ssh "$REMOTE_HOST" .d2-build-lock sh_c gitsync "$REMOTE_HOST" src/d2 sh_c ssh "$REMOTE_HOST" "COLOR=${COLOR-} \ @@ -205,9 +205,9 @@ PATH=\\\"/usr/local/bin:/usr/local/sbin:/opt/homebrew/bin:/opt/homebrew/sbin\\\$ ./src/d2/ci/release/_build.sh" sh_c mkdir -p "$HW_BUILD_DIR" sh_c rsync --archive --human-readable "$REMOTE_HOST:src/d2/$ARCHIVE" "$ARCHIVE" -} +)} -build_remote_linux() { +build_remote_linux() {( sh_c lockfile_ssh "$REMOTE_HOST" .d2-build-lock sh_c gitsync "$REMOTE_HOST" src/d2 sh_c ssh "$REMOTE_HOST" "COLOR=${COLOR-} \ @@ -221,7 +221,7 @@ ARCHIVE=$ARCHIVE \ ./src/d2/ci/release/build_docker.sh" sh_c mkdir -p "$HW_BUILD_DIR" sh_c rsync --archive --human-readable "$REMOTE_HOST:src/d2/$ARCHIVE" "$ARCHIVE" -} +)} ssh() { command ssh -o='StrictHostKeyChecking=accept-new' "$@" From 4f49cf6426c0925d238bb35424ebb1e6165b6054 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Thu, 8 Dec 2022 04:01:24 -0800 Subject: [PATCH 031/257] deps: update [ci-force] --- ci/release/template/scripts/lib.sh | 17 +++-------------- ci/sub | 2 +- go.mod | 2 +- go.sum | 4 ++-- install.sh | 17 +++-------------- 5 files changed, 10 insertions(+), 32 deletions(-) diff --git a/ci/release/template/scripts/lib.sh b/ci/release/template/scripts/lib.sh index a6e59fb27..fa7ad8bda 100644 --- a/ci/release/template/scripts/lib.sh +++ b/ci/release/template/scripts/lib.sh @@ -46,24 +46,13 @@ if [ "${LIB_TEMP-}" ]; then fi LIB_TEMP=1 -ensure_tmpdir() { - if [ -n "${_TMPDIR-}" ]; then - return - fi - +if [ -z "${_TMPDIR-}" ]; then _TMPDIR=$(mktemp -d) export _TMPDIR - trap temp_exittrap EXIT -} - -temp_exittrap() { - if [ -n "${_TMPDIR-}" ]; then - rm -r "$_TMPDIR" - fi -} + trap 'rm -Rf "$_TMPDIR"' EXIT +fi temppath() { - ensure_tmpdir while true; do temppath=$_TMPDIR/$( Date: Fri, 9 Dec 2022 17:21:05 -0800 Subject: [PATCH 032/257] add plugin links --- README.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 31152515b..634e70010 100644 --- a/README.md +++ b/README.md @@ -187,13 +187,18 @@ Open sourced under the Mozilla Public License 2.0. See [./LICENSE.txt](./LICENSE ## Related -### VSCode extension +### Official plugins -[https://github.com/terrastruct/d2-vscode](https://github.com/terrastruct/d2-vscode) +- **VSCode extension**: [https://github.com/terrastruct/d2-vscode](https://github.com/terrastruct/d2-vscode) +- **Vim extension**: [https://github.com/terrastruct/d2-vim](https://github.com/terrastruct/d2-vim) +- **Obsidian plugin**: [https://github.com/terrastruct/d2-obsidian](https://github.com/terrastruct/d2-obsidian) -### Vim extension +### Community plugins -[https://github.com/terrastruct/d2-vim](https://github.com/terrastruct/d2-vim) +- **Tree-sitter grammar**: [https://github.com/pleshevskiy/tree-sitter-d2](https://github.com/pleshevskiy/tree-sitter-d2) +- **Emacs extension**: [https://github.com/andorsk/d2-mode](https://github.com/andorsk/d2-mode) +- **Telegram bot**: [https://github.com/meinside/telegram-d2-bot](https://github.com/meinside/telegram-d2-bot) +- **Postgres importer**: [https://github.com/zekenie/d2-erd-from-postgres](https://github.com/zekenie/d2-erd-from-postgres) ### Language docs From 5e45b606a3dca6f65fa4276d2ec24ea7501ac461 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Fri, 9 Dec 2022 17:26:12 -0800 Subject: [PATCH 033/257] add description --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 634e70010..188ee0594 100644 --- a/README.md +++ b/README.md @@ -187,6 +187,12 @@ Open sourced under the Mozilla Public License 2.0. See [./LICENSE.txt](./LICENSE ## Related +We are constantly working on new plugins, integrations, extensions. Contributions are +welcome in any official or community plugins. If you have somewhere in your workflow that +you want to use D2, feel free to open a discussion. We have limited bandwidth and usually +choose the most high-demand ones to work on. If you make a plugin for one yourself, let us +know and we'll be happy to include it here or help you out! + ### Official plugins - **VSCode extension**: [https://github.com/terrastruct/d2-vscode](https://github.com/terrastruct/d2-vscode) From c23b17db150d7dd5e1107100920b460a069c3189 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Fri, 9 Dec 2022 17:28:11 -0800 Subject: [PATCH 034/257] edit --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 188ee0594..c2b69f7d6 100644 --- a/README.md +++ b/README.md @@ -190,8 +190,8 @@ Open sourced under the Mozilla Public License 2.0. See [./LICENSE.txt](./LICENSE We are constantly working on new plugins, integrations, extensions. Contributions are welcome in any official or community plugins. If you have somewhere in your workflow that you want to use D2, feel free to open a discussion. We have limited bandwidth and usually -choose the most high-demand ones to work on. If you make a plugin for one yourself, let us -know and we'll be happy to include it here or help you out! +choose the most high-demand ones to work on. If you make something cool with D2 yourself, +let us know and we'll be happy to include it here! ### Official plugins From 8b32b0965b9eefa3f227418bf73463ca835c9b37 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 10 Dec 2022 16:21:54 -0800 Subject: [PATCH 035/257] make compression dict determinstic --- lib/urlenc/urlenc.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/urlenc/urlenc.go b/lib/urlenc/urlenc.go index 64e08db11..a409fbdcd 100644 --- a/lib/urlenc/urlenc.go +++ b/lib/urlenc/urlenc.go @@ -5,6 +5,7 @@ import ( "compress/flate" "encoding/base64" "io" + "sort" "strings" "oss.terrastruct.com/util-go/xdefer" @@ -18,13 +19,18 @@ var compressionDict = "->" + "<->" func init() { + var common []string for k := range d2graph.StyleKeywords { - compressionDict += k + common = append(common, k) } for k := range d2graph.ReservedKeywords { - compressionDict += k + common = append(common, k) } for k := range d2graph.ReservedKeywordHolders { + common = append(common, k) + } + sort.Strings(common) + for _, k := range common { compressionDict += k } } From b6ac1e8114d1d12947bee7d4ff508214cef99992 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 11 Dec 2022 16:17:55 -0800 Subject: [PATCH 036/257] fix serialization casing --- d2graph/serde.go | 3 ++- d2graph/serde_test.go | 34 +++++++++++++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/d2graph/serde.go b/d2graph/serde.go index e5a8b1fbc..76e83ae2c 100644 --- a/d2graph/serde.go +++ b/d2graph/serde.go @@ -2,6 +2,7 @@ package d2graph import ( "encoding/json" + "strings" "oss.terrastruct.com/util-go/go2" ) @@ -48,7 +49,7 @@ func DeserializeGraph(bytes []byte, g *Graph) error { for _, id := range so["ChildrenArray"].([]interface{}) { o := idToObj[id.(string)] childrenArray = append(childrenArray, o) - children[id.(string)] = o + children[strings.ToLower(id.(string))] = o o.Parent = idToObj[so["AbsID"].(string)] } diff --git a/d2graph/serde_test.go b/d2graph/serde_test.go index 2afc65cbb..070400f20 100644 --- a/d2graph/serde_test.go +++ b/d2graph/serde_test.go @@ -14,9 +14,7 @@ func TestSerialization(t *testing.T) { t.Parallel() g, err := d2compiler.Compile("", strings.NewReader("a.a.b -> a.a.c"), nil) - if err != nil { - t.Fatal(err) - } + assert.Nil(t, err) asserts := func(g *d2graph.Graph) { assert.Equal(t, 4, len(g.Objects)) @@ -41,15 +39,33 @@ func TestSerialization(t *testing.T) { asserts(g) b, err := d2graph.SerializeGraph(g) - if err != nil { - t.Fatal(err) - } + assert.Nil(t, err) var newG d2graph.Graph err = d2graph.DeserializeGraph(b, &newG) - if err != nil { - t.Fatal(err) - } + assert.Nil(t, err) asserts(&newG) } + +func TestCasingRegression(t *testing.T) { + t.Parallel() + + script := `UserCreatedTypeField` + + g, err := d2compiler.Compile("", strings.NewReader(script), nil) + assert.Nil(t, err) + + _, ok := g.Root.HasChild([]string{"UserCreatedTypeField"}) + assert.True(t, ok) + + b, err := d2graph.SerializeGraph(g) + assert.Nil(t, err) + + var newG d2graph.Graph + err = d2graph.DeserializeGraph(b, &newG) + assert.Nil(t, err) + + _, ok = newG.Root.HasChild([]string{"UserCreatedTypeField"}) + assert.True(t, ok) +} From 65a6bbdc4681e35744d0ab507075a118b5ffbab6 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 11 Dec 2022 16:21:14 -0800 Subject: [PATCH 037/257] add changelog --- ci/release/changelogs/next.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index f3c0d2a77..0d163a20c 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -3,3 +3,6 @@ #### Improvements 🧹 #### Bugfixes ⛑️ + +- Fixed serialization affecting binary plugins (TALA). + [https://github.com/terrastruct/d2/pull/426](https://github.com/terrastruct/d2/pull/426) From c4483523bfd4d322dbc5bf38f0f57908cc7ce940 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 11 Dec 2022 16:28:30 -0800 Subject: [PATCH 038/257] fix sequence diagram with no messages --- ci/release/changelogs/next.md | 2 + d2layouts/d2sequence/sequence_diagram.go | 11 +- e2etests/regression_test.go | 5 + .../dagre/board.exp.json | 165 ++++++++++++++++++ .../dagre/sketch.exp.svg | 28 +++ .../elk/board.exp.json | 165 ++++++++++++++++++ .../elk/sketch.exp.svg | 28 +++ 7 files changed, 401 insertions(+), 3 deletions(-) create mode 100644 e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/sequence_diagram_no_message/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json create mode 100644 e2etests/testdata/regression/sequence_diagram_no_message/elk/sketch.exp.svg diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 0d163a20c..9366912b5 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -4,5 +4,7 @@ #### Bugfixes ⛑️ +- Fixed crash when sequence diagrams had no messages + [https://github.com/terrastruct/d2/pull/427](https://github.com/terrastruct/d2/pull/427) - Fixed serialization affecting binary plugins (TALA). [https://github.com/terrastruct/d2/pull/426](https://github.com/terrastruct/d2/pull/426) diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index 4eeac153a..b05ea10a6 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -299,14 +299,19 @@ func (sd *sequenceDiagram) placeActors() { // │ // │ func (sd *sequenceDiagram) addLifelineEdges() { - lastRoute := sd.messages[len(sd.messages)-1].Route endY := 0. - for _, p := range lastRoute { - endY = math.Max(endY, p.Y) + if len(sd.messages) > 0 { + lastRoute := sd.messages[len(sd.messages)-1].Route + for _, p := range lastRoute { + endY = math.Max(endY, p.Y) + } } for _, note := range sd.notes { endY = math.Max(endY, note.TopLeft.Y+note.Height) } + for _, actor := range sd.actors { + endY = math.Max(endY, actor.TopLeft.Y+actor.Height) + } endY += sd.yStep for _, actor := range sd.actors { diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index a7eef68c1..7c627be74 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -34,6 +34,11 @@ A->B`, script: `shape: sequence_diagram b.1 -> b.1 b.1 -> b.1`, + }, { + name: "sequence_diagram_no_message", + script: `shape: sequence_diagram +a: A +b: B`, }, } diff --git a/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json new file mode 100644 index 000000000..5f1267bc6 --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json @@ -0,0 +1,165 @@ +{ + "name": "", + "shapes": [ + { + "id": "a", + "type": "", + "pos": { + "x": 24, + "y": 74 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "A", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 14, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "", + "pos": { + "x": 274, + "y": 74 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "B", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(a -- )[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a-lifeline-end-2251863791", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 200 + }, + { + "x": 99, + "y": 330 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(b -- )[0]", + "src": "b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 349, + "y": 200 + }, + { + "x": 349, + "y": 330 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence_diagram_no_message/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_no_message/dagre/sketch.exp.svg new file mode 100644 index 000000000..04f0e8b4e --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_no_message/dagre/sketch.exp.svg @@ -0,0 +1,28 @@ + +AB \ No newline at end of file diff --git a/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json new file mode 100644 index 000000000..5f1267bc6 --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json @@ -0,0 +1,165 @@ +{ + "name": "", + "shapes": [ + { + "id": "a", + "type": "", + "pos": { + "x": 24, + "y": 74 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "A", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 14, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "", + "pos": { + "x": 274, + "y": 74 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "B", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(a -- )[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a-lifeline-end-2251863791", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 200 + }, + { + "x": 99, + "y": 330 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(b -- )[0]", + "src": "b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 349, + "y": 200 + }, + { + "x": 349, + "y": 330 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence_diagram_no_message/elk/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_no_message/elk/sketch.exp.svg new file mode 100644 index 000000000..04f0e8b4e --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_no_message/elk/sketch.exp.svg @@ -0,0 +1,28 @@ + +AB \ No newline at end of file From 794e86498844866f2714f975f5642c35bcc95ca3 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 11 Dec 2022 16:46:09 -0800 Subject: [PATCH 039/257] fix constraint keyword --- d2compiler/compile.go | 3 + d2compiler/compile_test.go | 11 ++ .../TestCompile/constraint_label.exp.json | 174 ++++++++++++++++++ 3 files changed, 188 insertions(+) create mode 100644 testdata/d2compiler/TestCompile/constraint_label.exp.json diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 2d2cba269..c49a95a43 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -363,6 +363,9 @@ func (c *compiler) applyScalar(attrs *d2graph.Attributes, reserved string, box d } attrs.Direction.Value = scalar.ScalarString() return + case "constraint": + // Compilation for shape-specific keywords happens elsewhere + return } if _, ok := d2graph.StyleKeywords[reserved]; ok { diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index c6cc1c25c..f29db2f16 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -1618,6 +1618,17 @@ choo: { assert.String(t, "left", g.Objects[0].Attributes.Direction.Value) }, }, + { + name: "constraint_label", + + text: `foo { + label: bar + constraint: BIZ +}`, + assertions: func(t *testing.T, g *d2graph.Graph) { + assert.String(t, "bar", g.Objects[0].Attributes.Label.Value) + }, + }, { name: "invalid_direction", diff --git a/testdata/d2compiler/TestCompile/constraint_label.exp.json b/testdata/d2compiler/TestCompile/constraint_label.exp.json new file mode 100644 index 000000000..dcaadd251 --- /dev/null +++ b/testdata/d2compiler/TestCompile/constraint_label.exp.json @@ -0,0 +1,174 @@ +{ + "graph": { + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,0:0:0-3:1:38", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,0:0:0-3:1:38", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,0:0:0-0:3:3", + "value": [ + { + "string": "foo", + "raw_string": "foo" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,0:4:4-3:0:37", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,1:2:8-1:12:18", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,1:2:8-1:7:13", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,1:2:8-1:7:13", + "value": [ + { + "string": "label", + "raw_string": "label" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,1:9:15-1:12:18", + "value": [ + { + "string": "bar", + "raw_string": "bar" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,2:2:21-2:17:36", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,2:2:21-2:12:31", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,2:2:21-2:12:31", + "value": [ + { + "string": "constraint", + "raw_string": "constraint" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,2:14:33-2:17:36", + "value": [ + { + "string": "BIZ", + "raw_string": "BIZ" + } + ] + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ + { + "id": "foo", + "id_val": "foo", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,0:0:0-0:4:4", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/constraint_label.d2,0:0:0-0:3:3", + "value": [ + { + "string": "foo", + "raw_string": "foo" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "bar" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + } + ] + }, + "err": null +} From 115d618d8deab1a7302c0474e8244fc6fb963683 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 11 Dec 2022 16:47:23 -0800 Subject: [PATCH 040/257] changelog --- ci/release/changelogs/next.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 9366912b5..1bf1c2093 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -4,7 +4,9 @@ #### Bugfixes ⛑️ -- Fixed crash when sequence diagrams had no messages +- Fixed crash when sequence diagrams had no messages. [https://github.com/terrastruct/d2/pull/427](https://github.com/terrastruct/d2/pull/427) +- Fixed `constraint` keyword setting label. + [https://github.com/terrastruct/d2/issues/415](https://github.com/terrastruct/d2/issues/415) - Fixed serialization affecting binary plugins (TALA). [https://github.com/terrastruct/d2/pull/426](https://github.com/terrastruct/d2/pull/426) From 8feb4d474927dd7f08d4a9977313bce6b21e40d5 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 11 Dec 2022 23:31:01 -0800 Subject: [PATCH 041/257] add pad option --- ci/release/changelogs/next.md | 3 +++ ci/release/template/man/d2.1 | 3 +++ d2renderers/d2svg/d2svg.go | 14 +++++++------- docs/examples/lib/1-d2lib/d2lib.go | 2 +- docs/examples/lib/3-lowlevel/lowlevel.go | 2 +- e2etests/e2e_test.go | 2 +- main.go | 11 ++++++++--- watch.go | 3 ++- 8 files changed, 26 insertions(+), 14 deletions(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 1bf1c2093..fcaa580c4 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -1,5 +1,8 @@ #### Features 🚀 +- Diagram padding can now can be configured in the CLI (default 100px). + [https://github.com/terrastruct/d2/pull/431](https://github.com/terrastruct/d2/pull/431) + #### Improvements 🧹 #### Bugfixes ⛑️ diff --git a/ci/release/template/man/d2.1 b/ci/release/template/man/d2.1 index 275eca9da..cdfe48392 100644 --- a/ci/release/template/man/d2.1 +++ b/ci/release/template/man/d2.1 @@ -58,6 +58,9 @@ Port listening address when used with Set the diagram theme to the passed integer. For a list of available options, see .Lk https://oss.terrastruct.com/d2 .Ns . +.It Fl -pad Ar 100 +Pixels padded around the rendered diagram +.Ns . .It Fl l , -layout Ar dagre Set the diagram layout engine to the passed string. For a list of available options, run .Ar layout diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 11f083c46..022fcf66d 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -34,7 +34,7 @@ import ( ) const ( - padding = 100 + DEFAULT_PADDING = 100 MIN_ARROWHEAD_STROKE_WIDTH = 2 threeDeeOffset = 15 ) @@ -47,10 +47,10 @@ var styleCSS string //go:embed github-markdown.css var mdCSS string -func setViewbox(writer io.Writer, diagram *d2target.Diagram) (width int, height int) { +func setViewbox(writer io.Writer, diagram *d2target.Diagram, pad int) (width int, height int) { tl, br := diagram.BoundingBox() - w := br.X - tl.X + padding*2 - h := br.Y - tl.Y + padding*2 + w := br.X - tl.X + pad*2 + h := br.Y - tl.Y + pad*2 // TODO minify // TODO background stuff. e.g. dotted, grid, colors @@ -58,7 +58,7 @@ func setViewbox(writer io.Writer, diagram *d2target.Diagram) (width int, height `, w, h, tl.X-padding, tl.Y-padding, w, h) +width="%d" height="%d" viewBox="%d %d %d %d">`, w, h, tl.X-pad, tl.Y-pad, w, h) return w, h } @@ -949,9 +949,9 @@ func embedFonts(buf *bytes.Buffer) { } // TODO minify output at end -func Render(diagram *d2target.Diagram) ([]byte, error) { +func Render(diagram *d2target.Diagram, pad int) ([]byte, error) { buf := &bytes.Buffer{} - w, h := setViewbox(buf, diagram) + w, h := setViewbox(buf, diagram, pad) buf.WriteString(fmt.Sprintf(` \ No newline at end of file diff --git a/e2etests/testdata/stable/stylish/elk/board.exp.json b/e2etests/testdata/stable/stylish/elk/board.exp.json index 0cd252c22..89f1269bf 100644 --- a/e2etests/testdata/stable/stylish/elk/board.exp.json +++ b/e2etests/testdata/stable/stylish/elk/board.exp.json @@ -46,7 +46,7 @@ "type": "", "pos": { "x": 12, - "y": 238 + "y": 359 }, "width": 114, "height": 126, @@ -95,7 +95,7 @@ "strokeDash": 5, "strokeWidth": 2, "stroke": "green", - "label": "", + "label": "in style", "fontSize": 16, "fontFamily": "DEFAULT", "language": "", @@ -103,9 +103,9 @@ "italic": true, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0, - "labelPosition": "", + "labelWidth": 47, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", "labelPercentage": 0, "route": [ { @@ -114,7 +114,7 @@ }, { "x": 69, - "y": 238 + "y": 359 } ], "animated": false, diff --git a/e2etests/testdata/stable/stylish/elk/sketch.exp.svg b/e2etests/testdata/stable/stylish/elk/sketch.exp.svg index eff681d67..c472ba27b 100644 --- a/e2etests/testdata/stable/stylish/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/stylish/elk/sketch.exp.svg @@ -2,7 +2,7 @@ \ No newline at end of file From 412713e2b724d76223582e51bc3532a6782703bb Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 16 Dec 2022 15:44:26 -0800 Subject: [PATCH 052/257] render connection label background according to style.fill --- d2exporter/export.go | 4 ++++ d2renderers/d2svg/d2svg.go | 5 +++++ d2target/d2target.go | 1 + 3 files changed, 10 insertions(+) diff --git a/d2exporter/export.go b/d2exporter/export.go index 1f2a15b8d..96900ff01 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -200,6 +200,10 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection connection.StrokeWidth, _ = strconv.Atoi(edge.Attributes.Style.StrokeWidth.Value) } + if edge.Attributes.Style.Fill != nil { + connection.Fill = edge.Attributes.Style.Fill.Value + } + connection.FontSize = text.FontSize if edge.Attributes.Style.FontSize != nil { connection.FontSize, _ = strconv.Atoi(edge.Attributes.Style.FontSize.Value) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 022fcf66d..6e31221c8 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -432,6 +432,11 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co if connection.Color != "" { fontColor = connection.Color } + + if connection.Fill != "" { + fmt.Fprintf(writer, ``, + labelTL.X, labelTL.Y, connection.LabelWidth, connection.LabelHeight, connection.Fill) + } textStyle := fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "middle", connection.FontSize, fontColor) x := labelTL.X + float64(connection.LabelWidth)/2 y := labelTL.Y + float64(connection.FontSize) diff --git a/d2target/d2target.go b/d2target/d2target.go index 41dc4c718..ae098fd28 100644 --- a/d2target/d2target.go +++ b/d2target/d2target.go @@ -207,6 +207,7 @@ type Connection struct { StrokeDash float64 `json:"strokeDash"` StrokeWidth int `json:"strokeWidth"` Stroke string `json:"stroke"` + Fill string `json:"fill,omitempty"` Text LabelPosition string `json:"labelPosition"` From 73a4ac1a6e8d4deba36e9c8b41587bda55c74c59 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Fri, 16 Dec 2022 15:48:24 -0800 Subject: [PATCH 053/257] update tests --- e2etests/testdata/stable/font_sizes/dagre/board.exp.json | 1 + e2etests/testdata/stable/font_sizes/dagre/sketch.exp.svg | 2 +- e2etests/testdata/stable/font_sizes/elk/board.exp.json | 1 + e2etests/testdata/stable/font_sizes/elk/sketch.exp.svg | 2 +- e2etests/testdata/stable/stylish/dagre/board.exp.json | 1 + e2etests/testdata/stable/stylish/dagre/sketch.exp.svg | 2 +- e2etests/testdata/stable/stylish/elk/board.exp.json | 1 + e2etests/testdata/stable/stylish/elk/sketch.exp.svg | 2 +- 8 files changed, 8 insertions(+), 4 deletions(-) diff --git a/e2etests/testdata/stable/font_sizes/dagre/board.exp.json b/e2etests/testdata/stable/font_sizes/dagre/board.exp.json index 3a91ea14e..0579a08d9 100644 --- a/e2etests/testdata/stable/font_sizes/dagre/board.exp.json +++ b/e2etests/testdata/stable/font_sizes/dagre/board.exp.json @@ -591,6 +591,7 @@ "strokeDash": 0, "strokeWidth": 2, "stroke": "#0D32B2", + "fill": "lavender", "label": "custom 48", "fontSize": 48, "fontFamily": "DEFAULT", diff --git a/e2etests/testdata/stable/font_sizes/dagre/sketch.exp.svg b/e2etests/testdata/stable/font_sizes/dagre/sketch.exp.svg index 578b7397c..0d98903f7 100644 --- a/e2etests/testdata/stable/font_sizes/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/font_sizes/dagre/sketch.exp.svg @@ -18,7 +18,7 @@ width="2360" height="632" viewBox="-100 -100 2360 632">size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 diff --git a/e2etests/testdata/stable/font_sizes/elk/board.exp.json b/e2etests/testdata/stable/font_sizes/elk/board.exp.json index 2d5446e61..9658ee501 100644 --- a/e2etests/testdata/stable/font_sizes/elk/board.exp.json +++ b/e2etests/testdata/stable/font_sizes/elk/board.exp.json @@ -573,6 +573,7 @@ "strokeDash": 0, "strokeWidth": 2, "stroke": "#0D32B2", + "fill": "lavender", "label": "custom 48", "fontSize": 48, "fontFamily": "DEFAULT", diff --git a/e2etests/testdata/stable/font_sizes/elk/sketch.exp.svg b/e2etests/testdata/stable/font_sizes/elk/sketch.exp.svg index cb9321042..9c69d48ce 100644 --- a/e2etests/testdata/stable/font_sizes/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/font_sizes/elk/sketch.exp.svg @@ -18,7 +18,7 @@ width="1965" height="793" viewBox="-88 -88 1965 793">size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 diff --git a/e2etests/testdata/stable/stylish/dagre/board.exp.json b/e2etests/testdata/stable/stylish/dagre/board.exp.json index 10836e6e0..7dce7c5ce 100644 --- a/e2etests/testdata/stable/stylish/dagre/board.exp.json +++ b/e2etests/testdata/stable/stylish/dagre/board.exp.json @@ -95,6 +95,7 @@ "strokeDash": 5, "strokeWidth": 2, "stroke": "green", + "fill": "lavender", "label": "in style", "fontSize": 16, "fontFamily": "DEFAULT", diff --git a/e2etests/testdata/stable/stylish/dagre/sketch.exp.svg b/e2etests/testdata/stable/stylish/dagre/sketch.exp.svg index f73951c97..8283749e7 100644 --- a/e2etests/testdata/stable/stylish/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/stylish/dagre/sketch.exp.svg @@ -28,7 +28,7 @@ width="314" height="552" viewBox="-100 -100 314 552">ninetynineeighty eightseventy sevena\yodetherea\"odea\node ninetynineeighty eightseventy sevena\yodetherea\"odea\node + + +ninetynineeighty eightseventy sevena\yodetherea\"odea\node ninetynineeighty eightseventy sevena\yodetherea\"odea\node + + +hellogoodbye hellogoodbye + + +hellogoodbye hellogoodbye + + +ABAB + + +ABAB + + +b b + + +b b + + +abc abc + + +abc abc + + +ab ab + + +ab ab + + +acbd acbd + + +acbd acbd + + + \ No newline at end of file + + + + \ No newline at end of file diff --git a/e2etests/testdata/sanity/empty/elk/sketch.exp.svg b/e2etests/testdata/sanity/empty/elk/sketch.exp.svg index 9563e1411..20d55bdc1 100644 --- a/e2etests/testdata/sanity/empty/elk/sketch.exp.svg +++ b/e2etests/testdata/sanity/empty/elk/sketch.exp.svg @@ -18,4 +18,7 @@ width="200" height="200" viewBox="-100 -100 200 200"> \ No newline at end of file + + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/all_shapes/dagre/sketch.exp.svg b/e2etests/testdata/stable/all_shapes/dagre/sketch.exp.svg index 864693eac..095790f60 100644 --- a/e2etests/testdata/stable/all_shapes/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/all_shapes/dagre/sketch.exp.svg @@ -18,7 +18,10 @@ width="1539" height="824" viewBox="-100 -100 1539 824">rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + + +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + + +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + + +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + + +cba * cba * + + +cba * cba * + + +abcdefghijklmno abcdefghijklmno + + +abcdefghijklmno abcdefghijklmno + + +abcd abcd + + +abcd abcd + + +abc abc + + +abc abc + + +acfbdhg acfbdhg + + +acfbdhg acfbdhg + + +agdfbhec agdfbhec + + +agdfbhec agdfbhec + + +abcdefghijklmnopq abcdefghijklmnopq + + +abcdefghijklmnopq abcdefghijklmnopq + + +finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot + + +finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot + + +bacde21345abcde bacde21345abcde + + +bacde21345abcde bacde21345abcde + + +hellohello + + +hellohello + + +ab ab + + +ab ab + + +abcdefghiqrjmnoszaabbeeffggklptuwxyccddv abcdefghiqrjmnoszaabbeeffggklptuwxyccddv + + +abcdefghiqrjmnoszaabbeeffggklptuwxyccddv abcdefghiqrjmnoszaabbeeffggklptuwxyccddv + + +

Markdown: Syntax

-
ab

Markdown: Syntax

-
ab markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-

code

-
ab

code

-
ab thisgoesmultiple linesthisgoesmultiple lines + + +thisgoesmultiple linesthisgoesmultiple lines + + +abcdefghijklmnopqrstuvw abcdefghijklmnopqrstuvw + + +abcdefghijklmnopqrstuvw abcdefghijklmnopqrstuvw + + +abcdefghijklmnopqrstu abcdefghijklmnopqrstu + + +abcdefghijklmnopqrstu abcdefghijklmnopqrstu + + +Foo Baz12hello Foo Baz12hello + + +Foo Baz12hello Foo Baz12hello + + +acdefgbh acdefgbh + + +acdefgbh acdefgbh + + +topabcbottomstartend topabcbottomstartend + + +topabcbottomstartend topabcbottomstartend + + +ba a note here to remember that padding must consider notes toojustalongnotehereba a note here to remember that padding must consider notes toojustalongnotehere + + +ba a note here to remember that padding must consider notes toojustalongnotehereba a note here to remember that padding must consider notes toojustalongnotehere + + +scoreritemResponseitemessayRubricconceptitemOutcome scoreritemResponseitemessayRubricconceptitemOutcome + + +scoreritemResponseitemessayRubricconceptitemOutcome scoreritemResponseitemessayRubricconceptitemOutcome + + +acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc + + +acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc + + + -cube -cubeAKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTNDAKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND + + +AKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTNDAKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND + + +ninety ninesixty fourthirty twosixteeneightninety ninesixty fourthirty twosixteeneight + + +ninety ninesixty fourthirty twosixteeneightninety ninesixty fourthirty twosixteeneight + + +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud cba * +cba * aaadddeeebbbccc111 222 +aaadddeeebbbccc111 222 - + aabbllmm

nn

oocciikkdd

gg

hhjj

ee

-
ff1122 334455667788 +ff1122 334455667788 - + - + aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - - + + diff --git a/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json index 3ed298e02..81a532b8a 100644 --- a/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json @@ -3565,7 +3565,7 @@ "route": [ { "x": 748, - "y": 176 + "y": 165 }, { "x": 748, @@ -3729,7 +3729,7 @@ "route": [ { "x": 830, - "y": 176 + "y": 165 }, { "x": 830, diff --git a/e2etests/testdata/stable/sequence_diagrams/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagrams/elk/sketch.exp.svg index b043d6fdd..938982dd1 100644 --- a/e2etests/testdata/stable/sequence_diagrams/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagrams/elk/sketch.exp.svg @@ -18,7 +18,7 @@ width="3324" height="4389" viewBox="-88 -88 3324 4389">a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) +a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) From a0515da60b4582a00acd6deddd9e6bc5e46e48ce Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Sat, 17 Dec 2022 20:47:14 -0800 Subject: [PATCH 064/257] changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 14a6c2a39..10392f641 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -17,4 +17,5 @@ [https://github.com/terrastruct/d2/issues/415](https://github.com/terrastruct/d2/issues/415) - Fixed serialization affecting binary plugins (TALA). [https://github.com/terrastruct/d2/pull/426](https://github.com/terrastruct/d2/pull/426) +- Fixed connections in elk layouts not going all the way to shape borders. [https://github.com/terrastruct/d2/pull/459](https://github.com/terrastruct/d2/pull/459) - Fixed a connection rendering bug that could happen in firefox when there were no connection labels. [https://github.com/terrastruct/d2/pull/453](https://github.com/terrastruct/d2/pull/453) From d28aed6184d163a45922073d603b39c6af08c137 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Sat, 17 Dec 2022 20:59:02 -0800 Subject: [PATCH 065/257] add markdown_stroke_fill e2e test --- e2etests/stable_test.go | 30 + .../markdown_stroke_fill/dagre/board.exp.json | 173 ++++ .../markdown_stroke_fill/dagre/sketch.exp.svg | 803 ++++++++++++++++++ .../markdown_stroke_fill/elk/board.exp.json | 164 ++++ .../markdown_stroke_fill/elk/sketch.exp.svg | 803 ++++++++++++++++++ 5 files changed, 1973 insertions(+) create mode 100644 e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json create mode 100644 e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json create mode 100644 e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index be9381938..76f4cf12a 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -1483,6 +1483,36 @@ a.note: "just\na\nlong\nnote\nhere"`, script: `shape: sequence_diagram alice -> bob: what does it mean to be well-adjusted bob -> alice: The ability to play bridge or golf as if they were games +`, + }, + { + name: "markdown_stroke_fill", + script: ` +container.md: |md +# a header + +a line of text and an + + { + indented: "block", + of: "json", + } + +walk into a bar. +| { + style.stroke: darkorange +} + +container -> no container + +no container: |md +they did it in style +| + +no container.style: { + stroke: red + fill: "#CEEDEE" +} `, }, } diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json new file mode 100644 index 000000000..820cea6e3 --- /dev/null +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json @@ -0,0 +1,173 @@ +{ + "name": "", + "shapes": [ + { + "id": "container", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 312, + "height": 357, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "container", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 117, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "container.md", + "type": "text", + "pos": { + "x": 50, + "y": 50 + }, + "width": 212, + "height": 257, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "darkorange", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "# a header\n\na line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n\nwalk into a bar.", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 212, + "labelHeight": 257, + "zIndex": 0, + "level": 2 + }, + { + "id": "no container", + "type": "text", + "pos": { + "x": 97, + "y": 457 + }, + "width": 118, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#CEEDEE", + "stroke": "red", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "they did it in style", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 118, + "labelHeight": 24, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(container -> no container)[0]", + "src": "container", + "srcArrow": "none", + "srcLabel": "", + "dst": "no container", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 156, + "y": 357 + }, + { + "x": 156, + "y": 397 + }, + { + "x": 156, + "y": 417 + }, + { + "x": 156, + "y": 457 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg b/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg new file mode 100644 index 000000000..c72e2fc93 --- /dev/null +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg @@ -0,0 +1,803 @@ + +container

they did it in style

+

a header

+

a line of text and an

+
{
+	indented: "block",
+	of: "json",
+}
+
+

walk into a bar.

+
+ + +
\ No newline at end of file diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json new file mode 100644 index 000000000..884a594e3 --- /dev/null +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json @@ -0,0 +1,164 @@ +{ + "name": "", + "shapes": [ + { + "id": "container", + "type": "", + "pos": { + "x": 12, + "y": 12 + }, + "width": 362, + "height": 407, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "container", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 117, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "container.md", + "type": "text", + "pos": { + "x": 87, + "y": 87 + }, + "width": 212, + "height": 257, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "darkorange", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "# a header\n\na line of text and an\n\n\t{\n\t\tindented: \"block\",\n\t\tof: \"json\",\n\t}\n\nwalk into a bar.", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 212, + "labelHeight": 257, + "zIndex": 0, + "level": 2 + }, + { + "id": "no container", + "type": "text", + "pos": { + "x": 134, + "y": 519 + }, + "width": 118, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#CEEDEE", + "stroke": "red", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "they did it in style", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 118, + "labelHeight": 24, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(container -> no container)[0]", + "src": "container", + "srcArrow": "none", + "srcLabel": "", + "dst": "no container", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 193, + "y": 419 + }, + { + "x": 193, + "y": 519 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg b/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg new file mode 100644 index 000000000..9423f5d3c --- /dev/null +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg @@ -0,0 +1,803 @@ + +container

they did it in style

+

a header

+

a line of text and an

+
{
+	indented: "block",
+	of: "json",
+}
+
+

walk into a bar.

+
+ + +
\ No newline at end of file From 1a3511d632ea866f7467fcaa0a09e4276ac38a95 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Sat, 17 Dec 2022 21:22:33 -0800 Subject: [PATCH 066/257] apply stroke and fill to markdown --- d2exporter/export.go | 2 ++ d2graph/d2graph.go | 5 ++++- d2renderers/d2svg/d2svg.go | 11 ++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/d2exporter/export.go b/d2exporter/export.go index 96900ff01..952a85662 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -45,6 +45,8 @@ func applyStyles(shape *d2target.Shape, obj *d2graph.Object) { } if obj.Attributes.Style.Fill != nil { shape.Fill = obj.Attributes.Style.Fill.Value + } else if obj.Attributes.Shape.Value == d2target.ShapeText { + shape.Fill = "transparent" } if obj.Attributes.Style.Stroke != nil { shape.Stroke = obj.Attributes.Style.Stroke.Value diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 838ffe6d7..528df55c1 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -397,7 +397,10 @@ func (obj *Object) GetFill(theme *d2themes.Theme) string { func (obj *Object) GetStroke(theme *d2themes.Theme, dashGapSize interface{}) string { shape := obj.Attributes.Shape.Value - if strings.EqualFold(shape, d2target.ShapeCode) || strings.EqualFold(shape, d2target.ShapeClass) || strings.EqualFold(shape, d2target.ShapeSQLTable) { + if strings.EqualFold(shape, d2target.ShapeCode) || + strings.EqualFold(shape, d2target.ShapeClass) || + strings.EqualFold(shape, d2target.ShapeSQLTable) || + strings.EqualFold(shape, d2target.ShapeText) { return theme.Colors.Neutrals.N1 } if dashGapSize != 0.0 { diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index db5b650bc..41a0c63a6 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -770,7 +770,16 @@ func drawShape(writer io.Writer, targetShape d2target.Shape) (labelMask string, ) // we need the self closing form in this svg/xhtml context render = strings.ReplaceAll(render, "
", "
") - fmt.Fprintf(writer, `
%v
`, render) + + var mdStyle string + if targetShape.Fill != "" { + mdStyle = fmt.Sprintf("background-color:%s;", targetShape.Fill) + } + if targetShape.Stroke != "" { + mdStyle += fmt.Sprintf("color:%s;", targetShape.Stroke) + } + + fmt.Fprintf(writer, `
%v
`, mdStyle, render) fmt.Fprint(writer, ``) } default: From 0266a1f802f80cb362b1b6adcff6bf1ce5828dcc Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Sat, 17 Dec 2022 21:34:42 -0800 Subject: [PATCH 067/257] update tests --- e2etests/testdata/stable/chaos2/dagre/board.exp.json | 12 ++++++------ e2etests/testdata/stable/chaos2/dagre/sketch.exp.svg | 8 ++++---- e2etests/testdata/stable/chaos2/elk/board.exp.json | 12 ++++++------ e2etests/testdata/stable/chaos2/elk/sketch.exp.svg | 8 ++++---- .../stable/giant_markdown_test/dagre/board.exp.json | 4 ++-- .../stable/giant_markdown_test/dagre/sketch.exp.svg | 4 ++-- .../stable/giant_markdown_test/elk/board.exp.json | 4 ++-- .../stable/giant_markdown_test/elk/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/hr/dagre/board.exp.json | 4 ++-- e2etests/testdata/stable/hr/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/hr/elk/board.exp.json | 4 ++-- e2etests/testdata/stable/hr/elk/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/latex/dagre/board.exp.json | 12 ++++++------ e2etests/testdata/stable/latex/dagre/sketch.exp.svg | 2 +- e2etests/testdata/stable/latex/elk/board.exp.json | 12 ++++++------ e2etests/testdata/stable/latex/elk/sketch.exp.svg | 2 +- e2etests/testdata/stable/li1/dagre/board.exp.json | 4 ++-- e2etests/testdata/stable/li1/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/li1/elk/board.exp.json | 4 ++-- e2etests/testdata/stable/li1/elk/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/li2/dagre/board.exp.json | 4 ++-- e2etests/testdata/stable/li2/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/li2/elk/board.exp.json | 4 ++-- e2etests/testdata/stable/li2/elk/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/li3/dagre/board.exp.json | 4 ++-- e2etests/testdata/stable/li3/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/li3/elk/board.exp.json | 4 ++-- e2etests/testdata/stable/li3/elk/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/li4/dagre/board.exp.json | 4 ++-- e2etests/testdata/stable/li4/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/li4/elk/board.exp.json | 4 ++-- e2etests/testdata/stable/li4/elk/sketch.exp.svg | 4 ++-- .../testdata/stable/lone_h1/dagre/board.exp.json | 4 ++-- .../testdata/stable/lone_h1/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/lone_h1/elk/board.exp.json | 4 ++-- e2etests/testdata/stable/lone_h1/elk/sketch.exp.svg | 4 ++-- .../testdata/stable/markdown/dagre/board.exp.json | 4 ++-- .../testdata/stable/markdown/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/markdown/elk/board.exp.json | 4 ++-- e2etests/testdata/stable/markdown/elk/sketch.exp.svg | 4 ++-- .../stable/markdown_stroke_fill/dagre/board.exp.json | 2 +- .../stable/markdown_stroke_fill/dagre/sketch.exp.svg | 6 +++--- .../stable/markdown_stroke_fill/elk/board.exp.json | 2 +- .../stable/markdown_stroke_fill/elk/sketch.exp.svg | 6 +++--- .../stable/md_2space_newline/dagre/board.exp.json | 4 ++-- .../stable/md_2space_newline/dagre/sketch.exp.svg | 4 ++-- .../stable/md_2space_newline/elk/board.exp.json | 4 ++-- .../stable/md_2space_newline/elk/sketch.exp.svg | 4 ++-- .../stable/md_backslash_newline/dagre/board.exp.json | 4 ++-- .../stable/md_backslash_newline/dagre/sketch.exp.svg | 4 ++-- .../stable/md_backslash_newline/elk/board.exp.json | 4 ++-- .../stable/md_backslash_newline/elk/sketch.exp.svg | 4 ++-- .../stable/md_code_block_fenced/dagre/board.exp.json | 4 ++-- .../stable/md_code_block_fenced/dagre/sketch.exp.svg | 4 ++-- .../stable/md_code_block_fenced/elk/board.exp.json | 4 ++-- .../stable/md_code_block_fenced/elk/sketch.exp.svg | 4 ++-- .../md_code_block_indented/dagre/board.exp.json | 4 ++-- .../md_code_block_indented/dagre/sketch.exp.svg | 4 ++-- .../stable/md_code_block_indented/elk/board.exp.json | 4 ++-- .../stable/md_code_block_indented/elk/sketch.exp.svg | 4 ++-- .../stable/md_code_inline/dagre/board.exp.json | 4 ++-- .../stable/md_code_inline/dagre/sketch.exp.svg | 4 ++-- .../stable/md_code_inline/elk/board.exp.json | 4 ++-- .../stable/md_code_inline/elk/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/p/dagre/board.exp.json | 4 ++-- e2etests/testdata/stable/p/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/p/elk/board.exp.json | 4 ++-- e2etests/testdata/stable/p/elk/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/pre/dagre/board.exp.json | 4 ++-- e2etests/testdata/stable/pre/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/pre/elk/board.exp.json | 4 ++-- e2etests/testdata/stable/pre/elk/sketch.exp.svg | 4 ++-- 72 files changed, 162 insertions(+), 162 deletions(-) diff --git a/e2etests/testdata/stable/chaos2/dagre/board.exp.json b/e2etests/testdata/stable/chaos2/dagre/board.exp.json index c928b6a24..79dbd4512 100644 --- a/e2etests/testdata/stable/chaos2/dagre/board.exp.json +++ b/e2etests/testdata/stable/chaos2/dagre/board.exp.json @@ -174,8 +174,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0D32B2", + "fill": "transparent", + "stroke": "#0A0F25", "shadow": false, "3d": false, "multiple": false, @@ -253,8 +253,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0D32B2", + "fill": "transparent", + "stroke": "#0A0F25", "shadow": false, "3d": false, "multiple": false, @@ -532,8 +532,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0D32B2", + "fill": "transparent", + "stroke": "#0A0F25", "shadow": false, "3d": false, "multiple": false, diff --git a/e2etests/testdata/stable/chaos2/dagre/sketch.exp.svg b/e2etests/testdata/stable/chaos2/dagre/sketch.exp.svg index f29093782..ef295905d 100644 --- a/e2etests/testdata/stable/chaos2/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/chaos2/dagre/sketch.exp.svg @@ -774,10 +774,10 @@ width="1317" height="1854" viewBox="-100 -100 1317 1854">aabbllmm

nn

-
oocciikkdd

gg

-
hhjj

ee

-
ff1122 334455667788 +aabbllmm

nn

+
oocciikkdd

gg

+
hhjj

ee

+
ff1122 334455667788 diff --git a/e2etests/testdata/stable/chaos2/elk/board.exp.json b/e2etests/testdata/stable/chaos2/elk/board.exp.json index 1aa503f04..9efdf2116 100644 --- a/e2etests/testdata/stable/chaos2/elk/board.exp.json +++ b/e2etests/testdata/stable/chaos2/elk/board.exp.json @@ -174,8 +174,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0D32B2", + "fill": "transparent", + "stroke": "#0A0F25", "shadow": false, "3d": false, "multiple": false, @@ -253,8 +253,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0D32B2", + "fill": "transparent", + "stroke": "#0A0F25", "shadow": false, "3d": false, "multiple": false, @@ -532,8 +532,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0D32B2", + "fill": "transparent", + "stroke": "#0A0F25", "shadow": false, "3d": false, "multiple": false, diff --git a/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg b/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg index f55323cfa..d40735703 100644 --- a/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg @@ -774,10 +774,10 @@ width="1092" height="1907" viewBox="-88 -88 1092 1907">aabbllmm

nn

-
oocciikkdd

gg

-
hhjj

ee

-
ff1122 334455667788 +aabbllmm

nn

+
oocciikkdd

gg

+
hhjj

ee

+
ff1122 334455667788 diff --git a/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json b/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json index 62256201b..414bc5f4a 100644 --- a/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json +++ b/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json @@ -14,8 +14,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0D32B2", + "fill": "transparent", + "stroke": "#0A0F25", "shadow": false, "3d": false, "multiple": false, diff --git a/e2etests/testdata/stable/giant_markdown_test/dagre/sketch.exp.svg b/e2etests/testdata/stable/giant_markdown_test/dagre/sketch.exp.svg index 920493c11..14fc3e202 100644 --- a/e2etests/testdata/stable/giant_markdown_test/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/giant_markdown_test/dagre/sketch.exp.svg @@ -774,7 +774,7 @@ width="3251" height="5500" viewBox="-100 -100 3251 5500">

Markdown: Syntax

+

Markdown: Syntax

  • Overview
      @@ -1031,7 +1031,7 @@ title for the link, surrounded in quotes. For example:

      Code

      Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example:

      -
ab +
ab

Markdown: Syntax

+

Markdown: Syntax

  • Overview
      @@ -1031,7 +1031,7 @@ title for the link, surrounded in quotes. For example:

      Code

      Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example:

      -
ab +
ab

Note: This document is itself written using Markdown; you +

Note: This document is itself written using Markdown; you can see the source for it by adding '.text' to the URL.


Overview

-
ab +
ab

Note: This document is itself written using Markdown; you +

Note: This document is itself written using Markdown; you can see the source for it by adding '.text' to the URL.


Overview

-
ab +
ab mixed togethersugarsolution we get +mixed togethersugarsolution we get mixed togethersugarsolution we get +mixed togethersugarsolution we get
    +
    • Overview
      • Philosophy
      • @@ -786,7 +786,7 @@ width="579" height="752" viewBox="-100 -100 579 752">
          +
          • Overview
            • Philosophy
            • @@ -786,7 +786,7 @@ width="579" height="752" viewBox="-88 -88 579 752">
                +
                • Overview ok this is all measured
                  • Philosophy
                  • @@ -782,7 +782,7 @@ width="445" height="728" viewBox="-100 -100 445 728">
                      +
                      • Overview ok this is all measured
                        • Philosophy
                        • @@ -782,7 +782,7 @@ width="445" height="728" viewBox="-88 -88 445 728">
                            +
                            • Overview
                              • Philosophy
                              • @@ -807,7 +807,7 @@ width="547" height="1164" viewBox="-100 -100 547 1164">
                                  +
                                  • Overview
                                    • Philosophy
                                    • @@ -807,7 +807,7 @@ width="547" height="1164" viewBox="-88 -88 547 1164">

                                      List items may consist of multiple paragraphs. Each subsequent +

                                      List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

                                        @@ -805,7 +805,7 @@ sit amet, consectetuer adipiscing elit.

                                        Another item in the same list.

                                    -
                                  ab +
                                ab

                                List items may consist of multiple paragraphs. Each subsequent +

                                List items may consist of multiple paragraphs. Each subsequent paragraph in a list item must be indented by either 4 spaces or one tab:

                                  @@ -805,7 +805,7 @@ sit amet, consectetuer adipiscing elit.

                                  Another item in the same list.

                              -
                            ab +
                          ab

                          Markdown: Syntax

                          -
                          ab +

                          Markdown: Syntax

                          +
                          ab

                          Markdown: Syntax

                          -
                          ab +

                          Markdown: Syntax

                          +
                          ab

                          Every frustum longs to be a cone

                          +

                          Every frustum longs to be a cone

                          • A continuing flow of paper is sufficient to continue the flow of paper
                          • Please remain calm, it's no use both of us being hysterical at the same time
                          • Visits always give pleasure: if not on arrival, then on the departure

                          Festivity Level 1: Your guests are chatting amiably with each other.

                          -
                          xy +
                          xy

                          Every frustum longs to be a cone

                          +

                          Every frustum longs to be a cone

                          • A continuing flow of paper is sufficient to continue the flow of paper
                          • Please remain calm, it's no use both of us being hysterical at the same time
                          • Visits always give pleasure: if not on arrival, then on the departure

                          Festivity Level 1: Your guests are chatting amiably with each other.

                          -
                          xy +
                          xy container

                          they did it in style

                          -

                          a header

                          +container

                          they did it in style

                          +

                          a header

                          a line of text and an

                          {
                           	indented: "block",
                          @@ -783,7 +783,7 @@ width="512" height="681" viewBox="-100 -100 512 681">container

                          they did it in style

                          -

                          a header

                          +container

                          they did it in style

                          +

                          a header

                          a line of text and an

                          {
                           	indented: "block",
                          @@ -783,7 +783,7 @@ width="562" height="731" viewBox="-88 -88 562 731">markdown

                          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                          +markdown

                          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                          sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

                          -
                          +
                          markdown

                          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                          +markdown

                          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                          sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

                          -
                          +
                          markdown

                          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                          +markdown

                          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                          sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

                          -
                          +
                          markdown

                          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                          +markdown

                          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                          sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

                          -
                          +
                          {
                          +
                          {
                           	fenced: "block",
                           	of: "json",
                           }
                           
                          -
                          ab +
                          ab
                          {
                          +
                          {
                           	fenced: "block",
                           	of: "json",
                           }
                           
                          -
                          ab +
                          ab

                          a line of text and an

                          +

                          a line of text and an

                          {
                           	indented: "block",
                           	of: "json",
                           }
                           
                          -
                          ab +
                          ab

                          a line of text and an

                          +

                          a line of text and an

                          {
                           	indented: "block",
                           	of: "json",
                           }
                           
                          -
                          ab +
                          ab

                          code

                          -
                          ab +

                          code

                          +
                          ab

                          code

                          -
                          ab +

                          code

                          +
                          ab

                          A paragraph is simply one or more consecutive lines of text, separated +

                          A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.

                          -
                          ab +
                          ab

                          A paragraph is simply one or more consecutive lines of text, separated +

                          A paragraph is simply one or more consecutive lines of text, separated by one or more blank lines. (A blank line is any line that looks like a blank line -- a line containing nothing but spaces or tabs is considered blank.) Normal paragraphs should not be indented with spaces or tabs.

                          -
                          ab +
                          ab

                          Here is an example of AppleScript:

                          +

                          Here is an example of AppleScript:

                          tell application "Foo"
                               beep
                           end tell
                           

                          A code block continues until it reaches a line that is not indented (or the end of the article).

                          -
                          ab +
                          ab

                          Here is an example of AppleScript:

                          +

                          Here is an example of AppleScript:

                          tell application "Foo"
                               beep
                           end tell
                           

                          A code block continues until it reaches a line that is not indented (or the end of the article).

                          -
                          ab +
                          ab success: successfully compiled - to - --- main.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/main.go b/main.go index f37c40c0a..ce2af7899 100644 --- a/main.go +++ b/main.go @@ -243,6 +243,10 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, pad, if err != nil { return svg, false, err } + } else { + if len(out) > 0 && out[len(out)-1] != '\n' { + out = append(out, '\n') + } } err = ms.WritePath(outputPath, out) From 4a5a02a4cc2e5842da9e7eb388e84225c5a1f7b8 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 11:22:37 -0800 Subject: [PATCH 088/257] ci/sub: Update --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index 55bf1d39f..21542934c 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 55bf1d39f3d524804422d4bdb4559cd6ff151b49 +Subproject commit 21542934c5318ad3acab232bd15ef50e458663c6 From 54e2f870d2b9139e21788c92e7af9f6ea01e7f6a Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 11:32:20 -0800 Subject: [PATCH 089/257] ci/aws: Fix env on ubuntu --- ci/release/aws/ensure.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/release/aws/ensure.sh b/ci/release/aws/ensure.sh index 66cc1cb1b..d5de7dfca 100755 --- a/ci/release/aws/ensure.sh +++ b/ci/release/aws/ensure.sh @@ -381,6 +381,9 @@ init_remote_env() { if sh_c ssh "$REMOTE_HOST" uname | grep -qF Darwin; then sh_c ssh "$REMOTE_HOST" "sudo launchctl stop com.openssh.sshd" else + # ubuntu has $PATH hard coded in /etc/environment for some reason. It takes precedence + # over ~/.ssh/environment. + sh_c ssh "$REMOTE_HOST" "sudo rm /etc/environment" sh_c ssh "$REMOTE_HOST" "sudo systemctl restart sshd" fi } From 72c0b76a22e12fc2639af011ad5350e39403c318 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 11:45:48 -0800 Subject: [PATCH 090/257] ci/aws: Copy SSH keys onto macOS hosts --- ci/release/aws/ensure.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/release/aws/ensure.sh b/ci/release/aws/ensure.sh index d5de7dfca..fb61f4725 100755 --- a/ci/release/aws/ensure.sh +++ b/ci/release/aws/ensure.sh @@ -347,6 +347,8 @@ init_remote_macos() { header "$REMOTE_NAME" wait_remote_host + sh_c ssh_copy_id -i="$ID_PUB_PATH" "$REMOTE_HOST" + sh_c ssh "$REMOTE_HOST" '"/bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""' if sh_c ssh "$REMOTE_HOST" uname -m | grep -qF arm64; then From 84d732f804cdb55f9bddf28556d401d908947363 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 11:49:22 -0800 Subject: [PATCH 091/257] release/README.md: Update Windows template to reflect .msi installer --- ci/release/template/README.md.sh | 20 ++------------------ 1 file changed, 2 insertions(+), 18 deletions(-) diff --git a/ci/release/template/README.md.sh b/ci/release/template/README.md.sh index 7ccea6fb2..d08a71bf6 100755 --- a/ci/release/template/README.md.sh +++ b/ci/release/template/README.md.sh @@ -20,27 +20,11 @@ EOF if [ "$OS" = windows ]; then cat <\` - -For installation you'll have to add the \`./bin/d2.exe\` binary to your \`\$PATH\`. Or add -the \`./bin\` directory of this release to your \`\$PATH\`. - -See https://www.wikihow.com/Change-the-PATH-Environment-Variable-on-Windows - -Then you'll be able to call \`d2\` from the commandline in \`cmd.exe\` or \`pwsh.exe\`. - -We intend to have a \`.msi\` release installer sometime soon that handles putting \`d2.exe\` into +You may find our \`.msi\` installer more convenient as it handles putting \`d2.exe\` into your \`\$PATH\` for you. -You can also use \`make install\` to install on Windows after first installing -[MSYS2](https://www.msys2.org/) which emulates a Linux shell for Windows. Its terminal -also enables \`d2\` to show colors in its output. The manpage will also become accessible -with \`man d2\`. - See https://github.com/terrastruct/d2/blob/master/docs/INSTALL.md#windows EOF fi From ef73cce63bc5e14b38bd6d1ba6dc9a0eeb7bb79e Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 12:22:33 -0800 Subject: [PATCH 092/257] ci/aws: Install man-db on windows --- ci/release/aws/ensure.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release/aws/ensure.sh b/ci/release/aws/ensure.sh index fb61f4725..4ff4e1ee6 100755 --- a/ci/release/aws/ensure.sh +++ b/ci/release/aws/ensure.sh @@ -468,7 +468,7 @@ if (-Not (Test-Path -Path C:\msys64)) { Invoke-WebRequest -Uri "https://github.com/msys2/msys2-installer/releases/download/2022-10-28/msys2-x86_64-20221028.exe" -OutFile "./msys2-x86_64.exe" ./msys2-x86_64.exe install --default-answer --confirm-command --root C:\msys64 } -C:\msys64\msys2_shell.cmd -defterm -here -no-start -mingw64 -c 'pacman -Sy --noconfirm base-devel vim rsync' +C:\msys64\msys2_shell.cmd -defterm -here -no-start -mingw64 -c 'pacman -Sy --noconfirm base-devel vim rsync man' C:\msys64\msys2_shell.cmd -defterm -here -no-start -mingw64 -c 'curl -fsSL https://d2lang.com/install.sh | sh -s -- --tala' C:\msys64\msys2_shell.cmd -defterm -here -no-start -mingw64 -c 'd2 --version' From 908ccaf50c5ad54ad5040c8a4f1db3a9c0f7f0ef Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 12:24:11 -0800 Subject: [PATCH 093/257] ci/sub: Update [ci-force] --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index 21542934c..2f443c093 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 21542934c5318ad3acab232bd15ef50e458663c6 +Subproject commit 2f443c093f402bcc971eddec8abea1f385fa13e0 From f7d63213c758010b47349d25fba5decb5b41d6c2 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 12:26:58 -0800 Subject: [PATCH 094/257] fmt --- docs/CONTRIBUTING.md | 21 ++++++++------------- main.go | 2 +- 2 files changed, 9 insertions(+), 14 deletions(-) diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md index f5b08f6b1..801917b2b 100644 --- a/docs/CONTRIBUTING.md +++ b/docs/CONTRIBUTING.md @@ -1,19 +1,14 @@ # Contributing - -- [CI](#ci) -- [Flow](#flow) -- [Logistics](#logistics) -- [Dev](#dev) - * [Content](#content) - * [Tests](#tests) - + [Running tests](#running-tests) - + [Chaos tests](#chaos-tests) - * [Documentation](#documentation) - * [Questions](#questions) - - +- CI +- Flow +- Logistics +- Dev + - Content + - Tests + - Documentation + - Questions ## CI diff --git a/main.go b/main.go index ce2af7899..53ef5d201 100644 --- a/main.go +++ b/main.go @@ -244,7 +244,7 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, pad, return svg, false, err } } else { - if len(out) > 0 && out[len(out)-1] != '\n' { + if len(out) > 0 && out[len(out)-1] != '\n' { out = append(out, '\n') } } From b2b1382d58f5bed419a0ac8bb1777af9d5f07d4c Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 12:28:14 -0800 Subject: [PATCH 095/257] ci/sub: Update [ci-force] --- ci/sub | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/sub b/ci/sub index 2f443c093..8c1b0bba1 160000 --- a/ci/sub +++ b/ci/sub @@ -1 +1 @@ -Subproject commit 2f443c093f402bcc971eddec8abea1f385fa13e0 +Subproject commit 8c1b0bba1d2539a11fc2b3f4fcf054d1d71f05a5 From d21a923f1f716585b5d6b73bf73b9652af36ec53 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 12:30:19 -0800 Subject: [PATCH 096/257] changelog: Fix wrapping --- ci/release/changelogs/next.md | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 58d3c237e..15c92e332 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -7,8 +7,7 @@ #### Improvements 🧹 -- `d2 fmt` now preserves leading comment spacing. - [#400](https://github.com/terrastruct/d2/issues/400) +- `d2 fmt` now preserves leading comment spacing. [#400](https://github.com/terrastruct/d2/issues/400) #### Bugfixes ⛑️ From 112c0a0d7d81fb73f702e8be1c4e5589014e6a9c Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 12:33:42 -0800 Subject: [PATCH 097/257] deps: update [ci-base] [ci-force] --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 74e905dbd..7a7910207 100644 --- a/go.mod +++ b/go.mod @@ -21,7 +21,7 @@ require ( golang.org/x/xerrors v0.0.0-20220907171357-04be3eba64a2 gonum.org/v1/plot v0.12.0 nhooyr.io/websocket v1.8.7 - oss.terrastruct.com/util-go v0.0.0-20221213112904-c09378905bfb + oss.terrastruct.com/util-go v0.0.0-20221218203331-558e3b4adc95 ) require ( diff --git a/go.sum b/go.sum index fb6710cf6..e77eb6d53 100644 --- a/go.sum +++ b/go.sum @@ -806,8 +806,8 @@ honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9 honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= nhooyr.io/websocket v1.8.7 h1:usjR2uOr/zjjkVMy0lW+PPohFok7PCow5sDjLgX4P4g= nhooyr.io/websocket v1.8.7/go.mod h1:B70DZP8IakI65RVQ51MsWP/8jndNma26DVA/nFSCgW0= -oss.terrastruct.com/util-go v0.0.0-20221213112904-c09378905bfb h1:ybqEeDAI/VyaVgPd5kis5aq+IPhHI3dQmdSxFG6SuuY= -oss.terrastruct.com/util-go v0.0.0-20221213112904-c09378905bfb/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= +oss.terrastruct.com/util-go v0.0.0-20221218203331-558e3b4adc95 h1:Ya/jgBNhNwZ30BsEcyjf2bTT8dtCdTM2WOSMEeSGB3E= +oss.terrastruct.com/util-go v0.0.0-20221218203331-558e3b4adc95/go.mod h1:Fwy72FDIOOM4K8F96ScXkxHHppR1CPfUyo9+x9c1PBU= rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1 h1:k1MczvYDUvJBe93bYd7wrZLLUEcLZAuF824/I4e5Xr4= rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= From 72dfbf708f328f6c236176daba78d536fde5a425 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 12:41:22 -0800 Subject: [PATCH 098/257] ci/release/build.sh: Automatically clone ci submodule --- ci/release/build.sh | 7 ++++++- make.sh | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ci/release/build.sh b/ci/release/build.sh index 82da752e3..82f930a51 100755 --- a/ci/release/build.sh +++ b/ci/release/build.sh @@ -1,7 +1,12 @@ #!/bin/sh set -eu +if [ ! -e "$(dirname "$0")/../../ci/sub/.git" ]; then + set -x + git submodule update --init + set +x +fi +. "$(dirname "$0")/../../ci/sub/lib.sh" cd -- "$(dirname "$0")/../.." -. ./ci/sub/lib.sh help() { cat < Date: Sun, 18 Dec 2022 12:42:50 -0800 Subject: [PATCH 099/257] docs/INSTALL.md: Document minimum Go version required --- docs/INSTALL.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/INSTALL.md b/docs/INSTALL.md index 8141d9fc3..410c95f77 100644 --- a/docs/INSTALL.md +++ b/docs/INSTALL.md @@ -158,6 +158,8 @@ You can always install from source: go install oss.terrastruct.com/d2@latest ``` +You need at least Go v1.18 + ### Source Release To install a release from source clone the repository and then: @@ -173,6 +175,8 @@ fonts and icons. Furthermore, when installing a non versioned commit, installing will ensure that `d2 --version` works correctly by embedding the commit hash into the `d2` binary. +Remember, you need at least Go v1.18 + ## Windows We have prebuilt releases of d2 available for Windows via `.msi` installers. The installer From be92906d9ad85ddb21227917164b4b1c384ab0a5 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 12:50:12 -0800 Subject: [PATCH 100/257] ci/release/aws: Reorder some statments [ci-force] --- ci/release/aws/ensure.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release/aws/ensure.sh b/ci/release/aws/ensure.sh index 4ff4e1ee6..4c4020da5 100755 --- a/ci/release/aws/ensure.sh +++ b/ci/release/aws/ensure.sh @@ -383,10 +383,10 @@ init_remote_env() { if sh_c ssh "$REMOTE_HOST" uname | grep -qF Darwin; then sh_c ssh "$REMOTE_HOST" "sudo launchctl stop com.openssh.sshd" else + sh_c ssh "$REMOTE_HOST" "sudo systemctl restart sshd" # ubuntu has $PATH hard coded in /etc/environment for some reason. It takes precedence # over ~/.ssh/environment. sh_c ssh "$REMOTE_HOST" "sudo rm /etc/environment" - sh_c ssh "$REMOTE_HOST" "sudo systemctl restart sshd" fi } From 8f69f49f8b133431dfc68a6366b45cca849a08e6 Mon Sep 17 00:00:00 2001 From: Anmol Sethi Date: Sun, 18 Dec 2022 19:44:35 -0800 Subject: [PATCH 101/257] ci/aws: Use ssh-keygen in better spot --- ci/release/aws/ensure.sh | 4 ++-- ci/sub | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/ci/release/aws/ensure.sh b/ci/release/aws/ensure.sh index 4c4020da5..5f68e45b3 100755 --- a/ci/release/aws/ensure.sh +++ b/ci/release/aws/ensure.sh @@ -267,6 +267,7 @@ wait_remote_host_ip() { ip=$(sh_c aws ec2 describe-instances \ --filters 'Name=instance-state-name,Values=pending,running,stopping,stopped' "Name=tag:Name,Values=$REMOTE_NAME" \ | jq -r '.Reservations[].Instances[].PublicIpAddress') + ssh-keygen -R "$ip" break fi sleep 5 @@ -391,7 +392,6 @@ init_remote_env() { } wait_remote_host() { - ssh-keygen -R "${REMOTE_HOST##*@}" while true; do if sh_c ssh "$REMOTE_HOST" true; then break @@ -538,7 +538,7 @@ EOF printf '%s\n' "$gen_init_ps1" >&2 warn '4. Run the following to be notified once installation is successful:' cat < Date: Sun, 18 Dec 2022 20:03:07 -0800 Subject: [PATCH 102/257] fix sequence edge identify --- d2layouts/d2sequence/layout.go | 2 +- d2layouts/d2sequence/sequence_diagram.go | 4 +- e2etests/regression_test.go | 12 + .../dagre/board.exp.json | 529 ++++++++++++++++++ .../dagre/sketch.exp.svg | 28 + .../elk/board.exp.json | 520 +++++++++++++++++ .../elk/sketch.exp.svg | 28 + 7 files changed, 1120 insertions(+), 3 deletions(-) create mode 100644 e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json create mode 100644 e2etests/testdata/regression/sequence_diagram_name_crash/elk/sketch.exp.svg diff --git a/d2layouts/d2sequence/layout.go b/d2layouts/d2sequence/layout.go index 42efeb174..55192ceab 100644 --- a/d2layouts/d2sequence/layout.go +++ b/d2layouts/d2sequence/layout.go @@ -88,7 +88,7 @@ func layoutSequenceDiagram(g *d2graph.Graph, obj *d2graph.Object) (*sequenceDiag var edges []*d2graph.Edge for _, edge := range g.Edges { // both Src and Dst must be inside the sequence diagram - if strings.HasPrefix(edge.Src.AbsID(), obj.AbsID()) && strings.HasPrefix(edge.Dst.AbsID(), obj.AbsID()) { + if obj == g.Root || (strings.HasPrefix(edge.Src.AbsID(), obj.AbsID()+".") && strings.HasPrefix(edge.Dst.AbsID(), obj.AbsID()+".")) { edges = append(edges, edge) } } diff --git a/d2layouts/d2sequence/sequence_diagram.go b/d2layouts/d2sequence/sequence_diagram.go index b05ea10a6..258428975 100644 --- a/d2layouts/d2sequence/sequence_diagram.go +++ b/d2layouts/d2sequence/sequence_diagram.go @@ -466,8 +466,8 @@ func (sd *sequenceDiagram) routeMessages() error { } else { return fmt.Errorf("could not find center of %s", message.Dst.AbsID()) } - isToDescendant := strings.HasPrefix(message.Dst.AbsID(), message.Src.AbsID()) - isFromDescendant := strings.HasPrefix(message.Src.AbsID(), message.Dst.AbsID()) + isToDescendant := strings.HasPrefix(message.Dst.AbsID(), message.Src.AbsID()+".") + isFromDescendant := strings.HasPrefix(message.Src.AbsID(), message.Dst.AbsID()+".") isSelfMessage := message.Src == message.Dst if isSelfMessage || isToDescendant || isFromDescendant { diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index 7c627be74..b9c2399f1 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -40,6 +40,18 @@ b.1 -> b.1`, a: A b: B`, }, + { + name: "sequence_diagram_name_crash", + script: `foo: { + shape: sequence_diagram + a -> b +} +foobar: { + shape: sequence_diagram + c -> d +} +foo -> foobar`, + }, } runa(t, tcs) diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json new file mode 100644 index 000000000..c07f75069 --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json @@ -0,0 +1,529 @@ +{ + "name": "", + "shapes": [ + { + "id": "foo", + "type": "sequence_diagram", + "pos": { + "x": 0, + "y": 0 + }, + "width": 448, + "height": 520, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "foo", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 43, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "foobar", + "type": "sequence_diagram", + "pos": { + "x": 0, + "y": 620 + }, + "width": 448, + "height": 520, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "foobar", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 84, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "foo.a", + "type": "", + "pos": { + "x": 24, + "y": 110 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "foo.b", + "type": "", + "pos": { + "x": 274, + "y": 110 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "foobar.c", + "type": "", + "pos": { + "x": 24, + "y": 730 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "c", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "foobar.d", + "type": "", + "pos": { + "x": 274, + "y": 730 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "d", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [ + { + "id": "foo.(a -> b)[0]", + "src": "foo.a", + "srcArrow": "none", + "srcLabel": "", + "dst": "foo.b", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 366 + }, + { + "x": 349, + "y": 366 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "foobar.(c -> d)[0]", + "src": "foobar.c", + "srcArrow": "none", + "srcLabel": "", + "dst": "foobar.d", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 986 + }, + { + "x": 349, + "y": 986 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(foo -> foobar)[0]", + "src": "foo", + "srcArrow": "none", + "srcLabel": "", + "dst": "foobar", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 224, + "y": 520 + }, + { + "x": 224, + "y": 560 + }, + { + "x": 224, + "y": 580 + }, + { + "x": 224, + "y": 620 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(foo.a -- )[0]", + "src": "foo.a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a-lifeline-end-2251863791", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 236 + }, + { + "x": 99, + "y": 496 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(foo.b -- )[0]", + "src": "foo.b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 349, + "y": 236 + }, + { + "x": 349, + "y": 496 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(foobar.c -- )[0]", + "src": "foobar.c", + "srcArrow": "none", + "srcLabel": "", + "dst": "c-lifeline-end-955173837", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 99, + "y": 856 + }, + { + "x": 99, + "y": 1116 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(foobar.d -- )[0]", + "src": "foobar.d", + "srcArrow": "none", + "srcLabel": "", + "dst": "d-lifeline-end-2106864010", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 349, + "y": 856 + }, + { + "x": 349, + "y": 1116 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg new file mode 100644 index 000000000..bdebbd687 --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg @@ -0,0 +1,28 @@ + +foofoobarabcd \ No newline at end of file diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json new file mode 100644 index 000000000..49186256a --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json @@ -0,0 +1,520 @@ +{ + "name": "", + "shapes": [ + { + "id": "foo", + "type": "sequence_diagram", + "pos": { + "x": 12, + "y": 12 + }, + "width": 448, + "height": 520, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "foo", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 43, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "foobar", + "type": "sequence_diagram", + "pos": { + "x": 12, + "y": 632 + }, + "width": 448, + "height": 520, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 0, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "foobar", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 84, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "foo.a", + "type": "", + "pos": { + "x": 36, + "y": 122 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "foo.b", + "type": "", + "pos": { + "x": 286, + "y": 122 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "foobar.c", + "type": "", + "pos": { + "x": 36, + "y": 742 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "c", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 12, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "foobar.d", + "type": "", + "pos": { + "x": 286, + "y": 742 + }, + "width": 150, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "d", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [ + { + "id": "foo.(a -> b)[0]", + "src": "foo.a", + "srcArrow": "none", + "srcLabel": "", + "dst": "foo.b", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 378 + }, + { + "x": 361, + "y": 378 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "foobar.(c -> d)[0]", + "src": "foobar.c", + "srcArrow": "none", + "srcLabel": "", + "dst": "foobar.d", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 998 + }, + { + "x": 361, + "y": 998 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 4 + }, + { + "id": "(foo -> foobar)[0]", + "src": "foo", + "srcArrow": "none", + "srcLabel": "", + "dst": "foobar", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 236, + "y": 532 + }, + { + "x": 236, + "y": 632 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(foo.a -- )[0]", + "src": "foo.a", + "srcArrow": "none", + "srcLabel": "", + "dst": "a-lifeline-end-2251863791", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 248 + }, + { + "x": 111, + "y": 508 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(foo.b -- )[0]", + "src": "foo.b", + "srcArrow": "none", + "srcLabel": "", + "dst": "b-lifeline-end-668380428", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 361, + "y": 248 + }, + { + "x": 361, + "y": 508 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(foobar.c -- )[0]", + "src": "foobar.c", + "srcArrow": "none", + "srcLabel": "", + "dst": "c-lifeline-end-955173837", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 111, + "y": 868 + }, + { + "x": 111, + "y": 1128 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + }, + { + "id": "(foobar.d -- )[0]", + "src": "foobar.d", + "srcArrow": "none", + "srcLabel": "", + "dst": "d-lifeline-end-2106864010", + "dstArrow": "none", + "dstLabel": "", + "opacity": 1, + "strokeDash": 6, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 361, + "y": 868 + }, + { + "x": 361, + "y": 1128 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 1 + } + ] +} diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/elk/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_name_crash/elk/sketch.exp.svg new file mode 100644 index 000000000..1675c4f07 --- /dev/null +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/elk/sketch.exp.svg @@ -0,0 +1,28 @@ + +foofoobarabcd \ No newline at end of file From e423c1a439b9e0cd4b8d96387b8a77cd92d56a54 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 18 Dec 2022 20:04:26 -0800 Subject: [PATCH 103/257] add changelog --- ci/release/changelogs/next.md | 1 + .../sequence_diagram_name_crash/dagre/sketch.exp.svg | 5 ++++- .../sequence_diagram_name_crash/elk/sketch.exp.svg | 5 ++++- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 15c92e332..44728f188 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -15,3 +15,4 @@ - Fixed `constraint` keyword setting label. [https://github.com/terrastruct/d2/issues/415](https://github.com/terrastruct/d2/issues/415) - Fixed serialization affecting binary plugins (TALA). [https://github.com/terrastruct/d2/pull/426](https://github.com/terrastruct/d2/pull/426) - Fixed a connection rendering bug that could happen in firefox when there were no connection labels. [https://github.com/terrastruct/d2/pull/453](https://github.com/terrastruct/d2/pull/453) +- Fixed a crash when external connection IDs were prefixes of a sequence diagram ID. [https://github.com/terrastruct/d2/pull/462](https://github.com/terrastruct/d2/pull/462) diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg index bdebbd687..7b7c06c7c 100644 --- a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/sketch.exp.svg @@ -18,7 +18,10 @@ width="648" height="1340" viewBox="-100 -100 648 1340">foofoobarabcd foofoobarabcd + + +foofoobarabcd foofoobarabcd + + +sql_table_overflowshort +loooooooooooooooooooong +loooooooooooooooooooong +short +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json b/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json new file mode 100644 index 000000000..d97bf998a --- /dev/null +++ b/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json @@ -0,0 +1,110 @@ +{ + "name": "", + "shapes": [ + { + "id": "table", + "type": "sql_table", + "pos": { + "x": 12, + "y": 12 + }, + "width": 387, + "height": 108, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": "short", + "type": "loooooooooooooooooooong", + "constraint": "", + "reference": "" + }, + { + "name": "loooooooooooooooooooong", + "type": "short", + "constraint": "", + "reference": "" + } + ], + "label": "sql_table_overflow", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 211, + "labelHeight": 36, + "zIndex": 0, + "level": 1 + }, + { + "id": "table_constrained", + "type": "sql_table", + "pos": { + "x": 419, + "y": 12 + }, + "width": 486, + "height": 108, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": "short", + "type": "loooooooooooooooooooong", + "constraint": "unique", + "reference": "" + }, + { + "name": "loooooooooooooooooooong", + "type": "short", + "constraint": "foreign_key", + "reference": "" + } + ], + "label": "sql_table_constrained_overflow", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 350, + "labelHeight": 36, + "zIndex": 0, + "level": 1 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/regression/sql_table_overflow/elk/sketch.exp.svg b/e2etests/testdata/regression/sql_table_overflow/elk/sketch.exp.svg new file mode 100644 index 000000000..1bb059b9e --- /dev/null +++ b/e2etests/testdata/regression/sql_table_overflow/elk/sketch.exp.svg @@ -0,0 +1,39 @@ + +sql_table_overflowshort +loooooooooooooooooooong +loooooooooooooooooooong +short +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK + + + \ No newline at end of file From 75a21435caaea6d6ede091012d7a2a3754c36456 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Sat, 17 Dec 2022 18:23:02 -0800 Subject: [PATCH 119/257] fix sql_table width measurement --- d2graph/d2graph.go | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 528df55c1..460e60ecd 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -995,23 +995,30 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler obj.Width = float64(maxWidth + 100) case d2target.ShapeSQLTable: - maxWidth := dims.Width + maxNameWidth := 0. + maxTypeWidth := 0. + constraintWidth := 0. + font := d2fonts.SourceSansPro.Font(d2fonts.FONT_SIZE_L, d2fonts.FONT_STYLE_REGULAR) for _, c := range obj.SQLTable.Columns { - cdims := getTextDimensions(mtexts, ruler, c.Text()) - if cdims == nil { - return fmt.Errorf("dimensions for column %#v not found", c.Text()) + nameWidth, _ := ruler.MeasurePrecise(font, c.Name) + if maxNameWidth < nameWidth { + maxNameWidth = nameWidth } - lineWidth := cdims.Width - if maxWidth < lineWidth { - maxWidth = lineWidth + typeWidth, _ := ruler.MeasurePrecise(font, c.Type) + if maxTypeWidth < typeWidth { + maxTypeWidth = typeWidth + } + if c.Constraint != "" { + // covers UNQ constraint with padding + constraintWidth = 70. } } // The rows get padded a little due to header font being larger than row font obj.Height = float64(dims.Height * (len(obj.SQLTable.Columns) + 1)) - // Leave room for padding - obj.Width = float64(maxWidth + 100) + // Leave room for padding (20 on each side) + obj.Width = float64(maxNameWidth + maxTypeWidth + constraintWidth + 40) case d2target.ShapeText, d2target.ShapeCode: } From 6429beb3bb94346f6951be67d27200ceb42370f7 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Sat, 17 Dec 2022 18:23:32 -0800 Subject: [PATCH 120/257] update tests --- .../sql_table_overflow/dagre/board.exp.json | 6 +++--- .../sql_table_overflow/dagre/sketch.exp.svg | 18 +++++++++--------- .../sql_table_overflow/elk/board.exp.json | 6 +++--- .../sql_table_overflow/elk/sketch.exp.svg | 18 +++++++++--------- 4 files changed, 24 insertions(+), 24 deletions(-) diff --git a/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json b/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json index c4c92edda..65fa36cf0 100644 --- a/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json +++ b/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json @@ -8,7 +8,7 @@ "x": 0, "y": 0 }, - "width": 387, + "width": 523, "height": 108, "opacity": 1, "strokeDash": 0, @@ -57,10 +57,10 @@ "id": "table_constrained", "type": "sql_table", "pos": { - "x": 447, + "x": 583, "y": 0 }, - "width": 486, + "width": 593, "height": 108, "opacity": 1, "strokeDash": 0, diff --git a/e2etests/testdata/regression/sql_table_overflow/dagre/sketch.exp.svg b/e2etests/testdata/regression/sql_table_overflow/dagre/sketch.exp.svg index 5e016ed19..d53b330bd 100644 --- a/e2etests/testdata/regression/sql_table_overflow/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/sql_table_overflow/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ sql_table_overflowshort loooooooooooooooooooong -loooooooooooooooooooong +loooooooooooooooooooong short -sql_table_constrained_overflowshort -loooooooooooooooooooong -UNQloooooooooooooooooooong -short -FK - +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK + sql_table_overflowshort +sql_table_overflowshort loooooooooooooooooooong -loooooooooooooooooooong +loooooooooooooooooooong short -sql_table_constrained_overflowshort -loooooooooooooooooooong -UNQloooooooooooooooooooong -short -FK - +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK + sql_table_overflowshort -loooooooooooooooooooong -loooooooooooooooooooong -short -sql_table_constrained_overflowshort -loooooooooooooooooooong -UNQloooooooooooooooooooong -short -FK - +sql_table_overflowshort +loooooooooooooooooooong +loooooooooooooooooooong +short +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK + sql_table_overflowshort -loooooooooooooooooooong -loooooooooooooooooooong -short -sql_table_constrained_overflowshort -loooooooooooooooooooong -UNQloooooooooooooooooooong -short -FK - +sql_table_overflowshort +loooooooooooooooooooong +loooooooooooooooooooong +short +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK + usersid -int -name -string -email -string -password -string -last_login -datetime -productsid -int -price -decimal -sku -string -name -string -ordersid -int -user_id -int -product_id -int -shipmentsid -int -order_id -int -tracking_number -string -status -string - - +usersid +int +name +string +email +string +password +string +last_login +datetime +productsid +int +price +decimal +sku +string +name +string +ordersid +int +user_id +int +product_id +int +shipmentsid +int +order_id +int +tracking_number +string +status +string + + usersid -int -name -string -email -string -password -string -last_login -datetime -productsid -int -price -decimal -sku -string -name -string -ordersid -int -user_id -int -product_id -int -shipmentsid -int -order_id -int -tracking_number -string -status -string - - +usersid +int +name +string +email +string +password +string +last_login +datetime +productsid +int +price +decimal +sku +string +name +string +ordersid +int +user_id +int +product_id +int +shipmentsid +int +order_id +int +tracking_number +string +status +string + + sql_table_overflowshort -loooooooooooooooooooong -loooooooooooooooooooong -short -sql_table_constrained_overflowshort -loooooooooooooooooooong -UNQloooooooooooooooooooong -short -FK - +sql_table_overflowshort +loooooooooooooooooooong +loooooooooooooooooooong +short +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK + sql_table_overflowshort -loooooooooooooooooooong -loooooooooooooooooooong -short -sql_table_constrained_overflowshort -loooooooooooooooooooong -UNQloooooooooooooooooooong -short -FK - +sql_table_overflowshort +loooooooooooooooooooong +loooooooooooooooooooong +short +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK + usersid -int -name -string -email -string -password -string -last_login -datetime -productsid -int -price -decimal -sku -string -name -string -ordersid -int -user_id -int -product_id -int -shipmentsid -int -order_id -int -tracking_number -string -status -string - - +usersid +int +name +string +email +string +password +string +last_login +datetime +productsid +int +price +decimal +sku +string +name +string +ordersid +int +user_id +int +product_id +int +shipmentsid +int +order_id +int +tracking_number +string +status +string + + usersid -int -name -string -email -string -password -string -last_login -datetime -productsid -int -price -decimal -sku -string -name -string -ordersid -int -user_id -int -product_id -int -shipmentsid -int -order_id -int -tracking_number -string -status -string - - +usersid +int +name +string +email +string +password +string +last_login +datetime +productsid +int +price +decimal +sku +string +name +string +ordersid +int +user_id +int +product_id +int +shipmentsid +int +order_id +int +tracking_number +string +status +string + + rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root + + + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json b/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json new file mode 100644 index 000000000..a2cdfa6e7 --- /dev/null +++ b/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json @@ -0,0 +1,912 @@ +{ + "name": "", + "shapes": [ + { + "id": "root", + "type": "image", + "pos": { + "x": 280, + "y": 12 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/essentials/004-picture.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "root", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 35, + "labelHeight": 26, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "container", + "type": "", + "pos": { + "x": 12, + "y": 245 + }, + "width": 1322, + "height": 966, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "container", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 117, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "container.root", + "type": "image", + "pos": { + "x": 280, + "y": 320 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/essentials/004-picture.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "root", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 35, + "labelHeight": 26, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "container.left", + "type": "", + "pos": { + "x": 87, + "y": 514 + }, + "width": 576, + "height": 622, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "left", + "fontSize": 24, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 38, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "container.left.root", + "type": "image", + "pos": { + "x": 258, + "y": 589 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/essentials/004-picture.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "root", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 35, + "labelHeight": 26, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "container.left.inner", + "type": "", + "pos": { + "x": 162, + "y": 783 + }, + "width": 426, + "height": 278, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "inner", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 49, + "labelHeight": 31, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "container.left.inner.left", + "type": "image", + "pos": { + "x": 237, + "y": 858 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/essentials/004-picture.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "left", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 29, + "labelHeight": 26, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 4 + }, + { + "id": "container.left.inner.right", + "type": "image", + "pos": { + "x": 385, + "y": 858 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/essentials/004-picture.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "right", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 39, + "labelHeight": 26, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 4 + }, + { + "id": "container.right", + "type": "", + "pos": { + "x": 683, + "y": 514 + }, + "width": 576, + "height": 622, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "right", + "fontSize": 24, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 52, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "container.right.root", + "type": "image", + "pos": { + "x": 854, + "y": 589 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/essentials/004-picture.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "root", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 35, + "labelHeight": 26, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "container.right.inner", + "type": "", + "pos": { + "x": 758, + "y": 783 + }, + "width": 426, + "height": 278, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "inner", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 49, + "labelHeight": 31, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "container.right.inner.left", + "type": "image", + "pos": { + "x": 833, + "y": 858 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/essentials/004-picture.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "left", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 29, + "labelHeight": 26, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 4 + }, + { + "id": "container.right.inner.right", + "type": "image", + "pos": { + "x": 981, + "y": 858 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/essentials/004-picture.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "right", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 39, + "labelHeight": 26, + "labelPosition": "OUTSIDE_TOP_CENTER", + "zIndex": 0, + "level": 4 + } + ], + "connections": [ + { + "id": "(root -> container.root)[0]", + "src": "root", + "srcArrow": "none", + "srcLabel": "", + "dst": "container.root", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 343.6666666666667, + "y": 140 + }, + { + "x": 343.6666666666667, + "y": 320 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "container.left.(root -> inner.left)[0]", + "src": "container.left.root", + "srcArrow": "none", + "srcLabel": "", + "dst": "container.left.inner.left", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "to inner left", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 76, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 301, + "y": 717 + }, + { + "x": 301, + "y": 858 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "container.left.(root -> inner.right)[0]", + "src": "container.left.root", + "srcArrow": "none", + "srcLabel": "", + "dst": "container.left.inner.right", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "to inner right", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 86, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 343.6666666666667, + "y": 717 + }, + { + "x": 343.6666666666667, + "y": 768 + }, + { + "x": 449, + "y": 768 + }, + { + "x": 449, + "y": 858 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "container.right.(root -> inner.left)[0]", + "src": "container.right.root", + "srcArrow": "none", + "srcLabel": "", + "dst": "container.right.inner.left", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "to inner left", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 76, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 897, + "y": 717 + }, + { + "x": 897, + "y": 858 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "container.right.(root -> inner.right)[0]", + "src": "container.right.root", + "srcArrow": "none", + "srcLabel": "", + "dst": "container.right.inner.right", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "to inner right", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 86, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 939.6666666666667, + "y": 717 + }, + { + "x": 939.6666666666667, + "y": 768 + }, + { + "x": 1045, + "y": 768 + }, + { + "x": 1045, + "y": 858 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "container.(root -> left.root)[0]", + "src": "container.root", + "srcArrow": "none", + "srcLabel": "", + "dst": "container.left.root", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "to left container root", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 136, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 322.33333333333337, + "y": 448 + }, + { + "x": 322.33333333333337, + "y": 589 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "container.(root -> right.root)[0]", + "src": "container.root", + "srcArrow": "none", + "srcLabel": "", + "dst": "container.right.root", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "to right container root", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 146, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 365, + "y": 448 + }, + { + "x": 365, + "y": 458 + }, + { + "x": 918.3333333333334, + "y": 458 + }, + { + "x": 918.3333333333334, + "y": 589 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/elk/sketch.exp.svg b/e2etests/testdata/stable/overlapping_image_container_labels/elk/sketch.exp.svg new file mode 100644 index 000000000..86ab6bb0f --- /dev/null +++ b/e2etests/testdata/stable/overlapping_image_container_labels/elk/sketch.exp.svg @@ -0,0 +1,50 @@ + +rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root + + + + + + + + \ No newline at end of file From 90846c659991897619f66287a82f18b70785b607 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 19 Dec 2022 19:47:31 -0800 Subject: [PATCH 129/257] update label positions for images --- d2layouts/d2dagrelayout/layout.go | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/d2layouts/d2dagrelayout/layout.go b/d2layouts/d2dagrelayout/layout.go index ec72a91c6..b516e228a 100644 --- a/d2layouts/d2dagrelayout/layout.go +++ b/d2layouts/d2dagrelayout/layout.go @@ -90,7 +90,14 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) { for _, obj := range g.Objects { id := obj.AbsID() idToObj[id] = obj - loadScript += generateAddNodeLine(id, int(obj.Width), int(obj.Height)) + + height := obj.Height + if obj.LabelWidth != nil && obj.LabelHeight != nil { + if obj.Attributes.Shape.Value == d2target.ShapeImage { + height += float64(*obj.LabelHeight) + label.PADDING + } + } + loadScript += generateAddNodeLine(id, int(obj.Width), int(height)) if obj.Parent != g.Root { loadScript += generateAddParentLine(id, obj.Parent.AbsID()) } @@ -151,7 +158,11 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) { if obj.LabelWidth != nil && obj.LabelHeight != nil { if len(obj.ChildrenArray) > 0 { obj.LabelPosition = go2.Pointer(string(label.InsideTopCenter)) - } else if obj.Attributes.Shape.Value == d2target.ShapeImage || obj.Attributes.Icon != nil { + } else if obj.Attributes.Shape.Value == d2target.ShapeImage { + obj.LabelPosition = go2.Pointer(string(label.OutsideBottomCenter)) + // remove the extra height we added to the node when passing to dagre + obj.Height -= float64(*obj.LabelHeight) + label.PADDING + } else if obj.Attributes.Icon != nil { obj.LabelPosition = go2.Pointer(string(label.OutsideTopCenter)) } else { obj.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter)) From f7d6f418eee977c908b4f7534a5ffb0fdc0c8051 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Mon, 19 Dec 2022 20:03:23 -0800 Subject: [PATCH 130/257] update tests --- .../stable/images/dagre/board.exp.json | 14 +- .../stable/images/dagre/sketch.exp.svg | 6 +- .../dagre/board.exp.json | 122 +++++++++--------- .../dagre/sketch.exp.svg | 18 +-- 4 files changed, 80 insertions(+), 80 deletions(-) diff --git a/e2etests/testdata/stable/images/dagre/board.exp.json b/e2etests/testdata/stable/images/dagre/board.exp.json index 65363a7d8..63be9ae31 100644 --- a/e2etests/testdata/stable/images/dagre/board.exp.json +++ b/e2etests/testdata/stable/images/dagre/board.exp.json @@ -48,7 +48,7 @@ "underline": false, "labelWidth": 13, "labelHeight": 26, - "labelPosition": "OUTSIDE_TOP_CENTER", + "labelPosition": "OUTSIDE_BOTTOM_CENTER", "zIndex": 0, "level": 1 }, @@ -57,7 +57,7 @@ "type": "image", "pos": { "x": 0, - "y": 228 + "y": 254 }, "width": 128, "height": 128, @@ -99,7 +99,7 @@ "underline": false, "labelWidth": 13, "labelHeight": 26, - "labelPosition": "OUTSIDE_TOP_CENTER", + "labelPosition": "OUTSIDE_BOTTOM_CENTER", "zIndex": 0, "level": 1 } @@ -132,19 +132,19 @@ "route": [ { "x": 64, - "y": 128 + "y": 154 }, { "x": 64, - "y": 168 + "y": 194 }, { "x": 64, - "y": 188 + "y": 214 }, { "x": 64, - "y": 228 + "y": 254 } ], "isCurve": true, diff --git a/e2etests/testdata/stable/images/dagre/sketch.exp.svg b/e2etests/testdata/stable/images/dagre/sketch.exp.svg index ecf004b8b..99d01640c 100644 --- a/e2etests/testdata/stable/images/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/images/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ ab + rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root - - - - - - - +rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root + + + + + + + ab - +ab + rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root - - - - - - - +rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root + + + + + + + hello - +hello + hello - +hello + aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 + - + - - - + + + aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 + - + - - - + + + lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest + + + + + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/elk_alignment/elk/board.exp.json b/e2etests/testdata/regression/elk_alignment/elk/board.exp.json new file mode 100644 index 000000000..f5e8e3e4a --- /dev/null +++ b/e2etests/testdata/regression/elk_alignment/elk/board.exp.json @@ -0,0 +1,879 @@ +{ + "name": "", + "shapes": [ + { + "id": "build_workflow", + "type": "", + "pos": { + "x": 852, + "y": 12 + }, + "width": 509, + "height": 1099, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "lambda-build.yaml", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 226, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "build_workflow.push", + "type": "", + "pos": { + "x": 956, + "y": 87 + }, + "width": 330, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Push to main branch", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 230, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "build_workflow.GHA", + "type": "", + "pos": { + "x": 987, + "y": 290 + }, + "width": 269, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "GitHub Actions", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 169, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "build_workflow.S3", + "type": "", + "pos": { + "x": 1056, + "y": 493 + }, + "width": 131, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "S3", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 31, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "build_workflow.Terraform", + "type": "", + "pos": { + "x": 1012, + "y": 696 + }, + "width": 218, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Terraform", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 118, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "build_workflow.AWS", + "type": "", + "pos": { + "x": 1044, + "y": 899 + }, + "width": 155, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "AWS", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 55, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "deploy_workflow", + "type": "", + "pos": { + "x": 1381, + "y": 175 + }, + "width": 440, + "height": 773, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "lambda-deploy.yaml", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 247, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "deploy_workflow.manual", + "type": "", + "pos": { + "x": 1476, + "y": 250 + }, + "width": 271, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Manual Trigger", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 171, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "deploy_workflow.GHA", + "type": "", + "pos": { + "x": 1477, + "y": 453 + }, + "width": 269, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "GitHub Actions", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 169, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "deploy_workflow.AWS", + "type": "", + "pos": { + "x": 1534, + "y": 736 + }, + "width": 155, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "AWS", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 55, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "apollo_workflow", + "type": "", + "pos": { + "x": 12, + "y": 215 + }, + "width": 819, + "height": 693, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "apollo-deploy.yaml", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 232, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "apollo_workflow.apollo", + "type": "", + "pos": { + "x": 503, + "y": 290 + }, + "width": 238, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Apollo Repo", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 138, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "apollo_workflow.GHA", + "type": "", + "pos": { + "x": 488, + "y": 493 + }, + "width": 269, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "GitHub Actions", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 169, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "apollo_workflow.AWS", + "type": "", + "pos": { + "x": 545, + "y": 696 + }, + "width": 155, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "AWS", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 55, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [ + { + "id": "build_workflow.(push -> GHA)[0]", + "src": "build_workflow.push", + "srcArrow": "none", + "srcLabel": "", + "dst": "build_workflow.GHA", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Triggers", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 67, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 1121, + "y": 224 + }, + { + "x": 1121, + "y": 290 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "build_workflow.(GHA -> S3)[0]", + "src": "build_workflow.GHA", + "srcArrow": "none", + "srcLabel": "", + "dst": "build_workflow.S3", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Builds zip and pushes it", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 192, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 1121, + "y": 427 + }, + { + "x": 1121, + "y": 493 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "build_workflow.(S3 <-> Terraform)[0]", + "src": "build_workflow.S3", + "srcArrow": "triangle", + "srcLabel": "", + "dst": "build_workflow.Terraform", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Pulls zip to deploy", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 149, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 1121, + "y": 630 + }, + { + "x": 1121, + "y": 696 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "build_workflow.(Terraform -> AWS)[0]", + "src": "build_workflow.Terraform", + "srcArrow": "none", + "srcLabel": "", + "dst": "build_workflow.AWS", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Changes live lambdas", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 179, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 1121, + "y": 833 + }, + { + "x": 1121, + "y": 899 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "deploy_workflow.(manual -> GHA)[0]", + "src": "deploy_workflow.manual", + "srcArrow": "none", + "srcLabel": "", + "dst": "deploy_workflow.GHA", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Launches", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 78, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 1611, + "y": 387 + }, + { + "x": 1611, + "y": 453 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "deploy_workflow.(GHA -> AWS)[0]", + "src": "deploy_workflow.GHA", + "srcArrow": "none", + "srcLabel": "", + "dst": "deploy_workflow.AWS", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Builds zip\npushes them to S3.\n\nDeploys lambdas\nusing Terraform", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 153, + "labelHeight": 106, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 1611, + "y": 590 + }, + { + "x": 1611, + "y": 736 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "apollo_workflow.(apollo -> GHA)[0]", + "src": "apollo_workflow.apollo", + "srcArrow": "none", + "srcLabel": "", + "dst": "apollo_workflow.GHA", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Triggered manually/push to master test test test test test test test", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 533, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 622, + "y": 427 + }, + { + "x": 622, + "y": 493 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "apollo_workflow.(GHA -> AWS)[0]", + "src": "apollo_workflow.GHA", + "srcArrow": "none", + "srcLabel": "", + "dst": "apollo_workflow.AWS", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "test", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 31, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 622, + "y": 630 + }, + { + "x": 622, + "y": 696 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg new file mode 100644 index 000000000..4b0877ba5 --- /dev/null +++ b/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg @@ -0,0 +1,52 @@ + +lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest + + + + + + + + + + \ No newline at end of file From 243df4b8e199442278b4118eff6156ee46ec5d23 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 20 Dec 2022 14:03:40 -0800 Subject: [PATCH 139/257] use elk layout's edge label position --- d2exporter/export.go | 3 +++ d2graph/d2graph.go | 1 + d2layouts/d2elklayout/layout.go | 3 ++- d2target/d2target.go | 8 ++++++-- 4 files changed, 12 insertions(+), 3 deletions(-) diff --git a/d2exporter/export.go b/d2exporter/export.go index 952a85662..6724283e8 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -242,6 +242,9 @@ func toConnection(edge *d2graph.Edge, theme *d2themes.Theme) d2target.Connection if edge.LabelPercentage != nil { connection.LabelPercentage = *edge.LabelPercentage } + if edge.LabelTL != nil { + connection.LabelTL = edge.LabelTL.Copy() + } connection.Route = edge.Route connection.IsCurve = edge.IsCurve diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index a6ec263f0..9ef90ed4c 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -664,6 +664,7 @@ type Edge struct { LabelDimensions d2target.TextDimensions `json:"label_dimensions"` LabelPosition *string `json:"labelPosition,omitempty"` LabelPercentage *float64 `json:"labelPercentage,omitempty"` + LabelTL *geo.Point `json:"labelTL,omitempty"` IsCurve bool `json:"isCurve"` Route []*geo.Point `json:"route,omitempty"` diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index fb364ceba..75ada9428 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -308,7 +308,8 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) { points[endIndex] = shape.TraceToShapeBorder(dstShape, points[endIndex], points[endIndex-1]) if edge.Attributes.Label.Value != "" { - edge.LabelPosition = go2.Pointer(string(label.InsideMiddleCenter)) + // using the edge label position from elk layout + edge.LabelTL = geo.NewPoint(e.Labels[0].X+parentX, e.Labels[0].Y+parentY) } edge.Route = points diff --git a/d2target/d2target.go b/d2target/d2target.go index ae098fd28..053a11687 100644 --- a/d2target/d2target.go +++ b/d2target/d2target.go @@ -210,8 +210,9 @@ type Connection struct { Fill string `json:"fill,omitempty"` Text - LabelPosition string `json:"labelPosition"` - LabelPercentage float64 `json:"labelPercentage"` + LabelPosition string `json:"labelPosition"` + LabelPercentage float64 `json:"labelPercentage"` + LabelTL *geo.Point `json:"labelTL,omitempty"` Route []*geo.Point `json:"route"` IsCurve bool `json:"isCurve,omitempty"` @@ -239,6 +240,9 @@ func BaseConnection() *Connection { } func (c *Connection) GetLabelTopLeft() *geo.Point { + if c.LabelTL != nil { + return c.LabelTL + } return label.Position(c.LabelPosition).GetPointOnRoute( c.Route, float64(c.StrokeWidth), From 9f9774b142ebdfad2abc1f11ca2a2ae7fa763f39 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 20 Dec 2022 14:07:30 -0800 Subject: [PATCH 140/257] update tests --- .../elk_alignment/elk/board.exp.json | 48 +++++++++++++++---- .../elk_alignment/elk/sketch.exp.svg | 11 +---- .../connection_label/elk/board.exp.json | 6 ++- .../connection_label/elk/sketch.exp.svg | 4 +- .../arrowhead_labels/elk/board.exp.json | 6 ++- .../arrowhead_labels/elk/sketch.exp.svg | 8 ++-- .../testdata/stable/chaos1/elk/board.exp.json | 12 ++++- .../testdata/stable/chaos1/elk/sketch.exp.svg | 5 +- .../testdata/stable/chaos2/elk/board.exp.json | 48 +++++++++++++++---- .../testdata/stable/chaos2/elk/sketch.exp.svg | 11 +---- .../stable/font_colors/elk/board.exp.json | 6 ++- .../stable/font_colors/elk/sketch.exp.svg | 4 +- .../stable/font_sizes/elk/board.exp.json | 18 +++++-- .../stable/font_sizes/elk/sketch.exp.svg | 6 +-- .../stable/investigate/elk/board.exp.json | 36 +++++++++++--- .../stable/investigate/elk/sketch.exp.svg | 13 ++--- .../testdata/stable/latex/elk/board.exp.json | 6 ++- .../testdata/stable/latex/elk/sketch.exp.svg | 4 +- .../elk/board.exp.json | 36 +++++++++++--- .../elk/sketch.exp.svg | 9 +--- .../self-referencing/elk/board.exp.json | 6 ++- .../self-referencing/elk/sketch.exp.svg | 8 ++-- .../stable/stylish/elk/board.exp.json | 6 ++- .../stable/stylish/elk/sketch.exp.svg | 4 +- .../container_child_edge/elk/board.exp.json | 12 ++++- .../container_child_edge/elk/sketch.exp.svg | 5 +- .../todo/font_sizes_large/elk/board.exp.json | 24 ++++++++-- .../todo/font_sizes_large/elk/sketch.exp.svg | 11 ++--- .../todo/tall_edge_label/elk/board.exp.json | 6 ++- .../todo/tall_edge_label/elk/sketch.exp.svg | 4 +- 30 files changed, 268 insertions(+), 115 deletions(-) diff --git a/e2etests/testdata/regression/elk_alignment/elk/board.exp.json b/e2etests/testdata/regression/elk_alignment/elk/board.exp.json index f5e8e3e4a..676dc94db 100644 --- a/e2etests/testdata/regression/elk_alignment/elk/board.exp.json +++ b/e2etests/testdata/regression/elk_alignment/elk/board.exp.json @@ -585,8 +585,12 @@ "underline": false, "labelWidth": 67, "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPosition": "", "labelPercentage": 0, + "labelTL": { + "x": 1052, + "y": 244 + }, "route": [ { "x": 1121, @@ -624,8 +628,12 @@ "underline": false, "labelWidth": 192, "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPosition": "", "labelPercentage": 0, + "labelTL": { + "x": 927, + "y": 447 + }, "route": [ { "x": 1121, @@ -663,8 +671,12 @@ "underline": false, "labelWidth": 149, "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPosition": "", "labelPercentage": 0, + "labelTL": { + "x": 970, + "y": 650 + }, "route": [ { "x": 1121, @@ -702,8 +714,12 @@ "underline": false, "labelWidth": 179, "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPosition": "", "labelPercentage": 0, + "labelTL": { + "x": 940, + "y": 853 + }, "route": [ { "x": 1121, @@ -741,8 +757,12 @@ "underline": false, "labelWidth": 78, "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPosition": "", "labelPercentage": 0, + "labelTL": { + "x": 1531, + "y": 407 + }, "route": [ { "x": 1611, @@ -780,8 +800,12 @@ "underline": false, "labelWidth": 153, "labelHeight": 106, - "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPosition": "", "labelPercentage": 0, + "labelTL": { + "x": 1456, + "y": 610 + }, "route": [ { "x": 1611, @@ -819,8 +843,12 @@ "underline": false, "labelWidth": 533, "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPosition": "", "labelPercentage": 0, + "labelTL": { + "x": 87, + "y": 447 + }, "route": [ { "x": 622, @@ -858,8 +886,12 @@ "underline": false, "labelWidth": 31, "labelHeight": 26, - "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPosition": "", "labelPercentage": 0, + "labelTL": { + "x": 589, + "y": 650 + }, "route": [ { "x": 622, diff --git a/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg index 4b0877ba5..10db0fd6b 100644 --- a/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg @@ -18,16 +18,9 @@ width="2009" height="1299" viewBox="-88 -88 2009 1299">lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest +lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest - - - - - - - - + ab hello +ab hello - + ab To err is human, to moo bovine1* - - +ab To err is human, to moo bovine1* + + aaadddeeebbbccc111 222 +aaadddeeebbbccc111 222 - - + aabbllmm

                          nn

                          oocciikkdd

                          gg

                          hhjj

                          ee

                          -
                          ff1122 334455667788 +
                          ff1122 334455667788 - - - - - - - - + alphabeta gamma +alphabeta gamma - + size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 - - - + aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - - - - - - - +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 + + mixed togethersugarsolution we get +mixed togethersugarsolution we get - + rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root +rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root - - - - - - + xyz hello - - +xyz hello + + containerfirstsecond 1->2c->2 +containerfirstsecond 1->2c->2 - - + eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one - - - - - +eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one + + ab Thereoncewasaverytalledgelabel +ab Thereoncewasaverytalledgelabel - + lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest - +lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest + ab hello +ab hello ab To err is human, to moo bovine1* - +ab To err is human, to moo bovine1* + aaadddeeebbbccc111 222 +aaadddeeebbbccc111 222 aabbllmm

                          nn

                          -
                          oocciikkdd

                          gg

                          -
                          hhjj

                          ee

                          -
                          ff1122 334455667788 - +aabbllmm

                          nn

                          +
                          oocciikkdd

                          gg

                          +
                          hhjj

                          ee

                          +
                          ff1122 334455667788 + alphabeta gamma +alphabeta gamma size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 + mixed togethersugarsolution we get +mixed togethersugarsolution we get rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root +rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root xyz hello - +xyz hello + containerfirstsecond 1->2c->2 - +containerfirstsecond 1->2c->2 + eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one - +eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one + ab Thereoncewasaverytalledgelabel +ab Thereoncewasaverytalledgelabel lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest - - +lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest + + + + + + + + + ab hello +ab hello - + ab To err is human, to moo bovine1* - - +ab To err is human, to moo bovine1* + + aaadddeeebbbccc111 222 +aaadddeeebbbccc111 222 - + + aabbllmm

                          nn

                          -
                          oocciikkdd

                          gg

                          -
                          hhjj

                          ee

                          -
                          ff1122 334455667788 - - +aabbllmm

                          nn

                          +
                          oocciikkdd

                          gg

                          +
                          hhjj

                          ee

                          +
                          ff1122 334455667788 + + + + + + + + + alphabeta gamma +alphabeta gamma - + size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 - + + + aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - - +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 + + + + + + + mixed togethersugarsolution we get +mixed togethersugarsolution we get - + rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root +rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root - + + + + + + xyz hello - - +xyz hello + + containerfirstsecond 1->2c->2 - - +containerfirstsecond 1->2c->2 + + + eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one - - +eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one + + + + + ab Thereoncewasaverytalledgelabel +ab Thereoncewasaverytalledgelabel - + lambda-build.yamlPush to main branchGitHub ActionsS3TerraformAWS TriggersBuilds zip & pushes it Pulls zip to deployChanges the live lambdas + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/dagre_edge_label_spacing/elk/board.exp.json b/e2etests/testdata/regression/dagre_edge_label_spacing/elk/board.exp.json new file mode 100644 index 000000000..6ea04a102 --- /dev/null +++ b/e2etests/testdata/regression/dagre_edge_label_spacing/elk/board.exp.json @@ -0,0 +1,403 @@ +{ + "name": "", + "shapes": [ + { + "id": "build_workflow", + "type": "", + "pos": { + "x": 12, + "y": 12 + }, + "width": 1893, + "height": 287, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "lambda-build.yaml", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 226, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "build_workflow.push", + "type": "", + "pos": { + "x": 87, + "y": 87 + }, + "width": 330, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Push to main branch", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 230, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "build_workflow.GHA", + "type": "", + "pos": { + "x": 511, + "y": 87 + }, + "width": 269, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "GitHub Actions", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 169, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "build_workflow.S3", + "type": "", + "pos": { + "x": 958, + "y": 87 + }, + "width": 131, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "S3", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 31, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "build_workflow.Terraform", + "type": "", + "pos": { + "x": 1248, + "y": 87 + }, + "width": 218, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Terraform", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 118, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "build_workflow.AWS", + "type": "", + "pos": { + "x": 1675, + "y": 87 + }, + "width": 155, + "height": 137, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "AWS", + "fontSize": 25, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 55, + "labelHeight": 37, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [ + { + "id": "build_workflow.(push -> GHA)[0]", + "src": "build_workflow.push", + "srcArrow": "none", + "srcLabel": "", + "dst": "build_workflow.GHA", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Triggers", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 54, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 417, + "y": 155.5 + }, + { + "x": 511, + "y": 155.5 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "build_workflow.(GHA -> S3)[0]", + "src": "build_workflow.GHA", + "srcArrow": "none", + "srcLabel": "", + "dst": "build_workflow.S3", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Builds zip & pushes it", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 138, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 780, + "y": 155.5 + }, + { + "x": 958, + "y": 155.5 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "build_workflow.(S3 <-> Terraform)[0]", + "src": "build_workflow.S3", + "srcArrow": "triangle", + "srcLabel": "", + "dst": "build_workflow.Terraform", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Pulls zip to deploy", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 119, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 1089, + "y": 155.5 + }, + { + "x": 1248, + "y": 155.5 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "build_workflow.(Terraform -> AWS)[0]", + "src": "build_workflow.Terraform", + "srcArrow": "none", + "srcLabel": "", + "dst": "build_workflow.AWS", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "Changes the live lambdas", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 169, + "labelHeight": 21, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 1466, + "y": 155.5 + }, + { + "x": 1675, + "y": 155.5 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/regression/dagre_edge_label_spacing/elk/sketch.exp.svg b/e2etests/testdata/regression/dagre_edge_label_spacing/elk/sketch.exp.svg new file mode 100644 index 000000000..33be96f29 --- /dev/null +++ b/e2etests/testdata/regression/dagre_edge_label_spacing/elk/sketch.exp.svg @@ -0,0 +1,48 @@ + +lambda-build.yamlPush to main branchGitHub ActionsS3TerraformAWS TriggersBuilds zip & pushes it Pulls zip to deployChanges the live lambdas + + + + + + \ No newline at end of file From 707f5b9dd76854ff598964343e2aa7347faf1c0b Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 20 Dec 2022 16:05:35 -0800 Subject: [PATCH 147/257] set dagre ranksep according to max edge label size --- d2layouts/d2dagrelayout/layout.go | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/d2layouts/d2dagrelayout/layout.go b/d2layouts/d2dagrelayout/layout.go index 3ae70e35a..68d8ec0f6 100644 --- a/d2layouts/d2dagrelayout/layout.go +++ b/d2layouts/d2dagrelayout/layout.go @@ -64,22 +64,35 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) { } rootAttrs := dagreGraphAttrs{ - ranksep: 100, edgesep: 40, nodesep: 60, } + isHorizontal := false switch g.Root.Attributes.Direction.Value { case "down": rootAttrs.rankdir = "TB" case "right": rootAttrs.rankdir = "LR" + isHorizontal = true case "left": rootAttrs.rankdir = "RL" + isHorizontal = true case "up": rootAttrs.rankdir = "BT" default: rootAttrs.rankdir = "TB" } + + maxLabelSize := 0 + for _, edge := range g.Edges { + size := edge.LabelDimensions.Width + if !isHorizontal { + size = edge.LabelDimensions.Height + } + maxLabelSize = go2.Max(maxLabelSize, size) + } + rootAttrs.ranksep = go2.Max(100, maxLabelSize+40) + configJS := setGraphAttrs(rootAttrs) if _, err := vm.RunString(configJS); err != nil { return err From 732bbf04bfd30cee309e19c3ca52c832fe561bb6 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Tue, 20 Dec 2022 16:07:23 -0800 Subject: [PATCH 148/257] update tests --- .../dagre/board.exp.json | 44 ++++----- .../dagre/sketch.exp.svg | 14 +-- .../elk_alignment/dagre/board.exp.json | 92 +++++++++---------- .../elk_alignment/dagre/sketch.exp.svg | 22 ++--- .../stable/font_sizes/dagre/board.exp.json | 24 ++--- .../stable/font_sizes/dagre/sketch.exp.svg | 10 +- .../font_sizes_large/dagre/board.exp.json | 38 ++++---- .../font_sizes_large/dagre/sketch.exp.svg | 14 +-- .../todo/tall_edge_label/dagre/board.exp.json | 8 +- .../todo/tall_edge_label/dagre/sketch.exp.svg | 8 +- 10 files changed, 137 insertions(+), 137 deletions(-) diff --git a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json index f13c457a2..50eca01cc 100644 --- a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json +++ b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/board.exp.json @@ -8,7 +8,7 @@ "x": 0, "y": 0 }, - "width": 1603, + "width": 2148, "height": 237, "opacity": 1, "strokeDash": 0, @@ -45,7 +45,7 @@ "id": "build_workflow.push", "type": "", "pos": { - "x": 50, + "x": 105, "y": 50 }, "width": 330, @@ -85,7 +85,7 @@ "id": "build_workflow.GHA", "type": "", "pos": { - "x": 480, + "x": 644, "y": 50 }, "width": 269, @@ -125,7 +125,7 @@ "id": "build_workflow.S3", "type": "", "pos": { - "x": 849, + "x": 1122, "y": 50 }, "width": 131, @@ -165,7 +165,7 @@ "id": "build_workflow.Terraform", "type": "", "pos": { - "x": 1080, + "x": 1462, "y": 50 }, "width": 218, @@ -205,7 +205,7 @@ "id": "build_workflow.AWS", "type": "", "pos": { - "x": 1398, + "x": 1889, "y": 50 }, "width": 155, @@ -269,19 +269,19 @@ "labelPercentage": 0, "route": [ { - "x": 380, + "x": 435.5, "y": 118.5 }, { - "x": 420, + "x": 518.3, "y": 118.5 }, { - "x": 440, + "x": 559.9, "y": 118.5 }, { - "x": 480, + "x": 643.5, "y": 118.5 } ], @@ -317,19 +317,19 @@ "labelPercentage": 0, "route": [ { - "x": 749, + "x": 913.5, "y": 118.5 }, { - "x": 789, + "x": 996.3, "y": 118.5 }, { - "x": 809, + "x": 1037.9, "y": 118.5 }, { - "x": 849, + "x": 1121.5, "y": 118.5 } ], @@ -365,19 +365,19 @@ "labelPercentage": 0, "route": [ { - "x": 980, + "x": 1253.5, "y": 118.5 }, { - "x": 1020, + "x": 1336.3, "y": 118.5 }, { - "x": 1040, + "x": 1377.9, "y": 118.5 }, { - "x": 1080, + "x": 1461.5, "y": 118.5 } ], @@ -413,19 +413,19 @@ "labelPercentage": 0, "route": [ { - "x": 1298, + "x": 1680.5, "y": 118.5 }, { - "x": 1338, + "x": 1763.3, "y": 118.5 }, { - "x": 1358, + "x": 1804.9, "y": 118.5 }, { - "x": 1398, + "x": 1888.5, "y": 118.5 } ], diff --git a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/sketch.exp.svg b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/sketch.exp.svg index 531799d20..fe87ffcc1 100644 --- a/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/dagre_edge_label_spacing/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ lambda-build.yamlPush to main branchGitHub ActionsS3TerraformAWS TriggersBuilds zip & pushes it Pulls zip to deployChanges the live lambdas + + + + + lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest - - - - - - - - - +lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest + + + + + + + + + size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 - - - +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 + + + eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one - - - - - +eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one + + + + + ab Thereoncewasaverytalledgelabel - - +ab Thereoncewasaverytalledgelabel + + lambda-build.yamlPush to main branchGitHub ActionsS3TerraformAWS TriggersBuilds zip & pushes it Pulls zip to deployChanges the live lambdas - +lambda-build.yamlPush to main branchGitHub ActionsS3TerraformAWS TriggersBuilds zip & pushes it Pulls zip to deployChanges the live lambdas + diff --git a/e2etests/testdata/regression/dagre_edge_label_spacing/elk/sketch.exp.svg b/e2etests/testdata/regression/dagre_edge_label_spacing/elk/sketch.exp.svg index 33be96f29..814c60100 100644 --- a/e2etests/testdata/regression/dagre_edge_label_spacing/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/dagre_edge_label_spacing/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="2093" height="487" viewBox="-88 -88 2093 487">lambda-build.yamlPush to main branchGitHub ActionsS3TerraformAWS TriggersBuilds zip & pushes it Pulls zip to deployChanges the live lambdas - +lambda-build.yamlPush to main branchGitHub ActionsS3TerraformAWS TriggersBuilds zip & pushes it Pulls zip to deployChanges the live lambdas + diff --git a/e2etests/testdata/regression/dagre_special_ids/dagre/sketch.exp.svg b/e2etests/testdata/regression/dagre_special_ids/dagre/sketch.exp.svg index f7a7922d5..d5d44ead7 100644 --- a/e2etests/testdata/regression/dagre_special_ids/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/dagre_special_ids/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="1427" height="568" viewBox="-100 -100 1427 568">ninetynineeighty eightseventy sevena\yodetherea\"odea\node - +ninetynineeighty eightseventy sevena\yodetherea\"odea\node + ninetynineeighty eightseventy sevena\yodetherea\"odea\node - +ninetynineeighty eightseventy sevena\yodetherea\"odea\node + lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest - +lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest + diff --git a/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg index 3d9ef5c63..487f8dc2a 100644 --- a/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/elk_alignment/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="1825" height="1299" viewBox="-88 -88 1825 1299">lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest - +lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest + diff --git a/e2etests/testdata/regression/empty_sequence/dagre/sketch.exp.svg b/e2etests/testdata/regression/empty_sequence/dagre/sketch.exp.svg index 47c42c577..192e116cb 100644 --- a/e2etests/testdata/regression/empty_sequence/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/empty_sequence/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="366" height="552" viewBox="-100 -100 366 552">hellogoodbye - +hellogoodbye + hellogoodbye - +hellogoodbye + foofoobarabcd - +foofoobarabcd + foofoobarabcd - +foofoobarabcd + AB - +AB + AB - +AB + b - +b + b - +b + abc - +abc + abc - +abc + ab - +ab + ab - +ab + acbd - +acbd + acbd - +acbd + ab hello - +ab hello + ab hello - +ab hello + - + + \ No newline at end of file diff --git a/e2etests/testdata/sanity/empty/elk/sketch.exp.svg b/e2etests/testdata/sanity/empty/elk/sketch.exp.svg index 20d55bdc1..243722dc6 100644 --- a/e2etests/testdata/sanity/empty/elk/sketch.exp.svg +++ b/e2etests/testdata/sanity/empty/elk/sketch.exp.svg @@ -18,7 +18,7 @@ width="200" height="200" viewBox="-100 -100 200 200"> - + + \ No newline at end of file diff --git a/e2etests/testdata/stable/all_shapes/dagre/sketch.exp.svg b/e2etests/testdata/stable/all_shapes/dagre/sketch.exp.svg index 095790f60..0ff95d243 100644 --- a/e2etests/testdata/stable/all_shapes/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/all_shapes/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="1539" height="824" viewBox="-100 -100 1539 824">rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud - +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud - +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud - +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud - +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + cba * - +cba * + cba * - +cba * + ab To err is human, to moo bovine1* - +ab To err is human, to moo bovine1* + ab To err is human, to moo bovine1* - +ab To err is human, to moo bovine1* + abcdefghijklmno - +abcdefghijklmno + abcdefghijklmno - +abcdefghijklmno + aaadddeeebbbccc111 222 - +aaadddeeebbbccc111 222 + aaadddeeebbbccc111 222 - +aaadddeeebbbccc111 222 + aabbllmm

                          nn

                          oocciikkdd

                          gg

                          hhjj

                          ee

                          -
                          ff1122 334455667788 - +
                          ff1122 334455667788 + diff --git a/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg b/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg index 9639ffaa6..69dc2c003 100644 --- a/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/chaos2/elk/sketch.exp.svg @@ -777,8 +777,8 @@ width="1080" height="1907" viewBox="-88 -88 1080 1907">aabbllmm

                          nn

                          oocciikkdd

                          gg

                          hhjj

                          ee

                          -
                          ff1122 334455667788 - +
                          ff1122 334455667788 + diff --git a/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg b/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg index 636412c12..ad3e8d1a2 100644 --- a/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/child_parent_edges/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="724" height="626" viewBox="-100 -100 724 626">abcd - +abcd + abcd - +abcd + abc - +abc + abc - +abc + acfbdhg - +acfbdhg + acfbdhg - +acfbdhg + agdfbhec - +agdfbhec + agdfbhec - +agdfbhec + abcdefghijklmnopq - +abcdefghijklmnopq + abcdefghijklmnopq - +abcdefghijklmnopq + finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot - +finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot + finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot - +finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot + bacde21345abcde - +bacde21345abcde + bacde21345abcde - +bacde21345abcde + alphabeta gamma - +alphabeta gamma + alphabeta gamma - +alphabeta gamma + size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 - +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 + diff --git a/e2etests/testdata/stable/font_sizes/elk/sketch.exp.svg b/e2etests/testdata/stable/font_sizes/elk/sketch.exp.svg index 9c69d48ce..3a0f127e0 100644 --- a/e2etests/testdata/stable/font_sizes/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/font_sizes/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="1965" height="793" viewBox="-88 -88 1965 793">size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 - +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 + diff --git a/e2etests/testdata/stable/giant_markdown_test/dagre/sketch.exp.svg b/e2etests/testdata/stable/giant_markdown_test/dagre/sketch.exp.svg index 14fc3e202..53f05277f 100644 --- a/e2etests/testdata/stable/giant_markdown_test/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/giant_markdown_test/dagre/sketch.exp.svg @@ -1031,8 +1031,8 @@ title for the link, surrounded in quotes. For example:

                          Code

                          Unlike a pre-formatted code block, a code span indicates code within a normal paragraph. For example:

                          -
                          ab - +
                      ab + hello - +hello + hello - +hello + ab - +ab + ab - +ab + aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 + diff --git a/e2etests/testdata/stable/investigate/elk/sketch.exp.svg b/e2etests/testdata/stable/investigate/elk/sketch.exp.svg index 237505427..65a4e7714 100644 --- a/e2etests/testdata/stable/investigate/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/investigate/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="859" height="4920" viewBox="-88 -88 859 4920">aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 + diff --git a/e2etests/testdata/stable/large_arch/dagre/sketch.exp.svg b/e2etests/testdata/stable/large_arch/dagre/sketch.exp.svg index e1ae164a1..482b251d0 100644 --- a/e2etests/testdata/stable/large_arch/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/large_arch/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="3244" height="1780" viewBox="-100 -100 3244 1780">abcdefghiqrjmnoszaabbeeffggklptuwxyccddv - +abcdefghiqrjmnoszaabbeeffggklptuwxyccddv + abcdefghiqrjmnoszaabbeeffggklptuwxyccddv - +abcdefghiqrjmnoszaabbeeffggklptuwxyccddv + mixed togethersugarsolution we get - +mixed togethersugarsolution we get + mixed togethersugarsolution we get - +mixed togethersugarsolution we get +

                      Markdown: Syntax

                      -
                      ab - +
                    ab +

                    Markdown: Syntax

                    -
                    ab - +
                ab + markdown

                Lorem ipsum dolor sit amet, consectetur adipiscing elit,
                sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

                -
                - +
              + markdown

              Lorem ipsum dolor sit amet, consectetur adipiscing elit,
              sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

              -
              - +
          + markdown

          Lorem ipsum dolor sit amet, consectetur adipiscing elit,
          sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

          -
          - +
        + markdown

        Lorem ipsum dolor sit amet, consectetur adipiscing elit,
        sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

        -
        - +
    +

    code

    -
    ab - +
ab +

code

-
ab - +ab + thisgoesmultiple lines - +thisgoesmultiple lines + thisgoesmultiple lines - +thisgoesmultiple lines + abcdefghijklmnopqrstuvw - +abcdefghijklmnopqrstuvw + abcdefghijklmnopqrstuvw - +abcdefghijklmnopqrstuvw + abcdefghijklmnopqrstu - +abcdefghijklmnopqrstu + abcdefghijklmnopqrstu - +abcdefghijklmnopqrstu + Foo Baz12hello - +Foo Baz12hello + Foo Baz12hello - +Foo Baz12hello + acdefgbh - +acdefgbh + acdefgbh - +acdefgbh + topabcbottomstartend - +topabcbottomstartend + topabcbottomstartend - +topabcbottomstartend + rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root - +rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root + diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/elk/sketch.exp.svg b/e2etests/testdata/stable/overlapping_image_container_labels/elk/sketch.exp.svg index 38f4d6c73..d4f292cdf 100644 --- a/e2etests/testdata/stable/overlapping_image_container_labels/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/overlapping_image_container_labels/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="1522" height="1503" viewBox="-88 -88 1522 1503">rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root - +rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root + diff --git a/e2etests/testdata/stable/p/dagre/sketch.exp.svg b/e2etests/testdata/stable/p/dagre/sketch.exp.svg index 7fb9d6e30..840c8a89b 100644 --- a/e2etests/testdata/stable/p/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/p/dagre/sketch.exp.svg @@ -778,8 +778,8 @@ width="2057" height="676" viewBox="-100 -100 2057 676">xyz hello - +xyz hello + xyz hello - +xyz hello + an actor with a really long label that will break everythinganactorwithareallylonglabelthatwillbreakeverythingsimplea short onefar awaywhat if there were no labels between this actor and the previous one shortlong label for testing purposes and it must be really, really longshortthis should span many actors lifelines so we know how it will look like when redering a long label over many actorslong label for testing purposes and it must be really, really long - +an actor with a really long label that will break everythinganactorwithareallylonglabelthatwillbreakeverythingsimplea short onefar awaywhat if there were no labels between this actor and the previous one shortlong label for testing purposes and it must be really, really longshortthis should span many actors lifelines so we know how it will look like when redering a long label over many actorslong label for testing purposes and it must be really, really long + diff --git a/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/sketch.exp.svg index b0be8b3b5..f0302fd8e 100644 --- a/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="2692" height="1396" viewBox="-76 -26 2692 1396">an actor with a really long label that will break everythinganactorwithareallylonglabelthatwillbreakeverythingsimplea short onefar awaywhat if there were no labels between this actor and the previous one shortlong label for testing purposes and it must be really, really longshortthis should span many actors lifelines so we know how it will look like when redering a long label over many actorslong label for testing purposes and it must be really, really long - +an actor with a really long label that will break everythinganactorwithareallylonglabelthatwillbreakeverythingsimplea short onefar awaywhat if there were no labels between this actor and the previous one shortlong label for testing purposes and it must be really, really longshortthis should span many actors lifelines so we know how it will look like when redering a long label over many actorslong label for testing purposes and it must be really, really long + diff --git a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/sketch.exp.svg index d5ef75817..c23490a3e 100644 --- a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/sketch.exp.svg @@ -28,8 +28,8 @@ width="5120" height="2984" viewBox="-76 -26 5120 2984">alicebob what does it mean to be well-adjustedThe ability to play bridge or golf as if they were games - +alicebob what does it mean to be well-adjustedThe ability to play bridge or golf as if they were games + alicebob what does it mean to be well-adjustedThe ability to play bridge or golf as if they were games - +alicebob what does it mean to be well-adjustedThe ability to play bridge or golf as if they were games + abcdggggroup 1group bchoonested guy lalaeyokayokaywhat would arnold saythis note - +abcdggggroup 1group bchoonested guy lalaeyokayokaywhat would arnold saythis note + diff --git a/e2etests/testdata/stable/sequence_diagram_groups/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_groups/elk/sketch.exp.svg index cac917156..0afcfd18a 100644 --- a/e2etests/testdata/stable/sequence_diagram_groups/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_groups/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="1147" height="2268" viewBox="-76 -26 1147 2268">abcdggggroup 1group bchoonested guy lalaeyokayokaywhat would arnold saythis note - +abcdggggroup 1group bchoonested guy lalaeyokayokaywhat would arnold saythis note + diff --git a/e2etests/testdata/stable/sequence_diagram_long_note/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_long_note/dagre/sketch.exp.svg index 97b4c4e3f..8cc670b3d 100644 --- a/e2etests/testdata/stable/sequence_diagram_long_note/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_long_note/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="850" height="1162" viewBox="-263 -26 850 1162">ba a note here to remember that padding must consider notes toojustalongnotehere - +ba a note here to remember that padding must consider notes toojustalongnotehere + ba a note here to remember that padding must consider notes toojustalongnotehere - +ba a note here to remember that padding must consider notes toojustalongnotehere + abjust an actorthis is a message groupaltand this is a nested message groupcase 1case 2case 3case 4what about more nestingcrazy townwhoa a notea note here to remember that padding must consider notes toojustalongnotehere - +abjust an actorthis is a message groupaltand this is a nested message groupcase 1case 2case 3case 4what about more nestingcrazy townwhoa a notea note here to remember that padding must consider notes toojustalongnotehere + diff --git a/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/sketch.exp.svg index 7ca2f5d0f..0dbb0afaa 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="1116" height="2458" viewBox="-197 -26 1116 2458">abjust an actorthis is a message groupaltand this is a nested message groupcase 1case 2case 3case 4what about more nestingcrazy townwhoa a notea note here to remember that padding must consider notes toojustalongnotehere - +abjust an actorthis is a message groupaltand this is a nested message groupcase 1case 2case 3case 4what about more nestingcrazy townwhoa a notea note here to remember that padding must consider notes toojustalongnotehere + diff --git a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/sketch.exp.svg index 8db0ad5d1..9fb361e64 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="1624" height="1626" viewBox="-76 -26 1624 1626">scoreritemResponseitemessayRubricconceptitemOutcome - +scoreritemResponseitemessayRubricconceptitemOutcome + scoreritemResponseitemessayRubricconceptitemOutcome - +scoreritemResponseitemessayRubricconceptitemOutcome + abcd okayexplanationanother explanationSome one who believes imaginary things appear right before your i's.The earth is like a tiny grain of sand, only much, much heavier - +abcd okayexplanationanother explanationSome one who believes imaginary things appear right before your i's.The earth is like a tiny grain of sand, only much, much heavier + abcd okayexplanationanother explanationSome one who believes imaginary things appear right before your i's.The earth is like a tiny grain of sand, only much, much heavier - +abcd okayexplanationanother explanationSome one who believes imaginary things appear right before your i's.The earth is like a tiny grain of sand, only much, much heavier + How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place - +How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place + diff --git a/e2etests/testdata/stable/sequence_diagram_real/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_real/elk/sketch.exp.svg index 0d904f1d9..364fb5549 100644 --- a/e2etests/testdata/stable/sequence_diagram_real/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_real/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="2447" height="2536" viewBox="-88 -88 2447 2536">How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place - +How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place + diff --git a/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/sketch.exp.svg index b0d237070..f947663cd 100644 --- a/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="696" height="1366" viewBox="-76 -26 696 1366">ab a self edge herebetween actorsto descendantto deeper descendantto parentactor - +ab a self edge herebetween actorsto descendantto deeper descendantto parentactor + diff --git a/e2etests/testdata/stable/sequence_diagram_self_edges/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_self_edges/elk/sketch.exp.svg index b0d237070..f947663cd 100644 --- a/e2etests/testdata/stable/sequence_diagram_self_edges/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_self_edges/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="696" height="1366" viewBox="-76 -26 696 1366">ab a self edge herebetween actorsto descendantto deeper descendantto parentactor - +ab a self edge herebetween actorsto descendantto deeper descendantto parentactor + diff --git a/e2etests/testdata/stable/sequence_diagram_simple/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_simple/dagre/sketch.exp.svg index 608019d3a..d0e6006a2 100644 --- a/e2etests/testdata/stable/sequence_diagram_simple/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_simple/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="1598" height="1868" viewBox="-76 -26 1598 1868">AlicelinebreakerBobdbqueueanoddservicewithanameinmultiple lines Authentication Requestmake request for something that is quite far away and requires a really long label to take all the space between the objectsvalidate credentialsAuthentication ResponseAnother authentication Requestdo it later storedAnother authentication Response - +AlicelinebreakerBobdbqueueanoddservicewithanameinmultiple lines Authentication Requestmake request for something that is quite far away and requires a really long label to take all the space between the objectsvalidate credentialsAuthentication ResponseAnother authentication Requestdo it later storedAnother authentication Response + diff --git a/e2etests/testdata/stable/sequence_diagram_simple/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_simple/elk/sketch.exp.svg index 608019d3a..d0e6006a2 100644 --- a/e2etests/testdata/stable/sequence_diagram_simple/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_simple/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="1598" height="1868" viewBox="-76 -26 1598 1868">AlicelinebreakerBobdbqueueanoddservicewithanameinmultiple lines Authentication Requestmake request for something that is quite far away and requires a really long label to take all the space between the objectsvalidate credentialsAuthentication ResponseAnother authentication Requestdo it later storedAnother authentication Response - +AlicelinebreakerBobdbqueueanoddservicewithanameinmultiple lines Authentication Requestmake request for something that is quite far away and requires a really long label to take all the space between the objectsvalidate credentialsAuthentication ResponseAnother authentication Requestdo it later storedAnother authentication Response + diff --git a/e2etests/testdata/stable/sequence_diagram_span/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_span/dagre/sketch.exp.svg index 470d35fc6..aa3321ec2 100644 --- a/e2etests/testdata/stable/sequence_diagram_span/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_span/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="1624" height="2146" viewBox="-76 -26 1624 2146">scoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) - +scoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) + diff --git a/e2etests/testdata/stable/sequence_diagram_span/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_span/elk/sketch.exp.svg index 470d35fc6..aa3321ec2 100644 --- a/e2etests/testdata/stable/sequence_diagram_span/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_span/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="1624" height="2146" viewBox="-76 -26 1624 2146">scoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) - +scoreritemResponseitemessayRubricconceptitemOutcome getItem() itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) + diff --git a/e2etests/testdata/stable/sequence_diagrams/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagrams/dagre/sketch.exp.svg index 1a8465908..db69a01ce 100644 --- a/e2etests/testdata/stable/sequence_diagrams/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagrams/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="3402" height="4269" viewBox="-100 -100 3402 4269">a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) - +a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) + diff --git a/e2etests/testdata/stable/sequence_diagrams/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagrams/elk/sketch.exp.svg index 938982dd1..8aaa9c058 100644 --- a/e2etests/testdata/stable/sequence_diagrams/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagrams/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="3324" height="4389" viewBox="-88 -88 3324 4389">a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) - +a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) + diff --git a/e2etests/testdata/stable/sql_tables/dagre/sketch.exp.svg b/e2etests/testdata/stable/sql_tables/dagre/sketch.exp.svg index da45fa870..d6087ea8a 100644 --- a/e2etests/testdata/stable/sql_tables/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sql_tables/dagre/sketch.exp.svg @@ -50,8 +50,8 @@ width="936" height="660" viewBox="-100 -100 936 660">acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc - +acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc + acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc - +acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc + -cube - +cube + -cube - +cube + AKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND - +AKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND + AKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND - +AKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND + containerfirstsecond 1->2c->2 - +containerfirstsecond 1->2c->2 + containerfirstsecond 1->2c->2 - +containerfirstsecond 1->2c->2 + ninety ninesixty fourthirty twosixteeneight - +ninety ninesixty fourthirty twosixteeneight + ninety ninesixty fourthirty twosixteeneight - +ninety ninesixty fourthirty twosixteeneight + eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one - +eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one + diff --git a/e2etests/testdata/todo/font_sizes_large/elk/sketch.exp.svg b/e2etests/testdata/todo/font_sizes_large/elk/sketch.exp.svg index 0b46e8a15..2e9ecf429 100644 --- a/e2etests/testdata/todo/font_sizes_large/elk/sketch.exp.svg +++ b/e2etests/testdata/todo/font_sizes_large/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="789" height="2014" viewBox="-88 -88 789 2014">eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one - +eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one + diff --git a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/sketch.exp.svg b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/sketch.exp.svg index a2ac750ea..288cab1f2 100644 --- a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/sketch.exp.svg +++ b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="921" height="1242" viewBox="-147 -26 921 1242">bacthis is a message groupand this is a nested message groupwhat about more nestingyoyo - +bacthis is a message groupand this is a nested message groupwhat about more nestingyoyo + diff --git a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/sketch.exp.svg b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/sketch.exp.svg index a2ac750ea..288cab1f2 100644 --- a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/sketch.exp.svg +++ b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/sketch.exp.svg @@ -18,8 +18,8 @@ width="921" height="1242" viewBox="-147 -26 921 1242">bacthis is a message groupand this is a nested message groupwhat about more nestingyoyo - +bacthis is a message groupand this is a nested message groupwhat about more nestingyoyo + diff --git a/e2etests/testdata/todo/tall_edge_label/dagre/sketch.exp.svg b/e2etests/testdata/todo/tall_edge_label/dagre/sketch.exp.svg index 619acbb99..e61e1a050 100644 --- a/e2etests/testdata/todo/tall_edge_label/dagre/sketch.exp.svg +++ b/e2etests/testdata/todo/tall_edge_label/dagre/sketch.exp.svg @@ -18,8 +18,8 @@ width="313" height="625" viewBox="-100 -100 313 625">ab Thereoncewasaverytalledgelabel - +ab Thereoncewasaverytalledgelabel + ab Thereoncewasaverytalledgelabel - +ab Thereoncewasaverytalledgelabel + + + + + +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + + + \ No newline at end of file diff --git a/d2renderers/d2sketch/testdata/basic/sketch.exp.svg b/d2renderers/d2sketch/testdata/basic/sketch.exp.svg new file mode 100644 index 000000000..e0eaa72c2 --- /dev/null +++ b/d2renderers/d2sketch/testdata/basic/sketch.exp.svg @@ -0,0 +1,43 @@ + + + + + + +ab + + + \ No newline at end of file diff --git a/d2renderers/d2sketch/testdata/chess/sketch.exp.svg b/d2renderers/d2sketch/testdata/chess/sketch.exp.svg new file mode 100644 index 000000000..cebddd9d9 --- /dev/null +++ b/d2renderers/d2sketch/testdata/chess/sketch.exp.svg @@ -0,0 +1,827 @@ + + + + + + +People discovery serviceAd mixerOnboarding serviceTwitter Frontend WebIphoneAndroidTimelineScorerHome RankerTimeline ServiceHome mixerManhattanGizmoduckSocial graphTweety PiePrediction ServiceHome ScorerManhattanMemcacheFetchFeatureScoringPrediction Service...etc

Timeline mixer

+
    +
  • Inject ads, who-to-follow, onboarding
  • +
  • Conversation module
  • +
  • Cursoring,pagination
  • +
  • Tweat deduplication
  • +
  • Served data logging
  • +
+
GraphQLFederated Strato Column

Tweet/user content hydration, visibility filtering

+
TLS-API (being deprecated)CrMixerEarlyBirdUtagSpaceCommunities iPhone webHTTP AndroidThrift RPC Candidate FetchFeature HydrationCandidate sources + + + + + + + +
\ No newline at end of file diff --git a/d2renderers/d2sketch/testdata/child_to_child/sketch.exp.svg b/d2renderers/d2sketch/testdata/child_to_child/sketch.exp.svg new file mode 100644 index 000000000..b326a4b8d --- /dev/null +++ b/d2renderers/d2sketch/testdata/child_to_child/sketch.exp.svg @@ -0,0 +1,50 @@ + + + + + + +wintersummersnowsun + + + \ No newline at end of file diff --git a/d2renderers/d2sketch/testdata/connection_label/board.exp.json b/d2renderers/d2sketch/testdata/connection_label/board.exp.json new file mode 100644 index 000000000..fc640e88a --- /dev/null +++ b/d2renderers/d2sketch/testdata/connection_label/board.exp.json @@ -0,0 +1,136 @@ +{ + "name": "", + "fontFamily": "HandDrawn", + "shapes": [ + { + "id": "a", + "type": "", + "pos": { + "x": 1, + "y": 0 + }, + "width": 114, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 14, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "b", + "type": "", + "pos": { + "x": 0, + "y": 226 + }, + "width": 115, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "b", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 15, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(a -> b)[0]", + "src": "a", + "srcArrow": "none", + "srcLabel": "", + "dst": "b", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "hello", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 31, + "labelHeight": 23, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "labelPercentage": 0, + "route": [ + { + "x": 57.5, + "y": 126 + }, + { + "x": 57.5, + "y": 166 + }, + { + "x": 57.5, + "y": 186 + }, + { + "x": 57.5, + "y": 226 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/d2renderers/d2sketch/testdata/connection_label/sketch.exp.svg b/d2renderers/d2sketch/testdata/connection_label/sketch.exp.svg new file mode 100644 index 000000000..68e523e47 --- /dev/null +++ b/d2renderers/d2sketch/testdata/connection_label/sketch.exp.svg @@ -0,0 +1,50 @@ + + + + + + +ab hello + + + \ No newline at end of file diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 41a0c63a6..c90e66a7a 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -25,11 +25,13 @@ import ( "oss.terrastruct.com/d2/d2graph" "oss.terrastruct.com/d2/d2renderers/d2fonts" "oss.terrastruct.com/d2/d2renderers/d2latex" + "oss.terrastruct.com/d2/d2renderers/d2sketch" "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/lib/color" "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/label" "oss.terrastruct.com/d2/lib/shape" + "oss.terrastruct.com/d2/lib/svg" "oss.terrastruct.com/d2/lib/textmeasure" ) @@ -44,9 +46,17 @@ var multipleOffset = geo.NewVector(10, -10) //go:embed style.css var styleCSS string +//go:embed sketchstyle.css +var sketchStyleCSS string + //go:embed github-markdown.css var mdCSS string +type RenderOpts struct { + Pad int + Sketch bool +} + func setViewbox(writer io.Writer, diagram *d2target.Diagram, pad int) (width int, height int) { tl, br := diagram.BoundingBox() w := br.X - tl.X + pad*2 @@ -346,7 +356,7 @@ func makeLabelMask(labelTL *geo.Point, width, height int) string { ) } -func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Connection, markers map[string]struct{}, idToShape map[string]d2target.Shape) (labelMask string) { +func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Connection, markers map[string]struct{}, idToShape map[string]d2target.Shape, sketchRunner *d2sketch.Runner) (labelMask string, _ error) { fmt.Fprintf(writer, ``, escapeText(connection.ID)) var markerStart string if connection.SrcArrow != d2target.NoArrowhead { @@ -413,13 +423,22 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co } } - fmt.Fprintf(writer, ``, - pathData(connection, idToShape), - connectionStyle(connection), + path := pathData(connection, idToShape) + attrs := fmt.Sprintf(`%s%smask="url(#%s)"`, markerStart, markerEnd, labelMaskID, ) + if sketchRunner != nil { + out, err := d2sketch.Connection(sketchRunner, connection, path, attrs) + if err != nil { + return "", err + } + fmt.Fprintf(writer, out) + } else { + fmt.Fprintf(writer, ``, + path, connectionStyle(connection), attrs) + } if connection.Label != "" { fontClass := "text" @@ -589,7 +608,7 @@ func render3dRect(targetShape d2target.Shape) string { return borderMask + mainRect + renderedSides + renderedBorder } -func drawShape(writer io.Writer, targetShape d2target.Shape) (labelMask string, err error) { +func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2sketch.Runner) (labelMask string, err error) { fmt.Fprintf(writer, ``, escapeText(targetShape.ID)) tl := geo.NewPoint(float64(targetShape.Pos.X), float64(targetShape.Pos.Y)) width := float64(targetShape.Width) @@ -636,7 +655,15 @@ func drawShape(writer io.Writer, targetShape d2target.Shape) (labelMask string, if targetShape.Multiple { fmt.Fprint(writer, renderOval(multipleTL, width, height, style)) } - fmt.Fprint(writer, renderOval(tl, width, height, style)) + if sketchRunner != nil { + out, err := d2sketch.Oval(sketchRunner, targetShape) + if err != nil { + return "", err + } + fmt.Fprintf(writer, out) + } else { + fmt.Fprint(writer, renderOval(tl, width, height, style)) + } case d2target.ShapeImage: fmt.Fprintf(writer, ``, @@ -652,8 +679,16 @@ func drawShape(writer io.Writer, targetShape d2target.Shape) (labelMask string, fmt.Fprintf(writer, ``, targetShape.Pos.X+10, targetShape.Pos.Y-10, targetShape.Width, targetShape.Height, style) } - fmt.Fprintf(writer, ``, - targetShape.Pos.X, targetShape.Pos.Y, targetShape.Width, targetShape.Height, style) + if sketchRunner != nil { + out, err := d2sketch.Rect(sketchRunner, targetShape) + if err != nil { + return "", err + } + fmt.Fprintf(writer, out) + } else { + fmt.Fprintf(writer, ``, + targetShape.Pos.X, targetShape.Pos.Y, targetShape.Width, targetShape.Height, style) + } } case d2target.ShapeText, d2target.ShapeCode: default: @@ -664,8 +699,16 @@ func drawShape(writer io.Writer, targetShape d2target.Shape) (labelMask string, } } - for _, pathData := range s.GetSVGPathData() { - fmt.Fprintf(writer, ``, pathData, style) + if sketchRunner != nil { + out, err := d2sketch.Paths(sketchRunner, targetShape, s.GetSVGPathData()) + if err != nil { + return "", err + } + fmt.Fprintf(writer, out) + } else { + for _, pathData := range s.GetSVGPathData() { + fmt.Fprintf(writer, ``, pathData, style) + } } } @@ -841,7 +884,7 @@ func shapeStyle(shape d2target.Shape) string { out += fmt.Sprintf(`opacity:%f;`, shape.Opacity) out += fmt.Sprintf(`stroke-width:%d;`, shape.StrokeWidth) if shape.StrokeDash != 0 { - dashSize, gapSize := getStrokeDashAttributes(float64(shape.StrokeWidth), shape.StrokeDash) + dashSize, gapSize := svg.GetStrokeDashAttributes(float64(shape.StrokeWidth), shape.StrokeDash) out += fmt.Sprintf(`stroke-dasharray:%f,%f;`, dashSize, gapSize) } @@ -855,22 +898,14 @@ func connectionStyle(connection d2target.Connection) string { out += fmt.Sprintf(`opacity:%f;`, connection.Opacity) out += fmt.Sprintf(`stroke-width:%d;`, connection.StrokeWidth) if connection.StrokeDash != 0 { - dashSize, gapSize := getStrokeDashAttributes(float64(connection.StrokeWidth), connection.StrokeDash) + dashSize, gapSize := svg.GetStrokeDashAttributes(float64(connection.StrokeWidth), connection.StrokeDash) out += fmt.Sprintf(`stroke-dasharray:%f,%f;`, dashSize, gapSize) } return out } -func getStrokeDashAttributes(strokeWidth, dashGapSize float64) (float64, float64) { - // as the stroke width gets thicker, the dash gap gets smaller - scale := math.Log10(-0.6*strokeWidth+10.6)*0.5 + 0.5 - scaledDashSize := strokeWidth * dashGapSize - scaledGapSize := scale * scaledDashSize - return scaledDashSize, scaledGapSize -} - -func embedFonts(buf *bytes.Buffer) { +func embedFonts(buf *bytes.Buffer, fontFamily *d2fonts.FontFamily) { content := buf.String() buf.WriteString(``, styleCSS)) +`, styleCSS, styleCSS2)) hasMarkdown := false for _, s := range diagram.Shapes { @@ -983,6 +1035,9 @@ func Render(diagram *d2target.Diagram, pad int) ([]byte, error) { if hasMarkdown { fmt.Fprintf(buf, ``, mdCSS) } + if sketchRunner != nil { + fmt.Fprintf(buf, d2sketch.DefineFillPattern()) + } // only define shadow filter if a shape uses it for _, s := range diagram.Shapes { @@ -1017,12 +1072,15 @@ func Render(diagram *d2target.Diagram, pad int) ([]byte, error) { markers := map[string]struct{}{} for _, obj := range allObjects { if c, is := obj.(d2target.Connection); is { - labelMask := drawConnection(buf, labelMaskID, c, markers, idToShape) + labelMask, err := drawConnection(buf, labelMaskID, c, markers, idToShape, sketchRunner) + if err != nil { + return nil, err + } if labelMask != "" { labelMasks = append(labelMasks, labelMask) } } else if s, is := obj.(d2target.Shape); is { - labelMask, err := drawShape(buf, s) + labelMask, err := drawShape(buf, s, sketchRunner) if err != nil { return nil, err } else if labelMask != "" { @@ -1046,7 +1104,7 @@ func Render(diagram *d2target.Diagram, pad int) ([]byte, error) { `
`, }, "\n")) - embedFonts(buf) + embedFonts(buf, diagram.FontFamily) buf.WriteString(``) return buf.Bytes(), nil diff --git a/d2renderers/d2svg/sketchstyle.css b/d2renderers/d2svg/sketchstyle.css new file mode 100644 index 000000000..33654aba2 --- /dev/null +++ b/d2renderers/d2svg/sketchstyle.css @@ -0,0 +1,4 @@ +.sketch-overlay { + fill: url(#streaks); + mix-blend-mode: overlay; +} diff --git a/d2target/d2target.go b/d2target/d2target.go index ae098fd28..96700c176 100644 --- a/d2target/d2target.go +++ b/d2target/d2target.go @@ -10,6 +10,7 @@ import ( "oss.terrastruct.com/util-go/go2" + "oss.terrastruct.com/d2/d2renderers/d2fonts" "oss.terrastruct.com/d2/d2themes" "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/label" @@ -22,8 +23,9 @@ const ( ) type Diagram struct { - Name string `json:"name"` - Description string `json:"description,omitempty"` + Name string `json:"name"` + Description string `json:"description,omitempty"` + FontFamily *d2fonts.FontFamily `json:"fontFamily,omitempty"` Shapes []Shape `json:"shapes"` Connections []Connection `json:"connections"` diff --git a/docs/examples/lib/1-d2lib/d2lib.go b/docs/examples/lib/1-d2lib/d2lib.go index 8e157d62a..3b0114c88 100644 --- a/docs/examples/lib/1-d2lib/d2lib.go +++ b/docs/examples/lib/1-d2lib/d2lib.go @@ -20,6 +20,8 @@ func main() { Ruler: ruler, ThemeID: d2themescatalog.GrapeSoda.ID, }) - out, _ := d2svg.Render(diagram, d2svg.DEFAULT_PADDING) + out, _ := d2svg.Render(diagram, &d2svg.RenderOpts{ + Pad: d2svg.DEFAULT_PADDING, + }) _ = ioutil.WriteFile(filepath.Join("out.svg"), out, 0600) } diff --git a/docs/examples/lib/3-lowlevel/lowlevel.go b/docs/examples/lib/3-lowlevel/lowlevel.go index 066558e42..1ad6443b0 100644 --- a/docs/examples/lib/3-lowlevel/lowlevel.go +++ b/docs/examples/lib/3-lowlevel/lowlevel.go @@ -18,9 +18,11 @@ import ( func main() { graph, _ := d2compiler.Compile("", strings.NewReader("x -> y"), nil) ruler, _ := textmeasure.NewRuler() - _ = graph.SetDimensions(nil, ruler) + _ = graph.SetDimensions(nil, ruler, nil) _ = d2dagrelayout.Layout(context.Background(), graph) - diagram, _ := d2exporter.Export(context.Background(), graph, d2themescatalog.NeutralDefault.ID) - out, _ := d2svg.Render(diagram, d2svg.DEFAULT_PADDING) + diagram, _ := d2exporter.Export(context.Background(), graph, d2themescatalog.NeutralDefault.ID, nil) + out, _ := d2svg.Render(diagram, &d2svg.RenderOpts{ + Pad: d2svg.DEFAULT_PADDING, + }) _ = ioutil.WriteFile(filepath.Join("out.svg"), out, 0600) } diff --git a/e2etests/e2e_test.go b/e2etests/e2e_test.go index f7f70f7ec..df76d986a 100644 --- a/e2etests/e2e_test.go +++ b/e2etests/e2e_test.go @@ -125,7 +125,9 @@ func run(t *testing.T, tc testCase) { dataPath := filepath.Join("testdata", strings.TrimPrefix(t.Name(), "TestE2E/"), layoutName) pathGotSVG := filepath.Join(dataPath, "sketch.got.svg") - svgBytes, err := d2svg.Render(diagram, d2svg.DEFAULT_PADDING) + svgBytes, err := d2svg.Render(diagram, &d2svg.RenderOpts{ + Pad: d2svg.DEFAULT_PADDING, + }) assert.Success(t, err) err = os.MkdirAll(dataPath, 0755) assert.Success(t, err) diff --git a/e2etests/testdata/regression/dagre_special_ids/dagre/board.exp.json b/e2etests/testdata/regression/dagre_special_ids/dagre/board.exp.json index 3684ac8af..b0d5e092e 100644 --- a/e2etests/testdata/regression/dagre_special_ids/dagre/board.exp.json +++ b/e2etests/testdata/regression/dagre_special_ids/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "\"ninety\\nnine\"", diff --git a/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json b/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json index dfd3230ad..bd21d8cc7 100644 --- a/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json +++ b/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "\"ninety\\nnine\"", diff --git a/e2etests/testdata/regression/empty_sequence/dagre/board.exp.json b/e2etests/testdata/regression/empty_sequence/dagre/board.exp.json index a2abea372..63644901e 100644 --- a/e2etests/testdata/regression/empty_sequence/dagre/board.exp.json +++ b/e2etests/testdata/regression/empty_sequence/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "A", diff --git a/e2etests/testdata/regression/empty_sequence/elk/board.exp.json b/e2etests/testdata/regression/empty_sequence/elk/board.exp.json index e5224a34d..3fd0b10ce 100644 --- a/e2etests/testdata/regression/empty_sequence/elk/board.exp.json +++ b/e2etests/testdata/regression/empty_sequence/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "A", diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json index c07f75069..d70cfb8a1 100644 --- a/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "foo", diff --git a/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json index 49186256a..019cb8809 100644 --- a/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_name_crash/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "foo", diff --git a/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json index 5f1267bc6..379bdcc9d 100644 --- a/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_no_message/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json index 5f1267bc6..379bdcc9d 100644 --- a/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_no_message/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json b/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json index 8966eb315..20808f117 100644 --- a/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_span_cover/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "b", diff --git a/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json b/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json index 8966eb315..20808f117 100644 --- a/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json +++ b/e2etests/testdata/regression/sequence_diagram_span_cover/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "b", diff --git a/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json b/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json index 1607ab8c2..dddfded93 100644 --- a/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json +++ b/e2etests/testdata/regression/sql_table_overflow/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "table", diff --git a/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json b/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json index e7e2b6741..9001adab0 100644 --- a/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json +++ b/e2etests/testdata/regression/sql_table_overflow/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "table", diff --git a/e2etests/testdata/sanity/1_to_2/dagre/board.exp.json b/e2etests/testdata/sanity/1_to_2/dagre/board.exp.json index 53c443478..57e3d9c03 100644 --- a/e2etests/testdata/sanity/1_to_2/dagre/board.exp.json +++ b/e2etests/testdata/sanity/1_to_2/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/sanity/1_to_2/elk/board.exp.json b/e2etests/testdata/sanity/1_to_2/elk/board.exp.json index c9ff1f18c..75ea599ab 100644 --- a/e2etests/testdata/sanity/1_to_2/elk/board.exp.json +++ b/e2etests/testdata/sanity/1_to_2/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/sanity/basic/dagre/board.exp.json b/e2etests/testdata/sanity/basic/dagre/board.exp.json index 44c5b6df0..bac537f6d 100644 --- a/e2etests/testdata/sanity/basic/dagre/board.exp.json +++ b/e2etests/testdata/sanity/basic/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/sanity/basic/elk/board.exp.json b/e2etests/testdata/sanity/basic/elk/board.exp.json index e1693297b..d57ec4ce1 100644 --- a/e2etests/testdata/sanity/basic/elk/board.exp.json +++ b/e2etests/testdata/sanity/basic/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/sanity/child_to_child/dagre/board.exp.json b/e2etests/testdata/sanity/child_to_child/dagre/board.exp.json index b92e7c63f..be228611f 100644 --- a/e2etests/testdata/sanity/child_to_child/dagre/board.exp.json +++ b/e2etests/testdata/sanity/child_to_child/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/sanity/child_to_child/elk/board.exp.json b/e2etests/testdata/sanity/child_to_child/elk/board.exp.json index 5ddfc3ea6..d6bda1299 100644 --- a/e2etests/testdata/sanity/child_to_child/elk/board.exp.json +++ b/e2etests/testdata/sanity/child_to_child/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/sanity/connection_label/dagre/board.exp.json b/e2etests/testdata/sanity/connection_label/dagre/board.exp.json index c5c97f5f7..d2e114820 100644 --- a/e2etests/testdata/sanity/connection_label/dagre/board.exp.json +++ b/e2etests/testdata/sanity/connection_label/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/sanity/connection_label/elk/board.exp.json b/e2etests/testdata/sanity/connection_label/elk/board.exp.json index be654cbef..350ede3da 100644 --- a/e2etests/testdata/sanity/connection_label/elk/board.exp.json +++ b/e2etests/testdata/sanity/connection_label/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/sanity/empty/dagre/board.exp.json b/e2etests/testdata/sanity/empty/dagre/board.exp.json index 8591adc9e..57a381554 100644 --- a/e2etests/testdata/sanity/empty/dagre/board.exp.json +++ b/e2etests/testdata/sanity/empty/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [], "connections": [] } diff --git a/e2etests/testdata/sanity/empty/elk/board.exp.json b/e2etests/testdata/sanity/empty/elk/board.exp.json index 8591adc9e..57a381554 100644 --- a/e2etests/testdata/sanity/empty/elk/board.exp.json +++ b/e2etests/testdata/sanity/empty/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [], "connections": [] } diff --git a/e2etests/testdata/stable/all_shapes/dagre/board.exp.json b/e2etests/testdata/stable/all_shapes/dagre/board.exp.json index 250620797..97f3baf20 100644 --- a/e2etests/testdata/stable/all_shapes/dagre/board.exp.json +++ b/e2etests/testdata/stable/all_shapes/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "rectangle", diff --git a/e2etests/testdata/stable/all_shapes/elk/board.exp.json b/e2etests/testdata/stable/all_shapes/elk/board.exp.json index a89fff02d..bb4e1b59a 100644 --- a/e2etests/testdata/stable/all_shapes/elk/board.exp.json +++ b/e2etests/testdata/stable/all_shapes/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "rectangle", diff --git a/e2etests/testdata/stable/all_shapes_multiple/dagre/board.exp.json b/e2etests/testdata/stable/all_shapes_multiple/dagre/board.exp.json index 7f16e5fcf..f2c2b370c 100644 --- a/e2etests/testdata/stable/all_shapes_multiple/dagre/board.exp.json +++ b/e2etests/testdata/stable/all_shapes_multiple/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "rectangle", diff --git a/e2etests/testdata/stable/all_shapes_multiple/elk/board.exp.json b/e2etests/testdata/stable/all_shapes_multiple/elk/board.exp.json index 57cab86a5..f58e186be 100644 --- a/e2etests/testdata/stable/all_shapes_multiple/elk/board.exp.json +++ b/e2etests/testdata/stable/all_shapes_multiple/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "rectangle", diff --git a/e2etests/testdata/stable/all_shapes_shadow/dagre/board.exp.json b/e2etests/testdata/stable/all_shapes_shadow/dagre/board.exp.json index d24a8ab71..6b56e5f3c 100644 --- a/e2etests/testdata/stable/all_shapes_shadow/dagre/board.exp.json +++ b/e2etests/testdata/stable/all_shapes_shadow/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "rectangle", diff --git a/e2etests/testdata/stable/all_shapes_shadow/elk/board.exp.json b/e2etests/testdata/stable/all_shapes_shadow/elk/board.exp.json index 8cac656f4..c59f8f93b 100644 --- a/e2etests/testdata/stable/all_shapes_shadow/elk/board.exp.json +++ b/e2etests/testdata/stable/all_shapes_shadow/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "rectangle", diff --git a/e2etests/testdata/stable/arrowhead_adjustment/dagre/board.exp.json b/e2etests/testdata/stable/arrowhead_adjustment/dagre/board.exp.json index 382538056..24b914614 100644 --- a/e2etests/testdata/stable/arrowhead_adjustment/dagre/board.exp.json +++ b/e2etests/testdata/stable/arrowhead_adjustment/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "c", diff --git a/e2etests/testdata/stable/arrowhead_adjustment/elk/board.exp.json b/e2etests/testdata/stable/arrowhead_adjustment/elk/board.exp.json index 533e8578d..f293ab039 100644 --- a/e2etests/testdata/stable/arrowhead_adjustment/elk/board.exp.json +++ b/e2etests/testdata/stable/arrowhead_adjustment/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "c", diff --git a/e2etests/testdata/stable/arrowhead_labels/dagre/board.exp.json b/e2etests/testdata/stable/arrowhead_labels/dagre/board.exp.json index 77ab7760f..75426bec1 100644 --- a/e2etests/testdata/stable/arrowhead_labels/dagre/board.exp.json +++ b/e2etests/testdata/stable/arrowhead_labels/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/arrowhead_labels/elk/board.exp.json b/e2etests/testdata/stable/arrowhead_labels/elk/board.exp.json index 97667ccc4..bbfd06974 100644 --- a/e2etests/testdata/stable/arrowhead_labels/elk/board.exp.json +++ b/e2etests/testdata/stable/arrowhead_labels/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/binary_tree/dagre/board.exp.json b/e2etests/testdata/stable/binary_tree/dagre/board.exp.json index a8a2e2377..b1f8d0b04 100644 --- a/e2etests/testdata/stable/binary_tree/dagre/board.exp.json +++ b/e2etests/testdata/stable/binary_tree/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/binary_tree/elk/board.exp.json b/e2etests/testdata/stable/binary_tree/elk/board.exp.json index c7843d221..210864690 100644 --- a/e2etests/testdata/stable/binary_tree/elk/board.exp.json +++ b/e2etests/testdata/stable/binary_tree/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/chaos1/dagre/board.exp.json b/e2etests/testdata/stable/chaos1/dagre/board.exp.json index bc738619a..d039ab154 100644 --- a/e2etests/testdata/stable/chaos1/dagre/board.exp.json +++ b/e2etests/testdata/stable/chaos1/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "aaa", diff --git a/e2etests/testdata/stable/chaos1/elk/board.exp.json b/e2etests/testdata/stable/chaos1/elk/board.exp.json index e091066ec..57334f005 100644 --- a/e2etests/testdata/stable/chaos1/elk/board.exp.json +++ b/e2etests/testdata/stable/chaos1/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "aaa", diff --git a/e2etests/testdata/stable/chaos2/dagre/board.exp.json b/e2etests/testdata/stable/chaos2/dagre/board.exp.json index 79dbd4512..dd4e04097 100644 --- a/e2etests/testdata/stable/chaos2/dagre/board.exp.json +++ b/e2etests/testdata/stable/chaos2/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "aa", diff --git a/e2etests/testdata/stable/chaos2/elk/board.exp.json b/e2etests/testdata/stable/chaos2/elk/board.exp.json index f99715058..71ec18ffd 100644 --- a/e2etests/testdata/stable/chaos2/elk/board.exp.json +++ b/e2etests/testdata/stable/chaos2/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "aa", diff --git a/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json b/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json index 0ba6c70e2..39018fcb3 100644 --- a/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json +++ b/e2etests/testdata/stable/child_parent_edges/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/child_parent_edges/elk/board.exp.json b/e2etests/testdata/stable/child_parent_edges/elk/board.exp.json index 6f2a79c20..36bf7d1f0 100644 --- a/e2etests/testdata/stable/child_parent_edges/elk/board.exp.json +++ b/e2etests/testdata/stable/child_parent_edges/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/circular_dependency/dagre/board.exp.json b/e2etests/testdata/stable/circular_dependency/dagre/board.exp.json index 2f3cf44dd..e7c9d66ff 100644 --- a/e2etests/testdata/stable/circular_dependency/dagre/board.exp.json +++ b/e2etests/testdata/stable/circular_dependency/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/circular_dependency/elk/board.exp.json b/e2etests/testdata/stable/circular_dependency/elk/board.exp.json index 5c33e09d4..4a5066473 100644 --- a/e2etests/testdata/stable/circular_dependency/elk/board.exp.json +++ b/e2etests/testdata/stable/circular_dependency/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/class/dagre/board.exp.json b/e2etests/testdata/stable/class/dagre/board.exp.json index 75c14d669..179ee373e 100644 --- a/e2etests/testdata/stable/class/dagre/board.exp.json +++ b/e2etests/testdata/stable/class/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "manager", diff --git a/e2etests/testdata/stable/class/elk/board.exp.json b/e2etests/testdata/stable/class/elk/board.exp.json index 85549a957..90dd60cd4 100644 --- a/e2etests/testdata/stable/class/elk/board.exp.json +++ b/e2etests/testdata/stable/class/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "manager", diff --git a/e2etests/testdata/stable/code_snippet/dagre/board.exp.json b/e2etests/testdata/stable/code_snippet/dagre/board.exp.json index c058364e1..6401cabbb 100644 --- a/e2etests/testdata/stable/code_snippet/dagre/board.exp.json +++ b/e2etests/testdata/stable/code_snippet/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "hey", diff --git a/e2etests/testdata/stable/code_snippet/elk/board.exp.json b/e2etests/testdata/stable/code_snippet/elk/board.exp.json index 0004dd714..8eac03000 100644 --- a/e2etests/testdata/stable/code_snippet/elk/board.exp.json +++ b/e2etests/testdata/stable/code_snippet/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "hey", diff --git a/e2etests/testdata/stable/connected_container/dagre/board.exp.json b/e2etests/testdata/stable/connected_container/dagre/board.exp.json index f16c21da4..92c12815c 100644 --- a/e2etests/testdata/stable/connected_container/dagre/board.exp.json +++ b/e2etests/testdata/stable/connected_container/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/connected_container/elk/board.exp.json b/e2etests/testdata/stable/connected_container/elk/board.exp.json index 5418f19ad..aa06b08f3 100644 --- a/e2etests/testdata/stable/connected_container/elk/board.exp.json +++ b/e2etests/testdata/stable/connected_container/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/container_edges/dagre/board.exp.json b/e2etests/testdata/stable/container_edges/dagre/board.exp.json index 85f844962..f44baa923 100644 --- a/e2etests/testdata/stable/container_edges/dagre/board.exp.json +++ b/e2etests/testdata/stable/container_edges/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/container_edges/elk/board.exp.json b/e2etests/testdata/stable/container_edges/elk/board.exp.json index 24edf456f..4da400cc9 100644 --- a/e2etests/testdata/stable/container_edges/elk/board.exp.json +++ b/e2etests/testdata/stable/container_edges/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/dense/dagre/board.exp.json b/e2etests/testdata/stable/dense/dagre/board.exp.json index 547905421..d9848b940 100644 --- a/e2etests/testdata/stable/dense/dagre/board.exp.json +++ b/e2etests/testdata/stable/dense/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/dense/elk/board.exp.json b/e2etests/testdata/stable/dense/elk/board.exp.json index c695b61a0..45e2e0190 100644 --- a/e2etests/testdata/stable/dense/elk/board.exp.json +++ b/e2etests/testdata/stable/dense/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/different_subgraphs/dagre/board.exp.json b/e2etests/testdata/stable/different_subgraphs/dagre/board.exp.json index fdb83f0fb..c8eed6a5e 100644 --- a/e2etests/testdata/stable/different_subgraphs/dagre/board.exp.json +++ b/e2etests/testdata/stable/different_subgraphs/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "finally", diff --git a/e2etests/testdata/stable/different_subgraphs/elk/board.exp.json b/e2etests/testdata/stable/different_subgraphs/elk/board.exp.json index 05ad815ae..8308fc41d 100644 --- a/e2etests/testdata/stable/different_subgraphs/elk/board.exp.json +++ b/e2etests/testdata/stable/different_subgraphs/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "finally", diff --git a/e2etests/testdata/stable/direction/dagre/board.exp.json b/e2etests/testdata/stable/direction/dagre/board.exp.json index a9b49e579..a8adfc1e7 100644 --- a/e2etests/testdata/stable/direction/dagre/board.exp.json +++ b/e2etests/testdata/stable/direction/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "b", diff --git a/e2etests/testdata/stable/direction/elk/board.exp.json b/e2etests/testdata/stable/direction/elk/board.exp.json index cee5d0039..22f3eb189 100644 --- a/e2etests/testdata/stable/direction/elk/board.exp.json +++ b/e2etests/testdata/stable/direction/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "b", diff --git a/e2etests/testdata/stable/font_colors/dagre/board.exp.json b/e2etests/testdata/stable/font_colors/dagre/board.exp.json index f8ea27cbe..a65741153 100644 --- a/e2etests/testdata/stable/font_colors/dagre/board.exp.json +++ b/e2etests/testdata/stable/font_colors/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "alpha", diff --git a/e2etests/testdata/stable/font_colors/elk/board.exp.json b/e2etests/testdata/stable/font_colors/elk/board.exp.json index c7cbbba18..864c7117d 100644 --- a/e2etests/testdata/stable/font_colors/elk/board.exp.json +++ b/e2etests/testdata/stable/font_colors/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "alpha", diff --git a/e2etests/testdata/stable/font_sizes/dagre/board.exp.json b/e2etests/testdata/stable/font_sizes/dagre/board.exp.json index 0579a08d9..bc25f0e7d 100644 --- a/e2etests/testdata/stable/font_sizes/dagre/board.exp.json +++ b/e2etests/testdata/stable/font_sizes/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "size XS", diff --git a/e2etests/testdata/stable/font_sizes/elk/board.exp.json b/e2etests/testdata/stable/font_sizes/elk/board.exp.json index 9658ee501..514d9af1e 100644 --- a/e2etests/testdata/stable/font_sizes/elk/board.exp.json +++ b/e2etests/testdata/stable/font_sizes/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "size XS", diff --git a/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json b/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json index 414bc5f4a..6a31c719e 100644 --- a/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json +++ b/e2etests/testdata/stable/giant_markdown_test/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json b/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json index f2ed13f05..2d2b42a30 100644 --- a/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json +++ b/e2etests/testdata/stable/giant_markdown_test/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/hr/dagre/board.exp.json b/e2etests/testdata/stable/hr/dagre/board.exp.json index 7f75d9d5f..2eab17c42 100644 --- a/e2etests/testdata/stable/hr/dagre/board.exp.json +++ b/e2etests/testdata/stable/hr/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/hr/elk/board.exp.json b/e2etests/testdata/stable/hr/elk/board.exp.json index 413ae4047..81bb926e0 100644 --- a/e2etests/testdata/stable/hr/elk/board.exp.json +++ b/e2etests/testdata/stable/hr/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/icon-label/dagre/board.exp.json b/e2etests/testdata/stable/icon-label/dagre/board.exp.json index d8830f909..b76cfb943 100644 --- a/e2etests/testdata/stable/icon-label/dagre/board.exp.json +++ b/e2etests/testdata/stable/icon-label/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "ww", diff --git a/e2etests/testdata/stable/icon-label/elk/board.exp.json b/e2etests/testdata/stable/icon-label/elk/board.exp.json index 2c78c5abb..9c603b89a 100644 --- a/e2etests/testdata/stable/icon-label/elk/board.exp.json +++ b/e2etests/testdata/stable/icon-label/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "ww", diff --git a/e2etests/testdata/stable/images/dagre/board.exp.json b/e2etests/testdata/stable/images/dagre/board.exp.json index 63be9ae31..27fa73e64 100644 --- a/e2etests/testdata/stable/images/dagre/board.exp.json +++ b/e2etests/testdata/stable/images/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/images/elk/board.exp.json b/e2etests/testdata/stable/images/elk/board.exp.json index 4e2889440..7594c85d2 100644 --- a/e2etests/testdata/stable/images/elk/board.exp.json +++ b/e2etests/testdata/stable/images/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/investigate/dagre/board.exp.json b/e2etests/testdata/stable/investigate/dagre/board.exp.json index 7cd6ea00b..e6d654503 100644 --- a/e2etests/testdata/stable/investigate/dagre/board.exp.json +++ b/e2etests/testdata/stable/investigate/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "aa", diff --git a/e2etests/testdata/stable/investigate/elk/board.exp.json b/e2etests/testdata/stable/investigate/elk/board.exp.json index 1dba1daa1..94ba1baf0 100644 --- a/e2etests/testdata/stable/investigate/elk/board.exp.json +++ b/e2etests/testdata/stable/investigate/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "aa", diff --git a/e2etests/testdata/stable/large_arch/dagre/board.exp.json b/e2etests/testdata/stable/large_arch/dagre/board.exp.json index f62e8f5a5..0c2dc271b 100644 --- a/e2etests/testdata/stable/large_arch/dagre/board.exp.json +++ b/e2etests/testdata/stable/large_arch/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/large_arch/elk/board.exp.json b/e2etests/testdata/stable/large_arch/elk/board.exp.json index 7ed86f290..838d9d7c5 100644 --- a/e2etests/testdata/stable/large_arch/elk/board.exp.json +++ b/e2etests/testdata/stable/large_arch/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/latex/dagre/board.exp.json b/e2etests/testdata/stable/latex/dagre/board.exp.json index ceaa1e7e1..77988139c 100644 --- a/e2etests/testdata/stable/latex/dagre/board.exp.json +++ b/e2etests/testdata/stable/latex/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/latex/elk/board.exp.json b/e2etests/testdata/stable/latex/elk/board.exp.json index 6a8173784..45fa46c1d 100644 --- a/e2etests/testdata/stable/latex/elk/board.exp.json +++ b/e2etests/testdata/stable/latex/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/li1/dagre/board.exp.json b/e2etests/testdata/stable/li1/dagre/board.exp.json index 9435b0921..244ae9d65 100644 --- a/e2etests/testdata/stable/li1/dagre/board.exp.json +++ b/e2etests/testdata/stable/li1/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/li1/elk/board.exp.json b/e2etests/testdata/stable/li1/elk/board.exp.json index 47de08c95..9e921bf9c 100644 --- a/e2etests/testdata/stable/li1/elk/board.exp.json +++ b/e2etests/testdata/stable/li1/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/li2/dagre/board.exp.json b/e2etests/testdata/stable/li2/dagre/board.exp.json index c574a6054..49b15e713 100644 --- a/e2etests/testdata/stable/li2/dagre/board.exp.json +++ b/e2etests/testdata/stable/li2/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/li2/elk/board.exp.json b/e2etests/testdata/stable/li2/elk/board.exp.json index 90a808fda..ce7f231fa 100644 --- a/e2etests/testdata/stable/li2/elk/board.exp.json +++ b/e2etests/testdata/stable/li2/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/li3/dagre/board.exp.json b/e2etests/testdata/stable/li3/dagre/board.exp.json index 634e620e0..198c058d2 100644 --- a/e2etests/testdata/stable/li3/dagre/board.exp.json +++ b/e2etests/testdata/stable/li3/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/li3/elk/board.exp.json b/e2etests/testdata/stable/li3/elk/board.exp.json index 1d6ac345e..0f59680e8 100644 --- a/e2etests/testdata/stable/li3/elk/board.exp.json +++ b/e2etests/testdata/stable/li3/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/li4/dagre/board.exp.json b/e2etests/testdata/stable/li4/dagre/board.exp.json index 81a0b09db..473c80389 100644 --- a/e2etests/testdata/stable/li4/dagre/board.exp.json +++ b/e2etests/testdata/stable/li4/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/li4/elk/board.exp.json b/e2etests/testdata/stable/li4/elk/board.exp.json index 07ea21fc6..ed7d132c8 100644 --- a/e2etests/testdata/stable/li4/elk/board.exp.json +++ b/e2etests/testdata/stable/li4/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/lone_h1/dagre/board.exp.json b/e2etests/testdata/stable/lone_h1/dagre/board.exp.json index 8b658c6fb..c14d6d206 100644 --- a/e2etests/testdata/stable/lone_h1/dagre/board.exp.json +++ b/e2etests/testdata/stable/lone_h1/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/lone_h1/elk/board.exp.json b/e2etests/testdata/stable/lone_h1/elk/board.exp.json index 3dbaafabd..12c8b5684 100644 --- a/e2etests/testdata/stable/lone_h1/elk/board.exp.json +++ b/e2etests/testdata/stable/lone_h1/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/markdown/dagre/board.exp.json b/e2etests/testdata/stable/markdown/dagre/board.exp.json index f699bafca..e48ab5dde 100644 --- a/e2etests/testdata/stable/markdown/dagre/board.exp.json +++ b/e2etests/testdata/stable/markdown/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "hey", diff --git a/e2etests/testdata/stable/markdown/elk/board.exp.json b/e2etests/testdata/stable/markdown/elk/board.exp.json index f2b76ef49..5fd076257 100644 --- a/e2etests/testdata/stable/markdown/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "hey", diff --git a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json index 3eb3963e9..ceb523966 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "container", diff --git a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json index 197eecbbb..4c61b52ee 100644 --- a/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json +++ b/e2etests/testdata/stable/markdown_stroke_fill/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "container", diff --git a/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json index 21a05248c..3d86d9b06 100644 --- a/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_2space_newline/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "markdown", diff --git a/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json b/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json index 3b4814447..805c80024 100644 --- a/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json +++ b/e2etests/testdata/stable/md_2space_newline/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "markdown", diff --git a/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json b/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json index d6ad2ea2b..cf98e2973 100644 --- a/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_backslash_newline/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "markdown", diff --git a/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json b/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json index 03fbd7b46..da037808b 100644 --- a/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json +++ b/e2etests/testdata/stable/md_backslash_newline/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "markdown", diff --git a/e2etests/testdata/stable/md_code_block_fenced/dagre/board.exp.json b/e2etests/testdata/stable/md_code_block_fenced/dagre/board.exp.json index c2b2def40..071050a31 100644 --- a/e2etests/testdata/stable/md_code_block_fenced/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_fenced/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json b/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json index 926e8ff3f..d249a4c75 100644 --- a/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_fenced/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json b/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json index ddd41a1bc..0242695e3 100644 --- a/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_indented/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json b/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json index 1f3537e36..2bb4e0287 100644 --- a/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_block_indented/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json b/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json index da1c97705..a5ada4f94 100644 --- a/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json +++ b/e2etests/testdata/stable/md_code_inline/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/md_code_inline/elk/board.exp.json b/e2etests/testdata/stable/md_code_inline/elk/board.exp.json index 001e39423..644f03251 100644 --- a/e2etests/testdata/stable/md_code_inline/elk/board.exp.json +++ b/e2etests/testdata/stable/md_code_inline/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/multiline_text/dagre/board.exp.json b/e2etests/testdata/stable/multiline_text/dagre/board.exp.json index dc408643d..c00ff06bf 100644 --- a/e2etests/testdata/stable/multiline_text/dagre/board.exp.json +++ b/e2etests/testdata/stable/multiline_text/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "hey", diff --git a/e2etests/testdata/stable/multiline_text/elk/board.exp.json b/e2etests/testdata/stable/multiline_text/elk/board.exp.json index f8401f6f1..e6f1b7d52 100644 --- a/e2etests/testdata/stable/multiline_text/elk/board.exp.json +++ b/e2etests/testdata/stable/multiline_text/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "hey", diff --git a/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json b/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json index 5ce72849a..5618041a7 100644 --- a/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json +++ b/e2etests/testdata/stable/multiple_trees/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/multiple_trees/elk/board.exp.json b/e2etests/testdata/stable/multiple_trees/elk/board.exp.json index ee8aa253e..e4b605c39 100644 --- a/e2etests/testdata/stable/multiple_trees/elk/board.exp.json +++ b/e2etests/testdata/stable/multiple_trees/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/n22_e32/dagre/board.exp.json b/e2etests/testdata/stable/n22_e32/dagre/board.exp.json index 7c7160909..a68914c56 100644 --- a/e2etests/testdata/stable/n22_e32/dagre/board.exp.json +++ b/e2etests/testdata/stable/n22_e32/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/n22_e32/elk/board.exp.json b/e2etests/testdata/stable/n22_e32/elk/board.exp.json index ac23e8ebc..e78d5636e 100644 --- a/e2etests/testdata/stable/n22_e32/elk/board.exp.json +++ b/e2etests/testdata/stable/n22_e32/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/number_connections/dagre/board.exp.json b/e2etests/testdata/stable/number_connections/dagre/board.exp.json index 135266c6a..31c7ff200 100644 --- a/e2etests/testdata/stable/number_connections/dagre/board.exp.json +++ b/e2etests/testdata/stable/number_connections/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "foo baz", diff --git a/e2etests/testdata/stable/number_connections/elk/board.exp.json b/e2etests/testdata/stable/number_connections/elk/board.exp.json index 33c4945db..4d6f95c7d 100644 --- a/e2etests/testdata/stable/number_connections/elk/board.exp.json +++ b/e2etests/testdata/stable/number_connections/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "foo baz", diff --git a/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json b/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json index 9970f03cd..429f6a3e0 100644 --- a/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json +++ b/e2etests/testdata/stable/one_container_loop/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/one_container_loop/elk/board.exp.json b/e2etests/testdata/stable/one_container_loop/elk/board.exp.json index 0840b6e3d..f21f8a462 100644 --- a/e2etests/testdata/stable/one_container_loop/elk/board.exp.json +++ b/e2etests/testdata/stable/one_container_loop/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json b/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json index 7af5ef943..8b88599a3 100644 --- a/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json +++ b/e2etests/testdata/stable/one_three_one_container/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "top", diff --git a/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json b/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json index 2d93434bd..b3f5277ed 100644 --- a/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json +++ b/e2etests/testdata/stable/one_three_one_container/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "top", diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json b/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json index 4c47a8a9c..0cb008545 100644 --- a/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json +++ b/e2etests/testdata/stable/overlapping_image_container_labels/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "root", diff --git a/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json b/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json index 754dfe0fb..4209d10c4 100644 --- a/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json +++ b/e2etests/testdata/stable/overlapping_image_container_labels/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "root", diff --git a/e2etests/testdata/stable/p/dagre/board.exp.json b/e2etests/testdata/stable/p/dagre/board.exp.json index 6e5540ffb..bb254d64c 100644 --- a/e2etests/testdata/stable/p/dagre/board.exp.json +++ b/e2etests/testdata/stable/p/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/p/elk/board.exp.json b/e2etests/testdata/stable/p/elk/board.exp.json index c5dde6807..70a23d967 100644 --- a/e2etests/testdata/stable/p/elk/board.exp.json +++ b/e2etests/testdata/stable/p/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/pre/dagre/board.exp.json b/e2etests/testdata/stable/pre/dagre/board.exp.json index 71acc0e57..a83d7c849 100644 --- a/e2etests/testdata/stable/pre/dagre/board.exp.json +++ b/e2etests/testdata/stable/pre/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/pre/elk/board.exp.json b/e2etests/testdata/stable/pre/elk/board.exp.json index 551efb434..df945bd32 100644 --- a/e2etests/testdata/stable/pre/elk/board.exp.json +++ b/e2etests/testdata/stable/pre/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "md", diff --git a/e2etests/testdata/stable/self-referencing/dagre/board.exp.json b/e2etests/testdata/stable/self-referencing/dagre/board.exp.json index 1f04cda77..5d31ca523 100644 --- a/e2etests/testdata/stable/self-referencing/dagre/board.exp.json +++ b/e2etests/testdata/stable/self-referencing/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/e2etests/testdata/stable/self-referencing/elk/board.exp.json b/e2etests/testdata/stable/self-referencing/elk/board.exp.json index 36e35e83d..a7558cb11 100644 --- a/e2etests/testdata/stable/self-referencing/elk/board.exp.json +++ b/e2etests/testdata/stable/self-referencing/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/e2etests/testdata/stable/sequence_diagram_actor_distance/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_actor_distance/dagre/board.exp.json index 2341f4127..085e70d8e 100644 --- a/e2etests/testdata/stable/sequence_diagram_actor_distance/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_actor_distance/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/board.exp.json index 2341f4127..085e70d8e 100644 --- a/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_actor_distance/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json index edd94ad16..61504c34e 100644 --- a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json index edd94ad16..61504c34e 100644 --- a/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_distance/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_distance/dagre/board.exp.json index 9be45ea07..f213d3498 100644 --- a/e2etests/testdata/stable/sequence_diagram_distance/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_distance/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "alice", diff --git a/e2etests/testdata/stable/sequence_diagram_distance/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_distance/elk/board.exp.json index 9be45ea07..f213d3498 100644 --- a/e2etests/testdata/stable/sequence_diagram_distance/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_distance/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "alice", diff --git a/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json index 4535a99dd..270198f16 100644 --- a/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_groups/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json index 4535a99dd..270198f16 100644 --- a/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_long_note/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_long_note/dagre/board.exp.json index 8890d73c9..3c36498bb 100644 --- a/e2etests/testdata/stable/sequence_diagram_long_note/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_long_note/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "b", diff --git a/e2etests/testdata/stable/sequence_diagram_long_note/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_long_note/elk/board.exp.json index 8890d73c9..3c36498bb 100644 --- a/e2etests/testdata/stable/sequence_diagram_long_note/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_long_note/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "b", diff --git a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json index efc84c172..21f56fb8a 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/board.exp.json index efc84c172..21f56fb8a 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_groups/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json index f43c4be26..6502324d5 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_span/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "scorer", diff --git a/e2etests/testdata/stable/sequence_diagram_nested_span/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_span/elk/board.exp.json index f43c4be26..6502324d5 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_span/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_span/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "scorer", diff --git a/e2etests/testdata/stable/sequence_diagram_note/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_note/dagre/board.exp.json index 0a9ecbf4e..adfec6be5 100644 --- a/e2etests/testdata/stable/sequence_diagram_note/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_note/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_note/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_note/elk/board.exp.json index 0a9ecbf4e..adfec6be5 100644 --- a/e2etests/testdata/stable/sequence_diagram_note/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_note/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json index a49ddb67a..53bd74bee 100644 --- a/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_real/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "How this is rendered", diff --git a/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json index 0f9eb51ae..d20a6d846 100644 --- a/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "How this is rendered", diff --git a/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/board.exp.json index 4c8d9cd09..54d51adf1 100644 --- a/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_self_edges/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_self_edges/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_self_edges/elk/board.exp.json index 4c8d9cd09..54d51adf1 100644 --- a/e2etests/testdata/stable/sequence_diagram_self_edges/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_self_edges/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/sequence_diagram_simple/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_simple/dagre/board.exp.json index 5daa335fc..fb0887203 100644 --- a/e2etests/testdata/stable/sequence_diagram_simple/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_simple/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "alice", diff --git a/e2etests/testdata/stable/sequence_diagram_simple/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_simple/elk/board.exp.json index 5daa335fc..fb0887203 100644 --- a/e2etests/testdata/stable/sequence_diagram_simple/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_simple/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "alice", diff --git a/e2etests/testdata/stable/sequence_diagram_span/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_span/dagre/board.exp.json index af401f123..37a77eab3 100644 --- a/e2etests/testdata/stable/sequence_diagram_span/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_span/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "scorer", diff --git a/e2etests/testdata/stable/sequence_diagram_span/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_span/elk/board.exp.json index af401f123..37a77eab3 100644 --- a/e2etests/testdata/stable/sequence_diagram_span/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_span/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "scorer", diff --git a/e2etests/testdata/stable/sequence_diagrams/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagrams/dagre/board.exp.json index fb7550f69..5844c5a26 100644 --- a/e2etests/testdata/stable/sequence_diagrams/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagrams/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a_shape", diff --git a/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json index 81a532b8a..69ec36ed6 100644 --- a/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagrams/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a_shape", diff --git a/e2etests/testdata/stable/sql_tables/dagre/board.exp.json b/e2etests/testdata/stable/sql_tables/dagre/board.exp.json index f8005cf0a..a3b85c40e 100644 --- a/e2etests/testdata/stable/sql_tables/dagre/board.exp.json +++ b/e2etests/testdata/stable/sql_tables/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "users", diff --git a/e2etests/testdata/stable/sql_tables/elk/board.exp.json b/e2etests/testdata/stable/sql_tables/elk/board.exp.json index e4f2be424..f9f18faf2 100644 --- a/e2etests/testdata/stable/sql_tables/elk/board.exp.json +++ b/e2etests/testdata/stable/sql_tables/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "users", diff --git a/e2etests/testdata/stable/square_3d/dagre/board.exp.json b/e2etests/testdata/stable/square_3d/dagre/board.exp.json index 8a037500b..fcc62b3d5 100644 --- a/e2etests/testdata/stable/square_3d/dagre/board.exp.json +++ b/e2etests/testdata/stable/square_3d/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "rectangle", diff --git a/e2etests/testdata/stable/square_3d/elk/board.exp.json b/e2etests/testdata/stable/square_3d/elk/board.exp.json index e7bf89b84..e1679a64f 100644 --- a/e2etests/testdata/stable/square_3d/elk/board.exp.json +++ b/e2etests/testdata/stable/square_3d/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "rectangle", diff --git a/e2etests/testdata/stable/straight_hierarchy_container/dagre/board.exp.json b/e2etests/testdata/stable/straight_hierarchy_container/dagre/board.exp.json index 00913a3e3..e959701ff 100644 --- a/e2etests/testdata/stable/straight_hierarchy_container/dagre/board.exp.json +++ b/e2etests/testdata/stable/straight_hierarchy_container/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/straight_hierarchy_container/elk/board.exp.json b/e2etests/testdata/stable/straight_hierarchy_container/elk/board.exp.json index e84f3cb86..86787d831 100644 --- a/e2etests/testdata/stable/straight_hierarchy_container/elk/board.exp.json +++ b/e2etests/testdata/stable/straight_hierarchy_container/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/stable/stylish/dagre/board.exp.json b/e2etests/testdata/stable/stylish/dagre/board.exp.json index 7dce7c5ce..2f80128a5 100644 --- a/e2etests/testdata/stable/stylish/dagre/board.exp.json +++ b/e2etests/testdata/stable/stylish/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/e2etests/testdata/stable/stylish/elk/board.exp.json b/e2etests/testdata/stable/stylish/elk/board.exp.json index f2da4deeb..04a954b3b 100644 --- a/e2etests/testdata/stable/stylish/elk/board.exp.json +++ b/e2etests/testdata/stable/stylish/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/e2etests/testdata/stable/transparent_3d/dagre/board.exp.json b/e2etests/testdata/stable/transparent_3d/dagre/board.exp.json index c19a78f8f..7927d10ea 100644 --- a/e2etests/testdata/stable/transparent_3d/dagre/board.exp.json +++ b/e2etests/testdata/stable/transparent_3d/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "cube", diff --git a/e2etests/testdata/stable/transparent_3d/elk/board.exp.json b/e2etests/testdata/stable/transparent_3d/elk/board.exp.json index cbdf1ca4e..4143c9ac5 100644 --- a/e2etests/testdata/stable/transparent_3d/elk/board.exp.json +++ b/e2etests/testdata/stable/transparent_3d/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "cube", diff --git a/e2etests/testdata/stable/us_map/dagre/board.exp.json b/e2etests/testdata/stable/us_map/dagre/board.exp.json index 6deece116..8cb41e19c 100644 --- a/e2etests/testdata/stable/us_map/dagre/board.exp.json +++ b/e2etests/testdata/stable/us_map/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "AK", diff --git a/e2etests/testdata/stable/us_map/elk/board.exp.json b/e2etests/testdata/stable/us_map/elk/board.exp.json index 3eab45ff6..e3aa25c1f 100644 --- a/e2etests/testdata/stable/us_map/elk/board.exp.json +++ b/e2etests/testdata/stable/us_map/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "AK", diff --git a/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json b/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json index 7c1c0908e..2ad08e0f2 100644 --- a/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json +++ b/e2etests/testdata/todo/container_child_edge/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "container", diff --git a/e2etests/testdata/todo/container_child_edge/elk/board.exp.json b/e2etests/testdata/todo/container_child_edge/elk/board.exp.json index 35b0e5dd0..db76f97e0 100644 --- a/e2etests/testdata/todo/container_child_edge/elk/board.exp.json +++ b/e2etests/testdata/todo/container_child_edge/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "container", diff --git a/e2etests/testdata/todo/font_sizes_containers_large/dagre/board.exp.json b/e2etests/testdata/todo/font_sizes_containers_large/dagre/board.exp.json index f3951de5d..e5ee6e21d 100644 --- a/e2etests/testdata/todo/font_sizes_containers_large/dagre/board.exp.json +++ b/e2etests/testdata/todo/font_sizes_containers_large/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "ninety nine", diff --git a/e2etests/testdata/todo/font_sizes_containers_large/elk/board.exp.json b/e2etests/testdata/todo/font_sizes_containers_large/elk/board.exp.json index d875b6ef5..67b173d17 100644 --- a/e2etests/testdata/todo/font_sizes_containers_large/elk/board.exp.json +++ b/e2etests/testdata/todo/font_sizes_containers_large/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "ninety nine", diff --git a/e2etests/testdata/todo/font_sizes_large/dagre/board.exp.json b/e2etests/testdata/todo/font_sizes_large/dagre/board.exp.json index d73c580ee..2d731a989 100644 --- a/e2etests/testdata/todo/font_sizes_large/dagre/board.exp.json +++ b/e2etests/testdata/todo/font_sizes_large/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "eight", diff --git a/e2etests/testdata/todo/font_sizes_large/elk/board.exp.json b/e2etests/testdata/todo/font_sizes_large/elk/board.exp.json index d012e76be..3a9722ca2 100644 --- a/e2etests/testdata/todo/font_sizes_large/elk/board.exp.json +++ b/e2etests/testdata/todo/font_sizes_large/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "eight", diff --git a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json index bf9dc2e70..c0f384c07 100644 --- a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json +++ b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "b", diff --git a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/board.exp.json b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/board.exp.json index bf9dc2e70..c0f384c07 100644 --- a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/board.exp.json +++ b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "b", diff --git a/e2etests/testdata/todo/tall_edge_label/dagre/board.exp.json b/e2etests/testdata/todo/tall_edge_label/dagre/board.exp.json index 4050c622f..f38c0a6d4 100644 --- a/e2etests/testdata/todo/tall_edge_label/dagre/board.exp.json +++ b/e2etests/testdata/todo/tall_edge_label/dagre/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/e2etests/testdata/todo/tall_edge_label/elk/board.exp.json b/e2etests/testdata/todo/tall_edge_label/elk/board.exp.json index be7edc7f0..3bef76163 100644 --- a/e2etests/testdata/todo/tall_edge_label/elk/board.exp.json +++ b/e2etests/testdata/todo/tall_edge_label/elk/board.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "a", diff --git a/lib/svg/path.go b/lib/svg/path.go index a643479f2..fa448d419 100644 --- a/lib/svg/path.go +++ b/lib/svg/path.go @@ -105,3 +105,11 @@ func (c *SvgPathContext) V(isLowerCase bool, y float64) { func (c *SvgPathContext) PathData() string { return strings.Join(c.Commands, " ") } + +func GetStrokeDashAttributes(strokeWidth, dashGapSize float64) (float64, float64) { + // as the stroke width gets thicker, the dash gap gets smaller + scale := math.Log10(-0.6*strokeWidth+10.6)*0.5 + 0.5 + scaledDashSize := strokeWidth * dashGapSize + scaledGapSize := scale * scaledDashSize + return scaledDashSize, scaledGapSize +} diff --git a/main.go b/main.go index 53ef5d201..d4b6b63aa 100644 --- a/main.go +++ b/main.go @@ -46,7 +46,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) { } hostFlag := ms.Opts.String("HOST", "host", "h", "localhost", "host listening address when used with watch") portFlag := ms.Opts.String("PORT", "port", "p", "0", "port listening address when used with watch") - bundleFlag, err := ms.Opts.Bool("D2_BUNDLE", "bundle", "b", true, "when outputting SVG, bundle all assets and layers into the output file.") + bundleFlag, err := ms.Opts.Bool("D2_BUNDLE", "bundle", "b", true, "when outputting SVG, bundle all assets and layers into the output file") if err != nil { return err } @@ -54,7 +54,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) { if err != nil { return err } - layoutFlag := ms.Opts.String("D2_LAYOUT", "layout", "l", "dagre", `the layout engine used.`) + layoutFlag := ms.Opts.String("D2_LAYOUT", "layout", "l", "dagre", `the layout engine used`) themeFlag, err := ms.Opts.Int64("D2_THEME", "theme", "t", 0, "the diagram theme ID. For a list of available options, see https://oss.terrastruct.com/d2") if err != nil { return err @@ -67,6 +67,10 @@ func run(ctx context.Context, ms *xmain.State) (err error) { if err != nil { return err } + sketchFlag, err := ms.Opts.Bool("D2_SKETCH", "sketch", "s", false, "render the diagram to look like it was sketched by hand") + if err != nil { + return err + } err = ms.Opts.Flags.Parse(ms.Opts.Args) if !errors.Is(err, pflag.ErrHelp) && err != nil { @@ -164,6 +168,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) { ms.Log.SetTS(true) w, err := newWatcher(ctx, ms, watcherOpts{ layoutPlugin: plugin, + sketch: *sketchFlag, themeID: *themeFlag, pad: *padFlag, host: *hostFlag, @@ -182,7 +187,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) { ctx, cancel := context.WithTimeout(ctx, time.Minute*2) defer cancel() - _, written, err := compile(ctx, ms, plugin, *padFlag, *themeFlag, inputPath, outputPath, *bundleFlag, pw.Page) + _, written, err := compile(ctx, ms, plugin, *sketchFlag, *padFlag, *themeFlag, inputPath, outputPath, *bundleFlag, pw.Page) if err != nil { if written { return fmt.Errorf("failed to fully compile (partial render written): %w", err) @@ -193,7 +198,7 @@ func run(ctx context.Context, ms *xmain.State) (err error) { return nil } -func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, pad, themeID int64, inputPath, outputPath string, bundle bool, page playwright.Page) (_ []byte, written bool, _ error) { +func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketch bool, pad, themeID int64, inputPath, outputPath string, bundle bool, page playwright.Page) (_ []byte, written bool, _ error) { input, err := ms.ReadPath(inputPath) if err != nil { return nil, false, err @@ -214,10 +219,14 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, pad, return nil, false, err } - svg, err := d2svg.Render(diagram, int(pad)) + svg, err := d2svg.Render(diagram, &d2svg.RenderOpts{ + Pad: int(pad), + Sketch: sketch, + }) if err != nil { return nil, false, err } + svg, err = plugin.PostProcess(ctx, svg) if err != nil { return svg, false, err diff --git a/testdata/d2exporter/TestExport/connection/arrowhead.exp.json b/testdata/d2exporter/TestExport/connection/arrowhead.exp.json index 09b26f2db..759d315c5 100644 --- a/testdata/d2exporter/TestExport/connection/arrowhead.exp.json +++ b/testdata/d2exporter/TestExport/connection/arrowhead.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/connection/basic.exp.json b/testdata/d2exporter/TestExport/connection/basic.exp.json index 50d65855d..fe9653021 100644 --- a/testdata/d2exporter/TestExport/connection/basic.exp.json +++ b/testdata/d2exporter/TestExport/connection/basic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/connection/stroke-dash.exp.json b/testdata/d2exporter/TestExport/connection/stroke-dash.exp.json index aa483fe31..7d044e4a5 100644 --- a/testdata/d2exporter/TestExport/connection/stroke-dash.exp.json +++ b/testdata/d2exporter/TestExport/connection/stroke-dash.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/connection/theme_stroke-dash.exp.json b/testdata/d2exporter/TestExport/connection/theme_stroke-dash.exp.json index d1add431f..9e662124a 100644 --- a/testdata/d2exporter/TestExport/connection/theme_stroke-dash.exp.json +++ b/testdata/d2exporter/TestExport/connection/theme_stroke-dash.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/label/basic_shape.exp.json b/testdata/d2exporter/TestExport/label/basic_shape.exp.json index f017e35f5..1b54cf228 100644 --- a/testdata/d2exporter/TestExport/label/basic_shape.exp.json +++ b/testdata/d2exporter/TestExport/label/basic_shape.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/label/connection_font_color.exp.json b/testdata/d2exporter/TestExport/label/connection_font_color.exp.json index 62cf2719e..33a67fdad 100644 --- a/testdata/d2exporter/TestExport/label/connection_font_color.exp.json +++ b/testdata/d2exporter/TestExport/label/connection_font_color.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/label/shape_font_color.exp.json b/testdata/d2exporter/TestExport/label/shape_font_color.exp.json index 00b3d298e..3c0f0c09b 100644 --- a/testdata/d2exporter/TestExport/label/shape_font_color.exp.json +++ b/testdata/d2exporter/TestExport/label/shape_font_color.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/shape/basic.exp.json b/testdata/d2exporter/TestExport/shape/basic.exp.json index 226cbb94e..e381679af 100644 --- a/testdata/d2exporter/TestExport/shape/basic.exp.json +++ b/testdata/d2exporter/TestExport/shape/basic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/shape/border-radius.exp.json b/testdata/d2exporter/TestExport/shape/border-radius.exp.json index 0a934ec54..77af6d534 100644 --- a/testdata/d2exporter/TestExport/shape/border-radius.exp.json +++ b/testdata/d2exporter/TestExport/shape/border-radius.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "Square", diff --git a/testdata/d2exporter/TestExport/shape/image_dimensions.exp.json b/testdata/d2exporter/TestExport/shape/image_dimensions.exp.json index 637bd91e8..1184300e9 100644 --- a/testdata/d2exporter/TestExport/shape/image_dimensions.exp.json +++ b/testdata/d2exporter/TestExport/shape/image_dimensions.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "hey", diff --git a/testdata/d2exporter/TestExport/shape/synonyms.exp.json b/testdata/d2exporter/TestExport/shape/synonyms.exp.json index dc02f5a8f..820282971 100644 --- a/testdata/d2exporter/TestExport/shape/synonyms.exp.json +++ b/testdata/d2exporter/TestExport/shape/synonyms.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/shape/text_color.exp.json b/testdata/d2exporter/TestExport/shape/text_color.exp.json index f043c040f..102ec04c2 100644 --- a/testdata/d2exporter/TestExport/shape/text_color.exp.json +++ b/testdata/d2exporter/TestExport/shape/text_color.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/theme/connection_with_bold.exp.json b/testdata/d2exporter/TestExport/theme/connection_with_bold.exp.json index c0f461b9a..01d4c3619 100644 --- a/testdata/d2exporter/TestExport/theme/connection_with_bold.exp.json +++ b/testdata/d2exporter/TestExport/theme/connection_with_bold.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/theme/connection_with_italic.exp.json b/testdata/d2exporter/TestExport/theme/connection_with_italic.exp.json index 629847c8f..db38a7c02 100644 --- a/testdata/d2exporter/TestExport/theme/connection_with_italic.exp.json +++ b/testdata/d2exporter/TestExport/theme/connection_with_italic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/theme/connection_without_italic.exp.json b/testdata/d2exporter/TestExport/theme/connection_without_italic.exp.json index dd3636dc0..2167b29cc 100644 --- a/testdata/d2exporter/TestExport/theme/connection_without_italic.exp.json +++ b/testdata/d2exporter/TestExport/theme/connection_without_italic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/theme/shape_with_italic.exp.json b/testdata/d2exporter/TestExport/theme/shape_with_italic.exp.json index 7672ab131..c67a7b56c 100644 --- a/testdata/d2exporter/TestExport/theme/shape_with_italic.exp.json +++ b/testdata/d2exporter/TestExport/theme/shape_with_italic.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/testdata/d2exporter/TestExport/theme/shape_without_bold.exp.json b/testdata/d2exporter/TestExport/theme/shape_without_bold.exp.json index c8b3c3d9f..c037ab27a 100644 --- a/testdata/d2exporter/TestExport/theme/shape_without_bold.exp.json +++ b/testdata/d2exporter/TestExport/theme/shape_without_bold.exp.json @@ -1,5 +1,6 @@ { "name": "", + "fontFamily": "SourceSansPro", "shapes": [ { "id": "x", diff --git a/watch.go b/watch.go index 3dc6767e3..5bc99e5e3 100644 --- a/watch.go +++ b/watch.go @@ -42,6 +42,7 @@ type watcherOpts struct { layoutPlugin d2plugin.Plugin themeID int64 pad int64 + sketch bool host string port string inputPath string @@ -355,7 +356,7 @@ func (w *watcher) compileLoop(ctx context.Context) error { w.pw = newPW } - svg, _, err := compile(ctx, w.ms, w.layoutPlugin, w.pad, w.themeID, w.inputPath, w.outputPath, w.bundle, w.pw.Page) + svg, _, err := compile(ctx, w.ms, w.layoutPlugin, w.sketch, w.pad, w.themeID, w.inputPath, w.outputPath, w.bundle, w.pw.Page) errs := "" if err != nil { if len(svg) > 0 { From d41b98fbc98afc00c21925806cbddf5dc49d8280 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 21 Dec 2022 21:05:35 -0800 Subject: [PATCH 155/257] update tests --- d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg | 4 ++-- d2renderers/d2sketch/testdata/basic/sketch.exp.svg | 4 ++-- d2renderers/d2sketch/testdata/chess/sketch.exp.svg | 4 ++-- d2renderers/d2sketch/testdata/child_to_child/sketch.exp.svg | 4 ++-- d2renderers/d2sketch/testdata/connection_label/sketch.exp.svg | 4 ++-- .../regression/dagre_edge_label_spacing/dagre/board.exp.json | 1 + .../regression/dagre_edge_label_spacing/elk/board.exp.json | 1 + .../testdata/regression/elk_alignment/dagre/board.exp.json | 1 + e2etests/testdata/regression/elk_alignment/elk/board.exp.json | 1 + 9 files changed, 14 insertions(+), 10 deletions(-) diff --git a/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg b/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg index 96864ca05..5b8429973 100644 --- a/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/all_shapes/sketch.exp.svg @@ -30,8 +30,8 @@ width="1593" height="831" viewBox="-100 -100 1593 831"> + + + + +People discovery serviceAd mixerOnboarding serviceTwitter Frontend WebIphoneAndroidTimelineScorerHome RankerTimeline ServiceHome mixerManhattanGizmoduckSocial graphTweety PiePrediction ServiceHome ScorerManhattanMemcacheFetchFeatureScoringPrediction Service...etc

Timeline mixer

+
    +
  • Inject ads, who-to-follow, onboarding
  • +
  • Conversation module
  • +
  • Cursoring,pagination
  • +
  • Tweat deduplication
  • +
  • Served data logging
  • +
+
GraphQLFederated Strato Column

Tweet/user content hydration, visibility filtering

+
TLS-API (being deprecated)CrMixerEarlyBirdUtagSpaceCommunities iPhone webHTTP AndroidThrift RPC Candidate FetchFeature HydrationCandidate sources + + + + + + + + \ No newline at end of file diff --git a/lib/textmeasure/markdown.go b/lib/textmeasure/markdown.go index 846c0955f..2b9f22ab2 100644 --- a/lib/textmeasure/markdown.go +++ b/lib/textmeasure/markdown.go @@ -66,8 +66,6 @@ var HeaderToFontSize = map[string]int{ "h6": FONT_SIZE_H6, } -var HeaderFonts map[string]d2fonts.Font - func RenderMarkdown(m string) (string, error) { var output bytes.Buffer if err := markdownRenderer.Convert([]byte(m), &output); err != nil { @@ -77,11 +75,6 @@ func RenderMarkdown(m string) (string, error) { } func init() { - HeaderFonts = make(map[string]d2fonts.Font) - for header, fontSize := range HeaderToFontSize { - HeaderFonts[header] = d2fonts.SourceSansPro.Font(fontSize, d2fonts.FONT_STYLE_BOLD) - } - markdownRenderer = goldmark.New( goldmark.WithRendererOptions( goldmarkHtml.WithUnsafe(), @@ -90,7 +83,7 @@ func init() { ) } -func MeasureMarkdown(mdText string, ruler *Ruler) (width, height int, err error) { +func MeasureMarkdown(mdText string, ruler *Ruler, fontFamily *d2fonts.FontFamily) (width, height int, err error) { render, err := RenderMarkdown(mdText) if err != nil { return width, height, err @@ -111,11 +104,9 @@ func MeasureMarkdown(mdText string, ruler *Ruler) (width, height int, err error) }() } - font := d2fonts.SourceSansPro.Font(MarkdownFontSize, d2fonts.FONT_STYLE_REGULAR) - // TODO consider setting a max width + (manual) text wrapping bodyNode := doc.Find("body").First().Nodes[0] - bodyAttrs := ruler.measureNode(0, bodyNode, font) + bodyAttrs := ruler.measureNode(0, bodyNode, fontFamily, MarkdownFontSize) return int(math.Ceil(bodyAttrs.width)), int(math.Ceil(bodyAttrs.height)), nil } @@ -201,7 +192,12 @@ func (b *blockAttrs) isNotEmpty() bool { } // measures node dimensions to match rendering with styles in github-markdown.css -func (ruler *Ruler) measureNode(depth int, n *html.Node, font d2fonts.Font) blockAttrs { +func (ruler *Ruler) measureNode(depth int, n *html.Node, fontFamily *d2fonts.FontFamily, fontSize int) blockAttrs { + if fontFamily == nil { + fontFamily = go2.Pointer(d2fonts.SourceSansPro) + } + font := fontFamily.Font(fontSize, d2fonts.FONT_STYLE_REGULAR) + var parentElementType string if n.Parent != nil && n.Parent.Type == html.ElementNode { parentElementType = n.Parent.Data @@ -253,7 +249,8 @@ func (ruler *Ruler) measureNode(depth int, n *html.Node, font d2fonts.Font) bloc isCode := false switch n.Data { case "h1", "h2", "h3", "h4", "h5", "h6": - font = HeaderFonts[n.Data] + fontSize = HeaderToFontSize[n.Data] + font = fontFamily.Font(HeaderToFontSize[n.Data], d2fonts.FONT_STYLE_BOLD) originalLineHeight := ruler.LineHeightFactor ruler.LineHeightFactor = LineHeight_h defer func() { @@ -264,6 +261,7 @@ func (ruler *Ruler) measureNode(depth int, n *html.Node, font d2fonts.Font) bloc case "b", "strong": font.Style = d2fonts.FONT_STYLE_BOLD case "pre", "code": + fontFamily = go2.Pointer(d2fonts.SourceCodePro) font.Family = d2fonts.SourceCodePro font.Style = d2fonts.FONT_STYLE_REGULAR isCode = true @@ -280,7 +278,7 @@ func (ruler *Ruler) measureNode(depth int, n *html.Node, font d2fonts.Font) bloc // first create blocks from combined inline elements, then combine all blocks // current will be non-nil while inline elements are being combined into a block for child := n.FirstChild; child != nil; child = child.NextSibling { - childBlock := ruler.measureNode(depth+1, child, font) + childBlock := ruler.measureNode(depth+1, child, fontFamily, fontSize) if child.Type == html.ElementNode && isBlockElement(child.Data) { if current != nil { @@ -354,7 +352,7 @@ func (ruler *Ruler) measureNode(depth int, n *html.Node, font d2fonts.Font) bloc switch n.Data { case "blockquote": - block.width += (2*PaddingLR_blockquote_em + BorderLeft_blockquote_em) * float64(font.Size) + block.width += (2*PaddingLR_blockquote_em + BorderLeft_blockquote_em) * float64(fontSize) block.marginBottom = go2.Max(block.marginBottom, MarginBottom_blockquote) case "p": if parentElementType == "li" { @@ -366,7 +364,7 @@ func (ruler *Ruler) measureNode(depth int, n *html.Node, font d2fonts.Font) bloc block.marginBottom = go2.Max(block.marginBottom, MarginBottom_h) switch n.Data { case "h1", "h2": - block.height += PaddingBottom_h1_h2_em * float64(font.Size) + block.height += PaddingBottom_h1_h2_em * float64(fontSize) } case "li": block.width += PaddingLeft_ul_ol @@ -386,8 +384,8 @@ func (ruler *Ruler) measureNode(depth int, n *html.Node, font d2fonts.Font) bloc block.marginBottom = go2.Max(block.marginBottom, MarginBottom_pre) case "code": if parentElementType != "pre" { - block.width += 2 * PaddingLeftRight_code_em * float64(font.Size) - block.height += 2 * PaddingTopBottom_code_em * float64(font.Size) + block.width += 2 * PaddingLeftRight_code_em * float64(fontSize) + block.height += 2 * PaddingTopBottom_code_em * float64(fontSize) } case "hr": block.height += Height_hr diff --git a/main.go b/main.go index d4b6b63aa..45d154f1f 100644 --- a/main.go +++ b/main.go @@ -14,10 +14,12 @@ import ( "github.com/spf13/pflag" "go.uber.org/multierr" + "oss.terrastruct.com/util-go/go2" "oss.terrastruct.com/util-go/xmain" "oss.terrastruct.com/d2/d2lib" "oss.terrastruct.com/d2/d2plugin" + "oss.terrastruct.com/d2/d2renderers/d2fonts" "oss.terrastruct.com/d2/d2renderers/d2svg" "oss.terrastruct.com/d2/d2themes" "oss.terrastruct.com/d2/d2themes/d2themescatalog" @@ -210,11 +212,15 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketc } layout := plugin.Layout - diagram, _, err := d2lib.Compile(ctx, string(input), &d2lib.CompileOptions{ + opts := &d2lib.CompileOptions{ Layout: layout, Ruler: ruler, ThemeID: themeID, - }) + } + if sketch { + opts.FontFamily = go2.Pointer(d2fonts.HandDrawn) + } + diagram, _, err := d2lib.Compile(ctx, string(input), opts) if err != nil { return nil, false, err } From 4ccaf4a5789f5fc843e2ac12c87136be6d689281 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 21 Dec 2022 23:57:56 -0800 Subject: [PATCH 157/257] ok --- .../d2sketch/testdata/twitter/sketch.exp.svg | 22 ++++++++++--------- lib/textmeasure/markdown.go | 14 +++++++----- 2 files changed, 21 insertions(+), 15 deletions(-) diff --git a/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg b/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg index 345b29043..26b1ee9fc 100644 --- a/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg @@ -2,7 +2,7 @@ \ No newline at end of file diff --git a/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg b/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg index 26b1ee9fc..471e8fa0a 100644 --- a/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg @@ -809,7 +809,7 @@ width="3454" height="2449" viewBox="-100 -100 3454 2449"> \ No newline at end of file From 1e0d6c294c658adf74363ebf53f7515b859c8ca8 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Thu, 22 Dec 2022 00:42:43 -0800 Subject: [PATCH 160/257] delete --- .../d2sketch/testdata/chess/sketch.exp.svg | 827 ------------------ 1 file changed, 827 deletions(-) delete mode 100644 d2renderers/d2sketch/testdata/chess/sketch.exp.svg diff --git a/d2renderers/d2sketch/testdata/chess/sketch.exp.svg b/d2renderers/d2sketch/testdata/chess/sketch.exp.svg deleted file mode 100644 index c8382de2c..000000000 --- a/d2renderers/d2sketch/testdata/chess/sketch.exp.svg +++ /dev/null @@ -1,827 +0,0 @@ - - - - - - -People discovery serviceAd mixerOnboarding serviceTwitter Frontend WebIphoneAndroidTimelineScorerHome RankerTimeline ServiceHome mixerManhattanGizmoduckSocial graphTweety PiePrediction ServiceHome ScorerManhattanMemcacheFetchFeatureScoringPrediction Service...etc

Timeline mixer

-
    -
  • Inject ads, who-to-follow, onboarding
  • -
  • Conversation module
  • -
  • Cursoring,pagination
  • -
  • Tweat deduplication
  • -
  • Served data logging
  • -
-
GraphQLFederated Strato Column

Tweet/user content hydration, visibility filtering

-
TLS-API (being deprecated)CrMixerEarlyBirdUtagSpaceCommunities iPhone webHTTP AndroidThrift RPC Candidate FetchFeature HydrationCandidate sources - - - - - - - -
\ No newline at end of file From 39cc07475776827b8412b7b6137d6bca7a4afabf Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Thu, 22 Dec 2022 00:45:32 -0800 Subject: [PATCH 161/257] cleanup --- lib/textmeasure/markdown.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/lib/textmeasure/markdown.go b/lib/textmeasure/markdown.go index bb2edd8a3..bf12dc7ab 100644 --- a/lib/textmeasure/markdown.go +++ b/lib/textmeasure/markdown.go @@ -251,23 +251,18 @@ func (ruler *Ruler) measureNode(depth int, n *html.Node, fontFamily *d2fonts.Fon case "h1", "h2", "h3", "h4", "h5", "h6": fontSize = HeaderToFontSize[n.Data] fontStyle = d2fonts.FONT_STYLE_BOLD - font = fontFamily.Font(HeaderToFontSize[n.Data], fontStyle) originalLineHeight := ruler.LineHeightFactor ruler.LineHeightFactor = LineHeight_h defer func() { ruler.LineHeightFactor = originalLineHeight }() case "em": - font.Style = d2fonts.FONT_STYLE_ITALIC fontStyle = d2fonts.FONT_STYLE_ITALIC case "b", "strong": - font.Style = d2fonts.FONT_STYLE_BOLD fontStyle = d2fonts.FONT_STYLE_BOLD case "pre", "code": fontFamily = go2.Pointer(d2fonts.SourceCodePro) fontStyle = d2fonts.FONT_STYLE_REGULAR - font.Family = d2fonts.SourceCodePro - font.Style = d2fonts.FONT_STYLE_REGULAR isCode = true } From 9812ea54fbc674e8d88785f46512ca741c3febd0 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Thu, 22 Dec 2022 00:46:46 -0800 Subject: [PATCH 162/257] test --- lib/textmeasure/textmeasure_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/textmeasure/textmeasure_test.go b/lib/textmeasure/textmeasure_test.go index 476464206..b5d31105e 100644 --- a/lib/textmeasure/textmeasure_test.go +++ b/lib/textmeasure/textmeasure_test.go @@ -110,7 +110,7 @@ func TestTextMeasureMarkdown(t *testing.T) { } for text, dims := range mdTexts { - width, height, err := textmeasure.MeasureMarkdown(text, ruler) + width, height, err := textmeasure.MeasureMarkdown(text, ruler, nil) if err != nil { t.Fatal(err) } From 2f545e3f61342afec6b1ee828201ace3c0dbc5d0 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Thu, 22 Dec 2022 11:06:57 -0800 Subject: [PATCH 163/257] tables --- d2renderers/d2sketch/sketch.go | 170 ++++++++++++++++-- d2renderers/d2sketch/sketch_test.go | 52 ++++++ .../d2sketch/testdata/class/sketch.exp.svg | 55 ++++++ .../testdata/sql_tables/sketch.exp.svg | 75 ++++++++ d2renderers/d2svg/class.go | 7 +- d2renderers/d2svg/d2svg.go | 27 +-- d2renderers/d2svg/table.go | 26 +-- d2target/sqltable.go | 13 ++ lib/svg/text.go | 12 ++ 9 files changed, 386 insertions(+), 51 deletions(-) create mode 100644 d2renderers/d2sketch/testdata/class/sketch.exp.svg create mode 100644 d2renderers/d2sketch/testdata/sql_tables/sketch.exp.svg create mode 100644 lib/svg/text.go diff --git a/d2renderers/d2sketch/sketch.go b/d2renderers/d2sketch/sketch.go index a8b6326b1..cbd696505 100644 --- a/d2renderers/d2sketch/sketch.go +++ b/d2renderers/d2sketch/sketch.go @@ -3,13 +3,17 @@ package d2sketch import ( "encoding/json" "fmt" + "strings" _ "embed" "github.com/dop251/goja" "oss.terrastruct.com/d2/d2target" + "oss.terrastruct.com/d2/lib/geo" + "oss.terrastruct.com/d2/lib/label" "oss.terrastruct.com/d2/lib/svg" + "oss.terrastruct.com/util-go/go2" ) //go:embed fillpattern.svg @@ -81,10 +85,7 @@ func Rect(r *Runner, shape d2target.Shape) (string, error) { strokeWidth: %d, %s });`, shape.Width, shape.Height, shape.Fill, shape.Stroke, shape.StrokeWidth, baseRoughProps) - if _, err := r.run(js); err != nil { - return "", err - } - paths, err := extractPaths(r) + paths, err := computeRoughPaths(r, js) if err != nil { return "", err } @@ -109,10 +110,7 @@ func Oval(r *Runner, shape d2target.Shape) (string, error) { strokeWidth: %d, %s });`, shape.Width/2, shape.Height/2, shape.Width, shape.Height, shape.Fill, shape.Stroke, shape.StrokeWidth, baseRoughProps) - if _, err := r.run(js); err != nil { - return "", err - } - paths, err := extractPaths(r) + paths, err := computeRoughPaths(r, js) if err != nil { return "", err } @@ -140,10 +138,7 @@ func Paths(r *Runner, shape d2target.Shape, paths []string) (string, error) { strokeWidth: %d, %s });`, path, shape.Fill, shape.Stroke, shape.StrokeWidth, baseRoughProps) - if _, err := r.run(js); err != nil { - return "", err - } - sketchPaths, err := extractPaths(r) + sketchPaths, err := computeRoughPaths(r, js) if err != nil { return "", err } @@ -180,10 +175,7 @@ func connectionStyle(connection d2target.Connection) string { func Connection(r *Runner, connection d2target.Connection, path, attrs string) (string, error) { roughness := 1.0 js := fmt.Sprintf(`node = rc.path("%s", {roughness: %f, seed: 1});`, path, roughness) - if _, err := r.run(js); err != nil { - return "", err - } - paths, err := extractPaths(r) + paths, err := computeRoughPaths(r, js) if err != nil { return "", err } @@ -197,6 +189,152 @@ func Connection(r *Runner, connection d2target.Connection, path, attrs string) ( return output, nil } +// TODO cleanup +func Table(r *Runner, shape d2target.Shape) (string, error) { + output := "" + js := fmt.Sprintf(`node = rc.rectangle(0, 0, %d, %d, { + fill: "%s", + stroke: "%s", + strokeWidth: %d, + %s + });`, shape.Width, shape.Height, shape.Fill, shape.Stroke, shape.StrokeWidth, baseRoughProps) + paths, err := computeRoughPaths(r, js) + if err != nil { + return "", err + } + for _, p := range paths { + output += fmt.Sprintf( + ``, + shape.Pos.X, shape.Pos.Y, p, shapeStyle(shape), + ) + } + + box := geo.NewBox( + geo.NewPoint(float64(shape.Pos.X), float64(shape.Pos.Y)), + float64(shape.Width), + float64(shape.Height), + ) + rowHeight := box.Height / float64(1+len(shape.SQLTable.Columns)) + headerBox := geo.NewBox(box.TopLeft, box.Width, rowHeight) + + js = fmt.Sprintf(`node = rc.rectangle(0, 0, %d, %f, { + fill: "%s", + %s + });`, shape.Width, rowHeight, shape.Fill, baseRoughProps) + paths, err = computeRoughPaths(r, js) + if err != nil { + return "", err + } + for _, p := range paths { + // TODO header fill + output += fmt.Sprintf( + ``, + shape.Pos.X, shape.Pos.Y, p, "#0a0f25", + ) + } + + if shape.Label != "" { + tl := label.InsideMiddleLeft.GetPointOnBox( + headerBox, + 20, + float64(shape.LabelWidth), + float64(shape.LabelHeight), + ) + + // TODO header font color + output += fmt.Sprintf(`%s`, + "text", + tl.X, + tl.Y+float64(shape.LabelHeight)*3/4, + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", + "start", + 4+shape.FontSize, + "white", + ), + svg.EscapeText(shape.Label), + ) + } + + var longestNameWidth int + for _, f := range shape.Columns { + longestNameWidth = go2.Max(longestNameWidth, f.Name.LabelWidth) + } + + rowBox := geo.NewBox(box.TopLeft.Copy(), box.Width, rowHeight) + rowBox.TopLeft.Y += headerBox.Height + for _, f := range shape.Columns { + nameTL := label.InsideMiddleLeft.GetPointOnBox( + rowBox, + d2target.NamePadding, + rowBox.Width, + float64(shape.FontSize), + ) + constraintTR := label.InsideMiddleRight.GetPointOnBox( + rowBox, + d2target.TypePadding, + 0, + float64(shape.FontSize), + ) + + // TODO theme based + primaryColor := "rgb(13, 50, 178)" + accentColor := "rgb(74, 111, 243)" + neutralColor := "rgb(103, 108, 126)" + + output += strings.Join([]string{ + fmt.Sprintf(`%s`, + nameTL.X, + nameTL.Y+float64(shape.FontSize)*3/4, + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", float64(shape.FontSize), primaryColor), + svg.EscapeText(f.Name.Label), + ), + + // TODO light font + fmt.Sprintf(`%s`, + nameTL.X+float64(longestNameWidth)+2*d2target.NamePadding, + nameTL.Y+float64(shape.FontSize)*3/4, + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", float64(shape.FontSize), neutralColor), + svg.EscapeText(f.Type.Label), + ), + + fmt.Sprintf(`%s`, + constraintTR.X, + constraintTR.Y+float64(shape.FontSize)*3/4, + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s;letter-spacing:2px;", "end", float64(shape.FontSize), accentColor), + f.ConstraintAbbr(), + ), + }, "\n") + + rowBox.TopLeft.Y += rowHeight + + js = fmt.Sprintf(`node = rc.line(%f, %f, %f, %f, { + %s + });`, rowBox.TopLeft.X, rowBox.TopLeft.Y, rowBox.TopLeft.X+rowBox.Width, rowBox.TopLeft.Y, baseRoughProps) + paths, err = computeRoughPaths(r, js) + if err != nil { + return "", err + } + for _, p := range paths { + output += fmt.Sprintf( + ``, + p, "#0a0f25", + ) + } + } + output += fmt.Sprintf( + ``, + shape.Pos.X, shape.Pos.Y, shape.Width, shape.Height, + ) + return output, nil +} + +func computeRoughPaths(r *Runner, js string) ([]string, error) { + if _, err := r.run(js); err != nil { + return nil, err + } + return extractPaths(r) +} + type attrs struct { D string `json:"d"` } diff --git a/d2renderers/d2sketch/sketch_test.go b/d2renderers/d2sketch/sketch_test.go index cfcb5abdb..87a2e17a2 100644 --- a/d2renderers/d2sketch/sketch_test.go +++ b/d2renderers/d2sketch/sketch_test.go @@ -223,6 +223,58 @@ queue -> package -> step callout -> stored_data -> person diamond -> oval -> circle hexagon -> cloud +`, + }, + { + name: "sql_tables", + script: `users: { + shape: sql_table + id: int + name: string + email: string + password: string + last_login: datetime +} + +products: { + shape: sql_table + id: int + price: decimal + sku: string + name: string +} + +orders: { + shape: sql_table + id: int + user_id: int + product_id: int +} + +shipments: { + shape: sql_table + id: int + order_id: int + tracking_number: string + status: string +} + +users.id <-> orders.user_id +products.id <-> orders.product_id +shipments.order_id <-> orders.id`, + }, + { + name: "class", + script: `manager: BatchManager { + shape: class + -num: int + -timeout: int + -pid + + +getStatus(): Enum + +getJobs(): "Job[]" + +setTimeout(seconds int) +} `, }, } diff --git a/d2renderers/d2sketch/testdata/class/sketch.exp.svg b/d2renderers/d2sketch/testdata/class/sketch.exp.svg new file mode 100644 index 000000000..6c8175350 --- /dev/null +++ b/d2renderers/d2sketch/testdata/class/sketch.exp.svg @@ -0,0 +1,55 @@ + + + + + + +BatchManager- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +void + + + \ No newline at end of file diff --git a/d2renderers/d2sketch/testdata/sql_tables/sketch.exp.svg b/d2renderers/d2sketch/testdata/sql_tables/sketch.exp.svg new file mode 100644 index 000000000..5509ac7ab --- /dev/null +++ b/d2renderers/d2sketch/testdata/sql_tables/sketch.exp.svg @@ -0,0 +1,75 @@ + + + + + + +usersid +int +name +string +email +string +password +string +last_login +datetime +productsid +int +price +decimal +sku +string +name +string +ordersid +int +user_id +int +product_id +int +shipmentsid +int +order_id +int +tracking_number +string +status +string + + + + \ No newline at end of file diff --git a/d2renderers/d2svg/class.go b/d2renderers/d2svg/class.go index af71ac1af..64ac62bab 100644 --- a/d2renderers/d2svg/class.go +++ b/d2renderers/d2svg/class.go @@ -8,6 +8,7 @@ import ( "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/label" + "oss.terrastruct.com/d2/lib/svg" ) func classHeader(box *geo.Box, text string, textWidth, textHeight, fontSize float64) string { @@ -32,7 +33,7 @@ func classHeader(box *geo.Box, text string, textWidth, textHeight, fontSize floa 4+fontSize, "white", ), - escapeText(text), + svg.EscapeText(text), ) } return str @@ -73,14 +74,14 @@ func classRow(box *geo.Box, prefix, nameText, typeText string, fontSize float64) prefixTL.X+prefixWidth, prefixTL.Y+fontSize*3/4, fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, "black"), - escapeText(nameText), + svg.EscapeText(nameText), ), fmt.Sprintf(`%s`, typeTR.X, typeTR.Y+fontSize*3/4, fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "end", fontSize, accentColor), - escapeText(typeText), + svg.EscapeText(typeText), ), }, "\n") } diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 7bd081068..896d1178e 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -5,7 +5,6 @@ package d2svg import ( "bytes" _ "embed" - "encoding/xml" "errors" "fmt" "hash/fnv" @@ -357,7 +356,7 @@ func makeLabelMask(labelTL *geo.Point, width, height int) string { } func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Connection, markers map[string]struct{}, idToShape map[string]d2target.Shape, sketchRunner *d2sketch.Runner) (labelMask string, _ error) { - fmt.Fprintf(writer, ``, escapeText(connection.ID)) + fmt.Fprintf(writer, ``, svg.EscapeText(connection.ID)) var markerStart string if connection.SrcArrow != d2target.NoArrowhead { id := arrowheadMarkerID(false, connection) @@ -536,7 +535,7 @@ func render3dRect(targetShape d2target.Shape) string { strings.Join(borderSegments, " "), borderStyle) // create mask from border stroke, to cut away from the shape fills - maskID := fmt.Sprintf("border-mask-%v", escapeText(targetShape.ID)) + maskID := fmt.Sprintf("border-mask-%v", svg.EscapeText(targetShape.ID)) borderMask := strings.Join([]string{ fmt.Sprintf(``, maskID, targetShape.Pos.X, targetShape.Pos.Y-threeDeeOffset, targetShape.Width+threeDeeOffset, targetShape.Height+threeDeeOffset, @@ -583,7 +582,7 @@ func render3dRect(targetShape d2target.Shape) string { } func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2sketch.Runner) (labelMask string, err error) { - fmt.Fprintf(writer, ``, escapeText(targetShape.ID)) + fmt.Fprintf(writer, ``, svg.EscapeText(targetShape.ID)) tl := geo.NewPoint(float64(targetShape.Pos.X), float64(targetShape.Pos.Y)) width := float64(targetShape.Width) height := float64(targetShape.Height) @@ -622,7 +621,15 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske fmt.Fprintf(writer, ``) return labelMask, nil case d2target.ShapeSQLTable: - drawTable(writer, targetShape) + if sketchRunner != nil { + out, err := d2sketch.Table(sketchRunner, targetShape) + if err != nil { + return "", err + } + fmt.Fprintf(writer, out) + } else { + drawTable(writer, targetShape) + } fmt.Fprintf(writer, ``) return labelMask, nil case d2target.ShapeOval: @@ -823,15 +830,9 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske return labelMask, nil } -func escapeText(text string) string { - buf := new(bytes.Buffer) - _ = xml.EscapeText(buf, []byte(text)) - return buf.String() -} - func renderText(text string, x, height float64) string { if !strings.Contains(text, "\n") { - return escapeText(text) + return svg.EscapeText(text) } rendered := []string{} lines := strings.Split(text, "\n") @@ -840,7 +841,7 @@ func renderText(text string, x, height float64) string { if i == 0 { dy = 0 } - escaped := escapeText(line) + escaped := svg.EscapeText(line) if escaped == "" { // if there are multiple newlines in a row we still need text for the tspan to render escaped = " " diff --git a/d2renderers/d2svg/table.go b/d2renderers/d2svg/table.go index 9407c0b82..5b4abaed9 100644 --- a/d2renderers/d2svg/table.go +++ b/d2renderers/d2svg/table.go @@ -8,6 +8,7 @@ import ( "oss.terrastruct.com/d2/d2target" "oss.terrastruct.com/d2/lib/geo" "oss.terrastruct.com/d2/lib/label" + "oss.terrastruct.com/d2/lib/svg" "oss.terrastruct.com/util-go/go2" ) @@ -32,7 +33,7 @@ func tableHeader(box *geo.Box, text string, textWidth, textHeight, fontSize floa 4+fontSize, "white", ), - escapeText(text), + svg.EscapeText(text), ) } return str @@ -64,7 +65,7 @@ func tableRow(box *geo.Box, nameText, typeText, constraintText string, fontSize, nameTL.X, nameTL.Y+fontSize*3/4, fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, primaryColor), - escapeText(nameText), + svg.EscapeText(nameText), ), // TODO light font @@ -72,7 +73,7 @@ func tableRow(box *geo.Box, nameText, typeText, constraintText string, fontSize, nameTL.X+longestNameWidth+2*d2target.NamePadding, nameTL.Y+fontSize*3/4, fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, neutralColor), - escapeText(typeText), + svg.EscapeText(typeText), ), fmt.Sprintf(`%s`, @@ -84,19 +85,6 @@ func tableRow(box *geo.Box, nameText, typeText, constraintText string, fontSize, }, "\n") } -func constraintAbbr(constraint string) string { - switch constraint { - case "primary_key": - return "PK" - case "foreign_key": - return "FK" - case "unique": - return "UNQ" - default: - return "" - } -} - func drawTable(writer io.Writer, targetShape d2target.Shape) { fmt.Fprintf(writer, ``, targetShape.Pos.X, targetShape.Pos.Y, targetShape.Width, targetShape.Height, shapeStyle(targetShape)) @@ -114,15 +102,15 @@ func drawTable(writer io.Writer, targetShape d2target.Shape) { ) var longestNameWidth int - for _, f := range targetShape.SQLTable.Columns { + for _, f := range targetShape.Columns { longestNameWidth = go2.Max(longestNameWidth, f.Name.LabelWidth) } rowBox := geo.NewBox(box.TopLeft.Copy(), box.Width, rowHeight) rowBox.TopLeft.Y += headerBox.Height - for _, f := range targetShape.SQLTable.Columns { + for _, f := range targetShape.Columns { fmt.Fprint(writer, - tableRow(rowBox, f.Name.Label, f.Type.Label, constraintAbbr(f.Constraint), float64(targetShape.FontSize), float64(longestNameWidth)), + tableRow(rowBox, f.Name.Label, f.Type.Label, f.ConstraintAbbr(), float64(targetShape.FontSize), float64(longestNameWidth)), ) rowBox.TopLeft.Y += rowHeight fmt.Fprintf(writer, ``, diff --git a/d2target/sqltable.go b/d2target/sqltable.go index 8642e77a0..ad6b6f61b 100644 --- a/d2target/sqltable.go +++ b/d2target/sqltable.go @@ -31,3 +31,16 @@ func (c SQLColumn) Text() *MText { Shape: "sql_table", } } + +func (c SQLColumn) ConstraintAbbr() string { + switch c.Constraint { + case "primary_key": + return "PK" + case "foreign_key": + return "FK" + case "unique": + return "UNQ" + default: + return "" + } +} diff --git a/lib/svg/text.go b/lib/svg/text.go new file mode 100644 index 000000000..a729d5675 --- /dev/null +++ b/lib/svg/text.go @@ -0,0 +1,12 @@ +package svg + +import ( + "bytes" + "encoding/xml" +) + +func EscapeText(text string) string { + buf := new(bytes.Buffer) + _ = xml.EscapeText(buf, []byte(text)) + return buf.String() +} From c828d2c8251374ebb510e41c6384a77999c907da Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Thu, 22 Dec 2022 11:32:41 -0800 Subject: [PATCH 164/257] classes --- d2renderers/d2sketch/sketch.go | 143 ++++++++++++++++++ .../d2sketch/testdata/class/sketch.exp.svg | 14 +- d2renderers/d2svg/class.go | 31 +--- d2renderers/d2svg/d2svg.go | 10 +- d2target/class.go | 27 ++++ 5 files changed, 193 insertions(+), 32 deletions(-) diff --git a/d2renderers/d2sketch/sketch.go b/d2renderers/d2sketch/sketch.go index cbd696505..ea3eb941c 100644 --- a/d2renderers/d2sketch/sketch.go +++ b/d2renderers/d2sketch/sketch.go @@ -328,6 +328,149 @@ func Table(r *Runner, shape d2target.Shape) (string, error) { return output, nil } +func Class(r *Runner, shape d2target.Shape) (string, error) { + output := "" + js := fmt.Sprintf(`node = rc.rectangle(0, 0, %d, %d, { + fill: "%s", + stroke: "%s", + strokeWidth: %d, + %s + });`, shape.Width, shape.Height, shape.Fill, shape.Stroke, shape.StrokeWidth, baseRoughProps) + paths, err := computeRoughPaths(r, js) + if err != nil { + return "", err + } + for _, p := range paths { + output += fmt.Sprintf( + ``, + shape.Pos.X, shape.Pos.Y, p, shapeStyle(shape), + ) + } + + box := geo.NewBox( + geo.NewPoint(float64(shape.Pos.X), float64(shape.Pos.Y)), + float64(shape.Width), + float64(shape.Height), + ) + + rowHeight := box.Height / float64(2+len(shape.Class.Fields)+len(shape.Class.Methods)) + headerBox := geo.NewBox(box.TopLeft, box.Width, 2*rowHeight) + + js = fmt.Sprintf(`node = rc.rectangle(0, 0, %d, %f, { + fill: "%s", + %s + });`, shape.Width, headerBox.Height, shape.Fill, baseRoughProps) + paths, err = computeRoughPaths(r, js) + if err != nil { + return "", err + } + for _, p := range paths { + // TODO header fill + output += fmt.Sprintf( + ``, + shape.Pos.X, shape.Pos.Y, p, "#0a0f25", + ) + } + + output += fmt.Sprintf( + ``, + shape.Pos.X, shape.Pos.Y, shape.Width, headerBox.Height, + ) + + if shape.Label != "" { + tl := label.InsideMiddleLeft.GetPointOnBox( + headerBox, + 0, + float64(shape.LabelWidth), + float64(shape.LabelHeight), + ) + + // TODO header font color + output += fmt.Sprintf(`%s`, + "text", + tl.X+float64(shape.LabelWidth)/2, + tl.Y+float64(shape.LabelHeight)*3/4, + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", + "middle", + 4+shape.FontSize, + "white", + ), + svg.EscapeText(shape.Label), + ) + } + + rowBox := geo.NewBox(box.TopLeft.Copy(), box.Width, rowHeight) + rowBox.TopLeft.Y += headerBox.Height + for _, f := range shape.Fields { + output += classRow(rowBox, f.VisibilityToken(), f.Name, f.Type, float64(shape.FontSize)) + rowBox.TopLeft.Y += rowHeight + } + + js = fmt.Sprintf(`node = rc.line(%f, %f, %f, %f, { +%s + });`, rowBox.TopLeft.X, rowBox.TopLeft.Y, rowBox.TopLeft.X+rowBox.Width, rowBox.TopLeft.Y, baseRoughProps) + paths, err = computeRoughPaths(r, js) + if err != nil { + return "", err + } + for _, p := range paths { + output += fmt.Sprintf( + ``, + p, "#0a0f25", + ) + } + + for _, m := range shape.Methods { + output += classRow(rowBox, m.VisibilityToken(), m.Name, m.Return, float64(shape.FontSize)) + rowBox.TopLeft.Y += rowHeight + } + + return output, nil +} + +func classRow(box *geo.Box, prefix, nameText, typeText string, fontSize float64) string { + output := "" + prefixTL := label.InsideMiddleLeft.GetPointOnBox( + box, + d2target.PrefixPadding, + box.Width, + fontSize, + ) + typeTR := label.InsideMiddleRight.GetPointOnBox( + box, + d2target.TypePadding, + 0, + fontSize, + ) + + // TODO theme based + accentColor := "rgb(13, 50, 178)" + + output += strings.Join([]string{ + fmt.Sprintf(`%s`, + prefixTL.X, + prefixTL.Y+fontSize*3/4, + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, accentColor), + prefix, + ), + + fmt.Sprintf(`%s`, + prefixTL.X+d2target.PrefixWidth, + prefixTL.Y+fontSize*3/4, + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, "black"), + svg.EscapeText(nameText), + ), + + fmt.Sprintf(`%s`, + typeTR.X, + typeTR.Y+fontSize*3/4, + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s;", "end", fontSize, accentColor), + svg.EscapeText(typeText), + ), + }, "\n") + return output +} + func computeRoughPaths(r *Runner, js string) ([]string, error) { if _, err := r.run(js); err != nil { return nil, err diff --git a/d2renderers/d2sketch/testdata/class/sketch.exp.svg b/d2renderers/d2sketch/testdata/class/sketch.exp.svg index 6c8175350..ed2b21d25 100644 --- a/d2renderers/d2sketch/testdata/class/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/class/sketch.exp.svg @@ -30,19 +30,19 @@ width="553" height="584" viewBox="-100 -100 553 584">abcdggggroup 1group bchoonested guy lalaeyokayokaywhat would arnold saythis note +abcdggggroup 1group bchoonested guy lalaeyokayokaywhat would arnold saythis note - - - - - + + + + + diff --git a/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json index 270198f16..776b8ddfb 100644 --- a/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_groups/elk/board.exp.json @@ -198,6 +198,7 @@ "underline": false, "labelWidth": 30, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 1 }, @@ -237,6 +238,7 @@ "underline": false, "labelWidth": 57, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 1 }, @@ -276,6 +278,7 @@ "underline": false, "labelWidth": 78, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 2 }, @@ -315,6 +318,7 @@ "underline": false, "labelWidth": 58, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 1 }, @@ -394,6 +398,7 @@ "underline": false, "labelWidth": 38, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 1 }, diff --git a/e2etests/testdata/stable/sequence_diagram_groups/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_groups/elk/sketch.exp.svg index 0afcfd18a..d3ed45a1a 100644 --- a/e2etests/testdata/stable/sequence_diagram_groups/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_groups/elk/sketch.exp.svg @@ -18,13 +18,13 @@ width="1147" height="2268" viewBox="-76 -26 1147 2268">abcdggggroup 1group bchoonested guy lalaeyokayokaywhat would arnold saythis note +abcdggggroup 1group bchoonested guy lalaeyokayokaywhat would arnold saythis note - - - - - + + + + + diff --git a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json index 21f56fb8a..772cc63c2 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/board.exp.json @@ -158,6 +158,7 @@ "underline": false, "labelWidth": 160, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 1 }, @@ -197,6 +198,7 @@ "underline": false, "labelWidth": 238, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 2 }, @@ -236,6 +238,7 @@ "underline": false, "labelWidth": 173, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 3 }, @@ -275,6 +278,7 @@ "underline": false, "labelWidth": 77, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 4 }, @@ -354,6 +358,7 @@ "underline": false, "labelWidth": 41, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 5 }, @@ -393,6 +398,7 @@ "underline": false, "labelWidth": 24, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 1 }, @@ -432,6 +438,7 @@ "underline": false, "labelWidth": 47, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 2 }, @@ -471,6 +478,7 @@ "underline": false, "labelWidth": 47, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 2 }, @@ -510,6 +518,7 @@ "underline": false, "labelWidth": 47, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 2 }, @@ -549,6 +558,7 @@ "underline": false, "labelWidth": 47, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 2 }, diff --git a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/sketch.exp.svg index 0dbb0afaa..48b328e86 100644 --- a/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_nested_groups/dagre/sketch.exp.svg @@ -18,18 +18,18 @@ width="1116" height="2458" viewBox="-197 -26 1116 2458">abjust an actorthis is a message groupaltand this is a nested message groupcase 1case 2case 3case 4what about more nestingcrazy townwhoa a notea note here to remember that padding must consider notes toojustalongnotehere +abjust an actorthis is a message groupaltand this is a nested message groupcase 1case 2case 3case 4what about more nestingcrazy townwhoa a notea note here to remember that padding must consider notes toojustalongnotehere - - - - - - - - - - + + + + + + + + + + abjust an actorthis is a message groupaltand this is a nested message groupcase 1case 2case 3case 4what about more nestingcrazy townwhoa a notea note here to remember that padding must consider notes toojustalongnotehere +abjust an actorthis is a message groupaltand this is a nested message groupcase 1case 2case 3case 4what about more nestingcrazy townwhoa a notea note here to remember that padding must consider notes toojustalongnotehere - - - - - - - - - - + + + + + + + + + + How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place +How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place - + diff --git a/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json index d20a6d846..3945edf3f 100644 --- a/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_real/elk/board.exp.json @@ -478,6 +478,7 @@ "underline": false, "labelWidth": 185, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 2 }, diff --git a/e2etests/testdata/stable/sequence_diagram_real/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_real/elk/sketch.exp.svg index 364fb5549..5f4dd359a 100644 --- a/e2etests/testdata/stable/sequence_diagram_real/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_real/elk/sketch.exp.svg @@ -18,9 +18,9 @@ width="2447" height="2536" viewBox="-88 -88 2447 2536">How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place +How this is renderedCLId2astd2compilerd2layoutd2exporterd2themesd2rendererd2sequencelayoutd2dagrelayoutonly if root is not sequence 'How this is rendered: {...}'tokenized ASTcompile ASTobjects and edgesrun layout enginesrun engine on shape: sequence_diagram, temporarily removerun core engine on rest add back in sequence diagramsdiagram with correct positions and dimensionsexport diagram with chosen theme and rendererget theme stylesrender to SVGresulting SVGmeasurements also take place - + diff --git a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json index c0f384c07..d20401f87 100644 --- a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json +++ b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/board.exp.json @@ -158,6 +158,7 @@ "underline": false, "labelWidth": 160, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 1 }, @@ -197,6 +198,7 @@ "underline": false, "labelWidth": 238, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 2 }, @@ -236,6 +238,7 @@ "underline": false, "labelWidth": 173, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 3 }, @@ -275,6 +278,7 @@ "underline": false, "labelWidth": 21, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 4 }, @@ -314,6 +318,7 @@ "underline": false, "labelWidth": 21, "labelHeight": 26, + "labelPosition": "INSIDE_TOP_LEFT", "zIndex": 3, "level": 5 } diff --git a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/sketch.exp.svg b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/sketch.exp.svg index 288cab1f2..5bcd47f78 100644 --- a/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/sketch.exp.svg +++ b/e2etests/testdata/todo/sequence_diagram_actor_padding_nested_groups/dagre/sketch.exp.svg @@ -18,13 +18,13 @@ width="921" height="1242" viewBox="-147 -26 921 1242">bacthis is a message groupand this is a nested message groupwhat about more nestingyoyo +bacthis is a message groupand this is a nested message groupwhat about more nestingyoyo - - - - - + + + + + bacthis is a message groupand this is a nested message groupwhat about more nestingyoyo +bacthis is a message groupand this is a nested message groupwhat about more nestingyoyo - - - - - + + + + + my network + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/query_param_escape/elk/board.exp.json b/e2etests/testdata/regression/query_param_escape/elk/board.exp.json new file mode 100644 index 000000000..bce062b6f --- /dev/null +++ b/e2etests/testdata/regression/query_param_escape/elk/board.exp.json @@ -0,0 +1,58 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "my network", + "type": "", + "pos": { + "x": 12, + "y": 12 + }, + "width": 190, + "height": 152, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/infra/019-network.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "fuga=1&hoge", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "my network", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 90, + "labelHeight": 26, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/regression/query_param_escape/elk/sketch.exp.svg b/e2etests/testdata/regression/query_param_escape/elk/sketch.exp.svg new file mode 100644 index 000000000..0a13f7b0b --- /dev/null +++ b/e2etests/testdata/regression/query_param_escape/elk/sketch.exp.svg @@ -0,0 +1,31 @@ + +my network + + + \ No newline at end of file From 0fa4ee84aa5b8ca5be3689204f49d951343792aa Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 24 Dec 2022 12:47:25 -0800 Subject: [PATCH 179/257] changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index dded33175..f96223703 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -16,5 +16,6 @@ - Fixed an issue where text could overflow in sql_table shapes. [#458](https://github.com/terrastruct/d2/pull/458) - Fixed an issue with elk layouts accounting for edge labels as if they were placed on the side of the edge. [#483](https://github.com/terrastruct/d2/pull/483) - Fixed an issue where dagre layouts may not have enough spacing for all edge labels. [#484](https://github.com/terrastruct/d2/pull/484) +- Icons with query parameters are now being escaped to valid SVG XML. [#438](https://github.com/terrastruct/d2/issues/438) - Fixed connections being clipped if they were at the very top or left edges of the diagram. [#493](https://github.com/terrastruct/d2/pull/493) - Fixed edge case where style being defined in same scope as sql_table caused compiler to skip compiling sql_table. [#506](https://github.com/terrastruct/d2/issues/506) From 3a6834662dca19902d342185181d9846c62f087b Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 24 Dec 2022 13:11:45 -0800 Subject: [PATCH 180/257] fix sql constraint array panic --- d2compiler/compile.go | 4 ++++ d2compiler/compile_test.go | 10 ++++++++++ testdata/d2compiler/TestCompile/sql-panic.exp.json | 12 ++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 testdata/d2compiler/TestCompile/sql-panic.exp.json diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 819dae9e3..9ca656098 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -688,6 +688,10 @@ func (c *compiler) compileSQLTable(obj *d2graph.Object) { continue } if n.MapKey.Key.Path[0].Unbox().ScalarString() == "constraint" { + if n.MapKey.Value.StringBox().Unbox() == nil { + c.errorf(n.MapKey.GetRange().Start, n.MapKey.GetRange().End, "constraint value must be a string") + return + } d2Col.Constraint = n.MapKey.Value.StringBox().Unbox().ScalarString() } } diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index 4009aa68b..afe9ceec4 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -1668,6 +1668,16 @@ choo: { tassert.Equal(t, 3, len(g.Objects)) }, }, + { + name: "sql-panic", + text: `test { + shape: sql_table + test_id: varchar(64) {constraint: [primary_key, foreign_key]} +} +`, + expErr: `d2/testdata/d2compiler/TestCompile/sql-panic.d2:3:27: constraint value must be a string +`, + }, } for _, tc := range testCases { diff --git a/testdata/d2compiler/TestCompile/sql-panic.exp.json b/testdata/d2compiler/TestCompile/sql-panic.exp.json new file mode 100644 index 000000000..c65b828a6 --- /dev/null +++ b/testdata/d2compiler/TestCompile/sql-panic.exp.json @@ -0,0 +1,12 @@ +{ + "graph": null, + "err": { + "ioerr": null, + "errs": [ + { + "range": "d2/testdata/d2compiler/TestCompile/sql-panic.d2,2:26:54-2:64:92", + "errmsg": "d2/testdata/d2compiler/TestCompile/sql-panic.d2:3:27: constraint value must be a string" + } + ] + } +} From fb2e0827d33cb635aeb5b8317b55f49909c8a1d5 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 24 Dec 2022 13:12:53 -0800 Subject: [PATCH 181/257] changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index f96223703..0f99d4538 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -19,3 +19,4 @@ - Icons with query parameters are now being escaped to valid SVG XML. [#438](https://github.com/terrastruct/d2/issues/438) - Fixed connections being clipped if they were at the very top or left edges of the diagram. [#493](https://github.com/terrastruct/d2/pull/493) - Fixed edge case where style being defined in same scope as sql_table caused compiler to skip compiling sql_table. [#506](https://github.com/terrastruct/d2/issues/506) +- Fixed panic when `constraint` value was not a string value. [#248](https://github.com/terrastruct/d2/issues/248) From 03e27abb5429155b5d4653ee3d235841fbbbe7c3 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 24 Dec 2022 13:34:23 -0800 Subject: [PATCH 182/257] elk force order --- d2layouts/d2elklayout/layout.go | 32 +- e2etests/regression_test.go | 37 + .../dagre_special_ids/elk/board.exp.json | 34 +- .../dagre_special_ids/elk/sketch.exp.svg | 2 +- .../elk_alignment/elk/board.exp.json | 60 +- .../elk_alignment/elk/sketch.exp.svg | 18 +- .../regression/elk_order/dagre/board.exp.json | 675 ++++++ .../regression/elk_order/dagre/sketch.exp.svg | 799 +++++++ .../regression/elk_order/elk/board.exp.json | 639 ++++++ .../regression/elk_order/elk/sketch.exp.svg | 799 +++++++ .../stable/all_shapes/elk/board.exp.json | 78 +- .../stable/all_shapes/elk/sketch.exp.svg | 6 +- .../all_shapes_multiple/elk/board.exp.json | 78 +- .../all_shapes_multiple/elk/sketch.exp.svg | 6 +- .../all_shapes_shadow/elk/board.exp.json | 78 +- .../all_shapes_shadow/elk/sketch.exp.svg | 6 +- .../stable/binary_tree/elk/board.exp.json | 150 +- .../stable/binary_tree/elk/sketch.exp.svg | 2 +- .../testdata/stable/chaos2/elk/board.exp.json | 236 +- .../testdata/stable/chaos2/elk/sketch.exp.svg | 28 +- .../testdata/stable/dense/elk/board.exp.json | 404 ++-- .../testdata/stable/dense/elk/sketch.exp.svg | 6 +- .../different_subgraphs/elk/board.exp.json | 164 +- .../different_subgraphs/elk/sketch.exp.svg | 6 +- .../stable/font_sizes/elk/board.exp.json | 36 +- .../stable/font_sizes/elk/sketch.exp.svg | 12 +- .../stable/investigate/elk/board.exp.json | 392 ++-- .../stable/investigate/elk/sketch.exp.svg | 18 +- .../stable/large_arch/elk/board.exp.json | 324 ++- .../stable/large_arch/elk/sketch.exp.svg | 6 +- .../testdata/stable/latex/elk/board.exp.json | 60 +- .../testdata/stable/latex/elk/sketch.exp.svg | 4 +- .../stable/multiple_trees/elk/board.exp.json | 226 +- .../stable/multiple_trees/elk/sketch.exp.svg | 6 +- .../stable/n22_e32/elk/board.exp.json | 412 ++-- .../stable/n22_e32/elk/sketch.exp.svg | 6 +- .../one_container_loop/elk/board.exp.json | 58 +- .../one_container_loop/elk/sketch.exp.svg | 2 +- .../elk/board.exp.json | 44 +- .../elk/sketch.exp.svg | 2 +- .../self-referencing/elk/board.exp.json | 54 +- .../self-referencing/elk/sketch.exp.svg | 8 +- .../stable/sql_tables/elk/board.exp.json | 28 +- .../stable/sql_tables/elk/sketch.exp.svg | 66 +- .../elk/board.exp.json | 214 +- .../elk/sketch.exp.svg | 6 +- .../testdata/stable/us_map/elk/board.exp.json | 1900 ++++++++--------- .../testdata/stable/us_map/elk/sketch.exp.svg | 6 +- 48 files changed, 5589 insertions(+), 2644 deletions(-) create mode 100644 e2etests/testdata/regression/elk_order/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/elk_order/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/elk_order/elk/board.exp.json create mode 100644 e2etests/testdata/regression/elk_order/elk/sketch.exp.svg diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index be40c6bff..18dd392f7 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -79,14 +79,16 @@ type ELKGraph struct { } type ELKLayoutOptions struct { - Algorithm string `json:"elk.algorithm,omitempty"` - HierarchyHandling string `json:"elk.hierarchyHandling,omitempty"` - NodeSpacing float64 `json:"spacing.nodeNodeBetweenLayers,omitempty"` - Padding string `json:"elk.padding,omitempty"` - EdgeNodeSpacing float64 `json:"spacing.edgeNodeBetweenLayers,omitempty"` - Direction string `json:"elk.direction"` - SelfLoopSpacing float64 `json:"elk.spacing.nodeSelfLoop"` - InlineEdgeLabels bool `json:"elk.edgeLabels.inline,omitempty"` + Algorithm string `json:"elk.algorithm,omitempty"` + HierarchyHandling string `json:"elk.hierarchyHandling,omitempty"` + NodeSpacing float64 `json:"spacing.nodeNodeBetweenLayers,omitempty"` + Padding string `json:"elk.padding,omitempty"` + EdgeNodeSpacing float64 `json:"spacing.edgeNodeBetweenLayers,omitempty"` + Direction string `json:"elk.direction"` + SelfLoopSpacing float64 `json:"elk.spacing.nodeSelfLoop"` + InlineEdgeLabels bool `json:"elk.edgeLabels.inline,omitempty"` + ConsiderModelOrder string `json:"elk.layered.considerModelOrder.strategy,omitempty"` + ForceNodeModelOrder bool `json:"elk.layered.crossingMinimization.forceNodeModelOrder,omitempty"` } func Layout(ctx context.Context, g *d2graph.Graph) (err error) { @@ -109,11 +111,12 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) { elkGraph := &ELKGraph{ ID: "root", LayoutOptions: &ELKLayoutOptions{ - Algorithm: "layered", - HierarchyHandling: "INCLUDE_CHILDREN", - NodeSpacing: 100.0, - EdgeNodeSpacing: 50.0, - SelfLoopSpacing: 50.0, + Algorithm: "layered", + HierarchyHandling: "INCLUDE_CHILDREN", + NodeSpacing: 100.0, + EdgeNodeSpacing: 50.0, + SelfLoopSpacing: 50.0, + ConsiderModelOrder: "NODES_AND_EDGES", }, } switch g.Root.Attributes.Direction.Value { @@ -157,7 +160,8 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) { if len(obj.ChildrenArray) > 0 { n.LayoutOptions = &ELKLayoutOptions{ - Padding: "[top=75,left=75,bottom=75,right=75]", + Padding: "[top=75,left=75,bottom=75,right=75]", + ForceNodeModelOrder: true, } } diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index 966e03af2..d3fe777b6 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -178,6 +178,43 @@ build_workflow: lambda-build.yaml { script: `my network: { icon: https://icons.terrastruct.com/infra/019-network.svg?fuga=1&hoge } +`, + }, + { + name: "elk_order", + script: `queue: { + shape: queue + label: '' + + M0 + M1 + M2 + M3 + M4 + M5 + M6 +} + +m0_desc: |md + Oldest message +| +m0_desc -> queue.M0 + +m2_desc: |md + Offset +| +m2_desc -> queue.M2 + +m5_desc: |md + Last message +| +m5_desc -> queue.M5 + +m6_desc: |md + Next message will be\ + inserted here +| +m6_desc -> queue.M6 `, }, } diff --git a/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json b/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json index bd21d8cc7..d74b1feb5 100644 --- a/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json +++ b/e2etests/testdata/regression/dagre_special_ids/elk/board.exp.json @@ -6,7 +6,7 @@ "id": "\"ninety\\nnine\"", "type": "", "pos": { - "x": 714, + "x": 12, "y": 12 }, "width": 151, @@ -46,7 +46,7 @@ "id": "eighty\reight", "type": "", "pos": { - "x": 194, + "x": 183, "y": 20 }, "width": 151, @@ -86,7 +86,7 @@ "id": "\"seventy\r\\nseven\"", "type": "", "pos": { - "x": 12, + "x": 354, "y": 12 }, "width": 162, @@ -126,7 +126,7 @@ "id": "\"a\\\\yode\"", "type": "", "pos": { - "x": 885, + "x": 536, "y": 28 }, "width": 154, @@ -166,7 +166,7 @@ "id": "there", "type": "", "pos": { - "x": 546, + "x": 716, "y": 254 }, "width": 143, @@ -206,7 +206,7 @@ "id": "'a\\\"ode'", "type": "", "pos": { - "x": 540, + "x": 710, "y": 28 }, "width": 154, @@ -246,7 +246,7 @@ "id": "\"a\\\\node\"", "type": "", "pos": { - "x": 365, + "x": 884, "y": 28 }, "width": 155, @@ -310,19 +310,19 @@ "labelPercentage": 0, "route": [ { - "x": 962, + "x": 613, "y": 154 }, { - "x": 962, + "x": 613, "y": 204 }, { - "x": 652.75, + "x": 751.25, "y": 204 }, { - "x": 652.75, + "x": 751.25, "y": 254 } ], @@ -357,11 +357,11 @@ "labelPercentage": 0, "route": [ { - "x": 617, + "x": 787, "y": 154 }, { - "x": 617, + "x": 787, "y": 254 } ], @@ -396,19 +396,19 @@ "labelPercentage": 0, "route": [ { - "x": 442.5, + "x": 961.5, "y": 154 }, { - "x": 442.5, + "x": 961.5, "y": 204 }, { - "x": 581.25, + "x": 822.75, "y": 204 }, { - "x": 581.25, + "x": 822.75, "y": 254 } ], diff --git a/e2etests/testdata/regression/dagre_special_ids/elk/sketch.exp.svg b/e2etests/testdata/regression/dagre_special_ids/elk/sketch.exp.svg index fb14b30ee..985f6ad4e 100644 --- a/e2etests/testdata/regression/dagre_special_ids/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/dagre_special_ids/elk/sketch.exp.svg @@ -18,7 +18,7 @@ width="1227" height="568" viewBox="-88 -88 1227 568">ninetynineeighty eightseventy sevena\yodetherea\"odea\node +ninetynineeighty eightseventy sevena\yodetherea\"odea\node lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest +lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest - - - - - - - - + + + + + + + +

Oldest message

+

Offset

+

Last message

+

Next message will be
+inserted here

+
M0M1M2M3M4M5M6 + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/elk_order/elk/board.exp.json b/e2etests/testdata/regression/elk_order/elk/board.exp.json new file mode 100644 index 000000000..10c667ae8 --- /dev/null +++ b/e2etests/testdata/regression/elk_order/elk/board.exp.json @@ -0,0 +1,639 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "queue", + "type": "queue", + "pos": { + "x": 12, + "y": 165 + }, + "width": 1146, + "height": 276, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1 + }, + { + "id": "queue.M0", + "type": "", + "pos": { + "x": 87, + "y": 240 + }, + "width": 125, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "M0", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 25, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "queue.M1", + "type": "", + "pos": { + "x": 232, + "y": 240 + }, + "width": 125, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "M1", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 25, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "queue.M2", + "type": "", + "pos": { + "x": 377, + "y": 240 + }, + "width": 125, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "M2", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 25, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "queue.M3", + "type": "", + "pos": { + "x": 522, + "y": 240 + }, + "width": 125, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "M3", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 25, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "queue.M4", + "type": "", + "pos": { + "x": 667, + "y": 240 + }, + "width": 126, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "M4", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 26, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "queue.M5", + "type": "", + "pos": { + "x": 813, + "y": 240 + }, + "width": 125, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "M5", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 25, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "queue.M6", + "type": "", + "pos": { + "x": 958, + "y": 240 + }, + "width": 125, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "M6", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 25, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "m0_desc", + "type": "text", + "pos": { + "x": 97, + "y": 36 + }, + "width": 106, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Oldest message", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 106, + "labelHeight": 24, + "zIndex": 0, + "level": 1 + }, + { + "id": "m2_desc", + "type": "text", + "pos": { + "x": 419, + "y": 36 + }, + "width": 41, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Offset", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 41, + "labelHeight": 24, + "zIndex": 0, + "level": 1 + }, + { + "id": "m5_desc", + "type": "text", + "pos": { + "x": 831, + "y": 36 + }, + "width": 90, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Last message", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 90, + "labelHeight": 24, + "zIndex": 0, + "level": 1 + }, + { + "id": "m6_desc", + "type": "text", + "pos": { + "x": 951, + "y": 12 + }, + "width": 140, + "height": 48, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Next message will be\\\ninserted here", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 140, + "labelHeight": 48, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(m0_desc -> queue.M0)[0]", + "src": "m0_desc", + "srcArrow": "none", + "srcLabel": "", + "dst": "queue.M0", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 149.5, + "y": 60 + }, + { + "x": 149.5, + "y": 240 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(m2_desc -> queue.M2)[0]", + "src": "m2_desc", + "srcArrow": "none", + "srcLabel": "", + "dst": "queue.M2", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 439.5, + "y": 60 + }, + { + "x": 439.5, + "y": 240 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(m5_desc -> queue.M5)[0]", + "src": "m5_desc", + "srcArrow": "none", + "srcLabel": "", + "dst": "queue.M5", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 875.5, + "y": 60 + }, + { + "x": 875.5, + "y": 240 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(m6_desc -> queue.M6)[0]", + "src": "m6_desc", + "srcArrow": "none", + "srcLabel": "", + "dst": "queue.M6", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 1020.5, + "y": 60 + }, + { + "x": 1020.5, + "y": 240 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/regression/elk_order/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_order/elk/sketch.exp.svg new file mode 100644 index 000000000..63a3b016e --- /dev/null +++ b/e2etests/testdata/regression/elk_order/elk/sketch.exp.svg @@ -0,0 +1,799 @@ + +

Oldest message

+

Offset

+

Last message

+

Next message will be
+inserted here

+
M0M1M2M3M4M5M6 + + +
\ No newline at end of file diff --git a/e2etests/testdata/stable/all_shapes/elk/board.exp.json b/e2etests/testdata/stable/all_shapes/elk/board.exp.json index bb4e1b59a..1e9044c30 100644 --- a/e2etests/testdata/stable/all_shapes/elk/board.exp.json +++ b/e2etests/testdata/stable/all_shapes/elk/board.exp.json @@ -6,7 +6,7 @@ "id": "rectangle", "type": "rectangle", "pos": { - "x": 769, + "x": 12, "y": 12 }, "width": 171, @@ -46,7 +46,7 @@ "id": "square", "type": "rectangle", "pos": { - "x": 778, + "x": 21, "y": 238 }, "width": 154, @@ -86,7 +86,7 @@ "id": "page", "type": "page", "pos": { - "x": 785, + "x": 28, "y": 492 }, "width": 139, @@ -126,7 +126,7 @@ "id": "parallelogram", "type": "parallelogram", "pos": { - "x": 960, + "x": 203, "y": 12 }, "width": 204, @@ -166,7 +166,7 @@ "id": "document", "type": "document", "pos": { - "x": 974, + "x": 217, "y": 252 }, "width": 177, @@ -206,7 +206,7 @@ "id": "cylinder", "type": "cylinder", "pos": { - "x": 980, + "x": 223, "y": 492 }, "width": 164, @@ -246,7 +246,7 @@ "id": "queue", "type": "queue", "pos": { - "x": 19, + "x": 427, "y": 12 }, "width": 149, @@ -286,7 +286,7 @@ "id": "package", "type": "package", "pos": { - "x": 12, + "x": 420, "y": 252 }, "width": 163, @@ -326,7 +326,7 @@ "id": "step", "type": "step", "pos": { - "x": 26, + "x": 434, "y": 492 }, "width": 136, @@ -366,7 +366,7 @@ "id": "callout", "type": "callout", "pos": { - "x": 213, + "x": 621, "y": 12 }, "width": 155, @@ -406,7 +406,7 @@ "id": "stored_data", "type": "stored_data", "pos": { - "x": 195, + "x": 603, "y": 252 }, "width": 191, @@ -446,7 +446,7 @@ "id": "person", "type": "person", "pos": { - "x": 214, + "x": 622, "y": 492 }, "width": 153, @@ -486,7 +486,7 @@ "id": "diamond", "type": "diamond", "pos": { - "x": 581, + "x": 798, "y": 12 }, "width": 168, @@ -526,7 +526,7 @@ "id": "oval", "type": "oval", "pos": { - "x": 597, + "x": 814, "y": 252 }, "width": 136, @@ -566,7 +566,7 @@ "id": "circle", "type": "oval", "pos": { - "x": 593, + "x": 810, "y": 492 }, "width": 144, @@ -606,7 +606,7 @@ "id": "hexagon", "type": "hexagon", "pos": { - "x": 396, + "x": 986, "y": 12 }, "width": 165, @@ -646,7 +646,7 @@ "id": "cloud", "type": "cloud", "pos": { - "x": 406, + "x": 996, "y": 238 }, "width": 145, @@ -710,11 +710,11 @@ "labelPercentage": 0, "route": [ { - "x": 854.5, + "x": 97.5, "y": 138 }, { - "x": 854.5, + "x": 97.5, "y": 238 } ], @@ -749,11 +749,11 @@ "labelPercentage": 0, "route": [ { - "x": 854.5, + "x": 97.5, "y": 392 }, { - "x": 855, + "x": 98, "y": 492 } ], @@ -788,11 +788,11 @@ "labelPercentage": 0, "route": [ { - "x": 1062, + "x": 305, "y": 138 }, { - "x": 1062, + "x": 305, "y": 252 } ], @@ -827,11 +827,11 @@ "labelPercentage": 0, "route": [ { - "x": 1062, + "x": 305, "y": 361 }, { - "x": 1062, + "x": 305, "y": 492 } ], @@ -866,11 +866,11 @@ "labelPercentage": 0, "route": [ { - "x": 93, + "x": 501, "y": 138 }, { - "x": 94, + "x": 502, "y": 252 } ], @@ -905,11 +905,11 @@ "labelPercentage": 0, "route": [ { - "x": 93, + "x": 501, "y": 378 }, { - "x": 94, + "x": 502, "y": 492 } ], @@ -944,11 +944,11 @@ "labelPercentage": 0, "route": [ { - "x": 291, + "x": 699, "y": 138 }, { - "x": 291, + "x": 699, "y": 252 } ], @@ -983,11 +983,11 @@ "labelPercentage": 0, "route": [ { - "x": 290, + "x": 698, "y": 378 }, { - "x": 291, + "x": 699, "y": 492 } ], @@ -1022,11 +1022,11 @@ "labelPercentage": 0, "route": [ { - "x": 665, + "x": 882, "y": 138 }, { - "x": 665, + "x": 882, "y": 252 } ], @@ -1061,11 +1061,11 @@ "labelPercentage": 0, "route": [ { - "x": 665, + "x": 882, "y": 378 }, { - "x": 665, + "x": 882, "y": 492 } ], @@ -1100,11 +1100,11 @@ "labelPercentage": 0, "route": [ { - "x": 478, + "x": 1068, "y": 138 }, { - "x": 479, + "x": 1069, "y": 240 } ], diff --git a/e2etests/testdata/stable/all_shapes/elk/sketch.exp.svg b/e2etests/testdata/stable/all_shapes/elk/sketch.exp.svg index 197d3d968..bbdb6ed74 100644 --- a/e2etests/testdata/stable/all_shapes/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/all_shapes/elk/sketch.exp.svg @@ -2,7 +2,7 @@ rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud - +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud + abcdefghijklmno +abcdefghijklmno abcdefghijklmnopq - +abcdefghijklmnopq + finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot - +finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot + size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 - - - - +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 + + + + aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - - - - - - - +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 + + + + + + + abcdefghiqrjmnoszaabbeeffggklptuwxyccddv - +abcdefghiqrjmnoszaabbeeffggklptuwxyccddv + abcdefghijklmnopqrstuvw - +abcdefghijklmnopqrstuvw + abcdefghijklmnopqrstu - +abcdefghijklmnopqrstu + acdefgbh +acdefgbh topabcbottomstartend +topabcbottomstartend xyz hello - - +xyz hello + + usersid -int -name -string -email -string -password -string -last_login -datetime -productsid -int -price -decimal -sku -string -name -string -ordersid -int -user_id -int -product_id -int -shipmentsid -int -order_id -int -tracking_number -string -status -string - +usersid +int +name +string +email +string +password +string +last_login +datetime +productsid +int +price +decimal +sku +string +name +string +ordersid +int +user_id +int +product_id +int +shipmentsid +int +order_id +int +tracking_number +string +status +string + acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc - +acbl1l2c1l2c3l2c2l3c1l3c2l4bacacbabcc1c2c3abc + AKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND - +AKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND + ninetynineeighty eightseventy sevena\yodetherea\"odea\node +ninetynineeighty eightseventy sevena\yodetherea\"odea\node lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest +lambda-build.yamllambda-deploy.yamlapollo-deploy.yamlPush to main branchGitHub ActionsS3TerraformAWSManual TriggerGitHub ActionsAWSApollo RepoGitHub ActionsAWS TriggersBuilds zip and pushes it Pulls zip to deployChanges live lambdasLaunchesBuilds zippushes them to S3. Deploys lambdasusing TerraformTriggered manually/push to master test test test test test test testtest diff --git a/e2etests/testdata/regression/elk_order/elk/board.exp.json b/e2etests/testdata/regression/elk_order/elk/board.exp.json index 10c667ae8..e17d4ca0f 100644 --- a/e2etests/testdata/regression/elk_order/elk/board.exp.json +++ b/e2etests/testdata/regression/elk_order/elk/board.exp.json @@ -325,7 +325,7 @@ "id": "m0_desc", "type": "text", "pos": { - "x": 97, + "x": 96, "y": 36 }, "width": 106, @@ -403,7 +403,7 @@ "id": "m5_desc", "type": "text", "pos": { - "x": 831, + "x": 830, "y": 36 }, "width": 90, @@ -442,7 +442,7 @@ "id": "m6_desc", "type": "text", "pos": { - "x": 951, + "x": 950, "y": 12 }, "width": 140, diff --git a/e2etests/testdata/regression/elk_order/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_order/elk/sketch.exp.svg index 63a3b016e..1088ee5a3 100644 --- a/e2etests/testdata/regression/elk_order/elk/sketch.exp.svg +++ b/e2etests/testdata/regression/elk_order/elk/sketch.exp.svg @@ -774,12 +774,12 @@ width="1346" height="629" viewBox="-88 -88 1346 629">

Oldest message

+

Oldest message

Offset

-

Last message

-

Next message will be
+

Last message

+

Next message will be
inserted here

-
M0M1M2M3M4M5M6 +
M0M1M2M3M4M5M6 abc +abc acbd +acbd rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud +rectanglesquarepageparallelogramdocumentcylinderqueuepackagestepcalloutstored_datapersondiamondovalcirclehexagoncloud cba * +cba * abcdefghijklmno +abcdefghijklmno acfbdhg +acfbdhg abcdefghijklmnopq +abcdefghijklmnopq finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot - +finallyatreeandnodessomemoremanythenhereyouhavehierarchyanotherofnestingtreesatreeinsidehierarchyroot + bacde21345abcde +bacde21345abcde alphabeta gamma +alphabeta gamma size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 - +size XSsize Ssize Msize Lsize XLsize XXLsize XXXLcustom 8custom 12custom 18custom 21custom 64 custom 10custom 15custom 48 + diff --git a/e2etests/testdata/stable/hr/elk/board.exp.json b/e2etests/testdata/stable/hr/elk/board.exp.json index 81bb926e0..b2afa8a49 100644 --- a/e2etests/testdata/stable/hr/elk/board.exp.json +++ b/e2etests/testdata/stable/hr/elk/board.exp.json @@ -45,7 +45,7 @@ "id": "a", "type": "", "pos": { - "x": 325, + "x": 324, "y": 12 }, "width": 113, @@ -85,7 +85,7 @@ "id": "b", "type": "", "pos": { - "x": 325, + "x": 324, "y": 472 }, "width": 113, diff --git a/e2etests/testdata/stable/hr/elk/sketch.exp.svg b/e2etests/testdata/stable/hr/elk/sketch.exp.svg index d4f060f54..d7373ac08 100644 --- a/e2etests/testdata/stable/hr/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/hr/elk/sketch.exp.svg @@ -778,7 +778,7 @@ width="938" height="786" viewBox="-88 -88 938 786">

Overview

-ab +ab aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 - +aabbccddllffwwyynniijjkkssuurmeemmmmgghhzzooppqqrrttvvxxabac 123456 + - + diff --git a/e2etests/testdata/stable/large_arch/elk/board.exp.json b/e2etests/testdata/stable/large_arch/elk/board.exp.json index d8dcaec74..ca38024d5 100644 --- a/e2etests/testdata/stable/large_arch/elk/board.exp.json +++ b/e2etests/testdata/stable/large_arch/elk/board.exp.json @@ -166,7 +166,7 @@ "id": "e", "type": "", "pos": { - "x": 856, + "x": 855, "y": 2394 }, "width": 113, @@ -326,7 +326,7 @@ "id": "i", "type": "", "pos": { - "x": 665, + "x": 664, "y": 1301 }, "width": 683, @@ -366,7 +366,7 @@ "id": "i.j", "type": "", "pos": { - "x": 879, + "x": 878, "y": 1376 }, "width": 392, @@ -406,7 +406,7 @@ "id": "i.j.k", "type": "", "pos": { - "x": 954, + "x": 953, "y": 1451 }, "width": 113, @@ -446,7 +446,7 @@ "id": "i.j.l", "type": "", "pos": { - "x": 1087, + "x": 1086, "y": 1451 }, "width": 109, @@ -486,8 +486,8 @@ "id": "i.m", "type": "", "pos": { - "x": 740, - "y": 1774 + "x": 739, + "y": 1773 }, "width": 117, "height": 126, @@ -526,7 +526,7 @@ "id": "i.n", "type": "", "pos": { - "x": 877, + "x": 876, "y": 1832 }, "width": 113, @@ -566,7 +566,7 @@ "id": "i.o", "type": "", "pos": { - "x": 1010, + "x": 1009, "y": 1682 }, "width": 263, @@ -606,7 +606,7 @@ "id": "i.o.p", "type": "", "pos": { - "x": 1085, + "x": 1084, "y": 1757 }, "width": 113, @@ -887,7 +887,7 @@ "type": "", "pos": { "x": 710, - "y": 687 + "y": 686 }, "width": 118, "height": 126, @@ -926,7 +926,7 @@ "id": "r.s.x", "type": "", "pos": { - "x": 694, + "x": 693, "y": 463 }, "width": 113, @@ -966,7 +966,7 @@ "id": "r.s.y", "type": "", "pos": { - "x": 827, + "x": 826, "y": 463 }, "width": 114, @@ -1046,7 +1046,7 @@ "id": "r.aa", "type": "", "pos": { - "x": 262, + "x": 261, "y": 237 }, "width": 122, @@ -1086,7 +1086,7 @@ "id": "r.bb", "type": "", "pos": { - "x": 404, + "x": 403, "y": 87 }, "width": 415, @@ -1126,7 +1126,7 @@ "id": "r.bb.cc", "type": "", "pos": { - "x": 479, + "x": 478, "y": 162 }, "width": 121, @@ -1166,7 +1166,7 @@ "id": "r.bb.dd", "type": "", "pos": { - "x": 620, + "x": 619, "y": 162 }, "width": 124, @@ -1246,7 +1246,7 @@ "id": "r.ff", "type": "", "pos": { - "x": 1036, + "x": 1035, "y": 388 }, "width": 117, @@ -1350,19 +1350,19 @@ "labelPercentage": 0, "route": [ { - "x": 1010.5, + "x": 1010.25, "y": 1577 }, { - "x": 1010.5, + "x": 1010.25, "y": 1667 }, { - "x": 827.75, + "x": 827.5, "y": 1667 }, { - "x": 827.75, + "x": 827.5, "y": 1773.875 } ], @@ -1397,11 +1397,11 @@ "labelPercentage": 0, "route": [ { - "x": 1141.5, + "x": 1141.25, "y": 1577 }, { - "x": 1141.5, + "x": 1141.25, "y": 1757 } ], diff --git a/e2etests/testdata/stable/large_arch/elk/sketch.exp.svg b/e2etests/testdata/stable/large_arch/elk/sketch.exp.svg index c8f91e3ba..f1dae3dd3 100644 --- a/e2etests/testdata/stable/large_arch/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/large_arch/elk/sketch.exp.svg @@ -18,7 +18,7 @@ width="1694" height="2708" viewBox="-88 -88 1694 2708">abcdefghiqrjmnoszaabbeeffggklptuwxyccddv +abcdefghiqrjmnoszaabbeeffggklptuwxyccddv mixed togethersugarsolution we get +mixed togethersugarsolution we get

Markdown: Syntax

-
ab +ab

code

-
ab +

code

+
ab abcdefghijklmnopqrstuvw - +abcdefghijklmnopqrstuvw + abcdefghijklmnopqrstu +abcdefghijklmnopqrstu Foo Baz12hello - +Foo Baz12hello + acdefgbh +acdefgbh topabcbottomstartend - +topabcbottomstartend + rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root +rootcontainerrootleftrightrootinnerrootinnerleftrightleftright to inner leftto inner rightto inner leftto inner rightto left container rootto right container root diff --git a/e2etests/testdata/stable/pre/elk/board.exp.json b/e2etests/testdata/stable/pre/elk/board.exp.json index df945bd32..f04cb489d 100644 --- a/e2etests/testdata/stable/pre/elk/board.exp.json +++ b/e2etests/testdata/stable/pre/elk/board.exp.json @@ -45,7 +45,7 @@ "id": "a", "type": "", "pos": { - "x": 257, + "x": 256, "y": 12 }, "width": 113, @@ -85,7 +85,7 @@ "id": "b", "type": "", "pos": { - "x": 257, + "x": 256, "y": 508 }, "width": 113, diff --git a/e2etests/testdata/stable/pre/elk/sketch.exp.svg b/e2etests/testdata/stable/pre/elk/sketch.exp.svg index 440472676..2d38f4dc0 100644 --- a/e2etests/testdata/stable/pre/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/pre/elk/sketch.exp.svg @@ -781,7 +781,7 @@ end tell

A code block continues until it reaches a line that is not indented (or the end of the article).

-ab +ab xyz hello +xyz hello a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) +a_shapea_sequenceanotherfinallysequencesequencesequencescoreritemResponseitemessayRubricconceptitemOutcomescorerconceptessayRubricitemitemOutcomeitemResponsescoreritemResponseitemessayRubricconceptitemOutcome getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts)getItem()itemgetRubric()rubricapplyTo(essayResp)match(essayResponse)scorenewgetNormalMinimum()getNormalMaximum()setScore(score)setFeedback(missingConcepts) - - - - - - - - - - - - + + + + + + + + + + + + diff --git a/e2etests/testdata/stable/square_3d/elk/board.exp.json b/e2etests/testdata/stable/square_3d/elk/board.exp.json index e1679a64f..dbcd20694 100644 --- a/e2etests/testdata/stable/square_3d/elk/board.exp.json +++ b/e2etests/testdata/stable/square_3d/elk/board.exp.json @@ -46,7 +46,7 @@ "id": "square", "type": "rectangle", "pos": { - "x": 21, + "x": 20, "y": 238 }, "width": 154, diff --git a/e2etests/testdata/stable/square_3d/elk/sketch.exp.svg b/e2etests/testdata/stable/square_3d/elk/sketch.exp.svg index 6c9a95e26..c052bafe0 100644 --- a/e2etests/testdata/stable/square_3d/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/square_3d/elk/sketch.exp.svg @@ -20,9 +20,9 @@ width="371" height="580" viewBox="-88 -88 371 580"> -rectangle - -square +rectangle + +square AKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND +AKHIALFLGAMSTNAZCANVNMUTARLAMOOKTXORCOKSNEWYCTMANYRIDEMDNJPANCSCIDMTWAILINIAMIKYWIOHMNSDVAWVMENHVTND eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one +eightsixteenthirty twosixty fourninety nine twelvetwenty fourforty eighteighty one From 4e7665b2520c957446ee2ee094bfca466922d39a Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 24 Dec 2022 13:42:34 -0800 Subject: [PATCH 184/257] add changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 0f99d4538..79c22bf5f 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -9,6 +9,7 @@ - Improved label placements for shapes with images to avoid overlapping container labels. [#474](https://github.com/terrastruct/d2/pull/474) - Sequence diagram edge group labels have more reasonable padding. [#512](https://github.com/terrastruct/d2/pull/512) +- ELK layout engine preserves order of nodes. [#282](https://github.com/terrastruct/d2/issues/282) #### Bugfixes ⛑️ From 64d7d5f1b6cb065792a5a855cb814ad9512d971a Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 24 Dec 2022 15:56:22 -0800 Subject: [PATCH 185/257] apply themes to tables and classes --- d2exporter/export.go | 5 ++ d2graph/d2graph.go | 10 ++- d2renderers/d2sketch/sketch.go | 56 ++++++-------- d2renderers/d2sketch/sketch_test.go | 2 +- .../d2sketch/testdata/class/sketch.exp.svg | 26 +++---- .../testdata/sql_tables/sketch.exp.svg | 70 +++++++++--------- d2renderers/d2svg/class.go | 25 +++---- d2renderers/d2svg/d2svg.go | 12 ++- d2renderers/d2svg/table.go | 28 +++---- d2target/d2target.go | 5 ++ e2etests/stable_test.go | 2 +- .../sql_table_overflow/dagre/board.exp.json | 18 +++-- .../sql_table_overflow/dagre/sketch.exp.svg | 18 ++--- .../sql_table_overflow/elk/board.exp.json | 18 +++-- .../sql_table_overflow/elk/sketch.exp.svg | 18 ++--- .../stable/class/dagre/board.exp.json | 9 ++- .../stable/class/dagre/sketch.exp.svg | 26 +++---- .../testdata/stable/class/elk/board.exp.json | 9 ++- .../testdata/stable/class/elk/sketch.exp.svg | 26 +++---- .../dagre/board.exp.json | 14 +++- .../dagre/sketch.exp.svg | 20 ++--- .../elk/board.exp.json | 14 +++- .../elk/sketch.exp.svg | 20 ++--- .../stable/sql_tables/dagre/board.exp.json | 74 +++++++++++-------- .../stable/sql_tables/dagre/sketch.exp.svg | 70 +++++++++--------- .../stable/sql_tables/elk/board.exp.json | 66 ++++++++++------- .../stable/sql_tables/elk/sketch.exp.svg | 70 +++++++++--------- 27 files changed, 397 insertions(+), 334 deletions(-) diff --git a/d2exporter/export.go b/d2exporter/export.go index 73a6e37bd..1eb2e6445 100644 --- a/d2exporter/export.go +++ b/d2exporter/export.go @@ -40,6 +40,11 @@ func applyTheme(shape *d2target.Shape, obj *d2graph.Object, theme *d2themes.Them if obj.Attributes.Shape.Value == d2target.ShapeText { shape.Color = theme.Colors.Neutrals.N1 } + if obj.Attributes.Shape.Value == d2target.ShapeSQLTable || obj.Attributes.Shape.Value == d2target.ShapeClass { + shape.PrimaryAccentColor = theme.Colors.B2 + shape.SecondaryAccentColor = theme.Colors.AA2 + shape.NeutralAccentColor = theme.Colors.Neutrals.N2 + } } func applyStyles(shape *d2target.Shape, obj *d2graph.Object) { diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index f0ad6e1f7..9f7d6fd3a 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -392,17 +392,23 @@ func (obj *Object) GetFill(theme *d2themes.Theme) string { return theme.Colors.Neutrals.N5 } + if strings.EqualFold(shape, d2target.ShapeSQLTable) || strings.EqualFold(shape, d2target.ShapeClass) { + return theme.Colors.Neutrals.N1 + } + return theme.Colors.Neutrals.N7 } func (obj *Object) GetStroke(theme *d2themes.Theme, dashGapSize interface{}) string { shape := obj.Attributes.Shape.Value if strings.EqualFold(shape, d2target.ShapeCode) || - strings.EqualFold(shape, d2target.ShapeClass) || - strings.EqualFold(shape, d2target.ShapeSQLTable) || strings.EqualFold(shape, d2target.ShapeText) { return theme.Colors.Neutrals.N1 } + if strings.EqualFold(shape, d2target.ShapeClass) || + strings.EqualFold(shape, d2target.ShapeSQLTable) { + return theme.Colors.Neutrals.N7 + } if dashGapSize != 0.0 { return theme.Colors.B2 } diff --git a/d2renderers/d2sketch/sketch.go b/d2renderers/d2sketch/sketch.go index ea3eb941c..afb71c87f 100644 --- a/d2renderers/d2sketch/sketch.go +++ b/d2renderers/d2sketch/sketch.go @@ -66,8 +66,13 @@ func DefineFillPattern() string { func shapeStyle(shape d2target.Shape) string { out := "" - out += fmt.Sprintf(`fill:%s;`, shape.Fill) - out += fmt.Sprintf(`stroke:%s;`, shape.Stroke) + if shape.Type == d2target.ShapeSQLTable || shape.Type == d2target.ShapeClass { + out += fmt.Sprintf(`fill:%s;`, shape.Stroke) + out += fmt.Sprintf(`stroke:%s;`, shape.Fill) + } else { + out += fmt.Sprintf(`fill:%s;`, shape.Fill) + out += fmt.Sprintf(`stroke:%s;`, shape.Stroke) + } out += fmt.Sprintf(`opacity:%f;`, shape.Opacity) out += fmt.Sprintf(`stroke-width:%d;`, shape.StrokeWidth) if shape.StrokeDash != 0 { @@ -226,10 +231,9 @@ func Table(r *Runner, shape d2target.Shape) (string, error) { return "", err } for _, p := range paths { - // TODO header fill output += fmt.Sprintf( ``, - shape.Pos.X, shape.Pos.Y, p, "#0a0f25", + shape.Pos.X, shape.Pos.Y, p, shape.Fill, ) } @@ -241,7 +245,6 @@ func Table(r *Runner, shape d2target.Shape) (string, error) { float64(shape.LabelHeight), ) - // TODO header font color output += fmt.Sprintf(`%s`, "text", tl.X, @@ -249,7 +252,7 @@ func Table(r *Runner, shape d2target.Shape) (string, error) { fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", 4+shape.FontSize, - "white", + shape.Stroke, ), svg.EscapeText(shape.Label), ) @@ -276,31 +279,23 @@ func Table(r *Runner, shape d2target.Shape) (string, error) { float64(shape.FontSize), ) - // TODO theme based - primaryColor := "rgb(13, 50, 178)" - accentColor := "rgb(74, 111, 243)" - neutralColor := "rgb(103, 108, 126)" - output += strings.Join([]string{ fmt.Sprintf(`%s`, nameTL.X, nameTL.Y+float64(shape.FontSize)*3/4, - fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", float64(shape.FontSize), primaryColor), + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", float64(shape.FontSize), shape.PrimaryAccentColor), svg.EscapeText(f.Name.Label), ), - - // TODO light font fmt.Sprintf(`%s`, nameTL.X+float64(longestNameWidth)+2*d2target.NamePadding, nameTL.Y+float64(shape.FontSize)*3/4, - fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", float64(shape.FontSize), neutralColor), + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", float64(shape.FontSize), shape.NeutralAccentColor), svg.EscapeText(f.Type.Label), ), - fmt.Sprintf(`%s`, constraintTR.X, constraintTR.Y+float64(shape.FontSize)*3/4, - fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s;letter-spacing:2px;", "end", float64(shape.FontSize), accentColor), + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s;letter-spacing:2px;", "end", float64(shape.FontSize), shape.SecondaryAccentColor), f.ConstraintAbbr(), ), }, "\n") @@ -316,8 +311,8 @@ func Table(r *Runner, shape d2target.Shape) (string, error) { } for _, p := range paths { output += fmt.Sprintf( - ``, - p, "#0a0f25", + ``, + p, shape.Fill, ) } } @@ -365,10 +360,9 @@ func Class(r *Runner, shape d2target.Shape) (string, error) { return "", err } for _, p := range paths { - // TODO header fill output += fmt.Sprintf( ``, - shape.Pos.X, shape.Pos.Y, p, "#0a0f25", + shape.Pos.X, shape.Pos.Y, p, shape.Fill, ) } @@ -385,7 +379,6 @@ func Class(r *Runner, shape d2target.Shape) (string, error) { float64(shape.LabelHeight), ) - // TODO header font color output += fmt.Sprintf(`%s`, "text", tl.X+float64(shape.LabelWidth)/2, @@ -393,7 +386,7 @@ func Class(r *Runner, shape d2target.Shape) (string, error) { fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "middle", 4+shape.FontSize, - "white", + shape.Stroke, ), svg.EscapeText(shape.Label), ) @@ -402,7 +395,7 @@ func Class(r *Runner, shape d2target.Shape) (string, error) { rowBox := geo.NewBox(box.TopLeft.Copy(), box.Width, rowHeight) rowBox.TopLeft.Y += headerBox.Height for _, f := range shape.Fields { - output += classRow(rowBox, f.VisibilityToken(), f.Name, f.Type, float64(shape.FontSize)) + output += classRow(shape, rowBox, f.VisibilityToken(), f.Name, f.Type, float64(shape.FontSize)) rowBox.TopLeft.Y += rowHeight } @@ -416,19 +409,19 @@ func Class(r *Runner, shape d2target.Shape) (string, error) { for _, p := range paths { output += fmt.Sprintf( ``, - p, "#0a0f25", + p, shape.Fill, ) } for _, m := range shape.Methods { - output += classRow(rowBox, m.VisibilityToken(), m.Name, m.Return, float64(shape.FontSize)) + output += classRow(shape, rowBox, m.VisibilityToken(), m.Name, m.Return, float64(shape.FontSize)) rowBox.TopLeft.Y += rowHeight } return output, nil } -func classRow(box *geo.Box, prefix, nameText, typeText string, fontSize float64) string { +func classRow(shape d2target.Shape, box *geo.Box, prefix, nameText, typeText string, fontSize float64) string { output := "" prefixTL := label.InsideMiddleLeft.GetPointOnBox( box, @@ -443,28 +436,25 @@ func classRow(box *geo.Box, prefix, nameText, typeText string, fontSize float64) fontSize, ) - // TODO theme based - accentColor := "rgb(13, 50, 178)" - output += strings.Join([]string{ fmt.Sprintf(`%s`, prefixTL.X, prefixTL.Y+fontSize*3/4, - fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, accentColor), + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, shape.PrimaryAccentColor), prefix, ), fmt.Sprintf(`%s`, prefixTL.X+d2target.PrefixWidth, prefixTL.Y+fontSize*3/4, - fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, "black"), + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, shape.Fill), svg.EscapeText(nameText), ), fmt.Sprintf(`%s`, typeTR.X, typeTR.Y+fontSize*3/4, - fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s;", "end", fontSize, accentColor), + fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s;", "end", fontSize, shape.SecondaryAccentColor), svg.EscapeText(typeText), ), }, "\n") diff --git a/d2renderers/d2sketch/sketch_test.go b/d2renderers/d2sketch/sketch_test.go index 87a2e17a2..e033bedfe 100644 --- a/d2renderers/d2sketch/sketch_test.go +++ b/d2renderers/d2sketch/sketch_test.go @@ -255,7 +255,7 @@ shipments: { shape: sql_table id: int order_id: int - tracking_number: string + tracking_number: string {constraint: primary_key} status: string } diff --git a/d2renderers/d2sketch/testdata/class/sketch.exp.svg b/d2renderers/d2sketch/testdata/class/sketch.exp.svg index ed2b21d25..827658e48 100644 --- a/d2renderers/d2sketch/testdata/class/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/class/sketch.exp.svg @@ -30,19 +30,19 @@ width="553" height="584" viewBox="-100 -100 553 584">sql_table_overflowshort -loooooooooooooooooooong -loooooooooooooooooooong -short -sql_table_constrained_overflowshort -loooooooooooooooooooong -UNQloooooooooooooooooooong -short -FK +sql_table_overflowshort +loooooooooooooooooooong +loooooooooooooooooooong +short +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK sql_table_overflowshort -loooooooooooooooooooong -loooooooooooooooooooong -short -sql_table_constrained_overflowshort -loooooooooooooooooooong -UNQloooooooooooooooooooong -short -FK +sql_table_overflowshort +loooooooooooooooooooong +loooooooooooooooooooong +short +sql_table_constrained_overflowshort +loooooooooooooooooooong +UNQloooooooooooooooooooong +short +FK BatchManager- -num -int- -timeout -int- -pid -+ -getStatus() -Enum+ -getJobs() -Job[]+ -setTimeout(seconds int) -void +BatchManager- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +void BatchManager- -num -int- -timeout -int- -pid -+ -getStatus() -Enum+ -getJobs() -Job[]+ -setTimeout(seconds int) -void +BatchManager- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +void a labelblabelsa class+ -public() bool -void- -private() int -voidcloudyyyy:= 5 +a labelblabelsa class+ +public() bool +void- +private() int +voidcloudyyyy:= 5 := a + 7 -fmt.Printf("%d", b)cyldiadocssix cornersa random iconoverpackdocs pagetoohard o saysinglepersona queuea squarea step at a timedatausersid -int -name -varchar - result := callThisFunction(obj, 5) midthis sideother side +fmt.Printf("%d", b)cyldiadocssix cornersa random iconoverpackdocs pagetoohard o saysinglepersona queuea squarea step at a timedatausersid +int +name +varchar + result := callThisFunction(obj, 5) midthis sideother side diff --git a/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json b/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json index 61504c34e..4b77fb8ae 100644 --- a/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/board.exp.json @@ -96,7 +96,7 @@ "strokeWidth": 2, "borderRadius": 0, "fill": "#EDF0FD", - "stroke": "#0A0F25", + "stroke": "#FFFFFF", "shadow": false, "3d": false, "multiple": false, @@ -131,7 +131,10 @@ "labelHeight": 36, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, - "level": 1 + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" }, { "id": "d", @@ -798,7 +801,7 @@ "strokeWidth": 2, "borderRadius": 0, "fill": "#EDF0FD", - "stroke": "#0A0F25", + "stroke": "#FFFFFF", "shadow": false, "3d": false, "multiple": false, @@ -879,7 +882,10 @@ "labelHeight": 36, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, - "level": 1 + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" } ], "connections": [ diff --git a/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/sketch.exp.svg index c23490a3e..c059492d0 100644 --- a/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_all_shapes/elk/sketch.exp.svg @@ -18,17 +18,17 @@ width="5120" height="2984" viewBox="-76 -26 5120 2984">a labelblabelsa class+ -public() bool -void- -private() int -voidcloudyyyy:= 5 +a labelblabelsa class+ +public() bool +void- +private() int +voidcloudyyyy:= 5 := a + 7 -fmt.Printf("%d", b)cyldiadocssix cornersa random iconoverpackdocs pagetoohard o saysinglepersona queuea squarea step at a timedatausersid -int -name -varchar - result := callThisFunction(obj, 5) midthis sideother side +fmt.Printf("%d", b)cyldiadocssix cornersa random iconoverpackdocs pagetoohard o saysinglepersona queuea squarea step at a timedatausersid +int +name +varchar + result := callThisFunction(obj, 5) midthis sideother side diff --git a/e2etests/testdata/stable/sql_tables/dagre/board.exp.json b/e2etests/testdata/stable/sql_tables/dagre/board.exp.json index a3b85c40e..0fd37e978 100644 --- a/e2etests/testdata/stable/sql_tables/dagre/board.exp.json +++ b/e2etests/testdata/stable/sql_tables/dagre/board.exp.json @@ -9,14 +9,14 @@ "x": 0, "y": 0 }, - "width": 208, + "width": 268, "height": 216, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0A0F25", + "fill": "#0A0F25", + "stroke": "#FFFFFF", "shadow": false, "3d": false, "multiple": false, @@ -165,7 +165,7 @@ "labelWidth": 77, "labelHeight": 26 }, - "constraint": "", + "constraint": "primary_key", "reference": "" } ], @@ -180,13 +180,16 @@ "labelWidth": 61, "labelHeight": 36, "zIndex": 0, - "level": 1 + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" }, { "id": "products", "type": "sql_table", "pos": { - "x": 268, + "x": 328, "y": 18 }, "width": 164, @@ -195,8 +198,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0A0F25", + "fill": "#0A0F25", + "stroke": "#FFFFFF", "shadow": false, "3d": false, "multiple": false, @@ -332,13 +335,16 @@ "labelWidth": 99, "labelHeight": 36, "zIndex": 0, - "level": 1 + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" }, { "id": "orders", "type": "sql_table", "pos": { - "x": 268, + "x": 328, "y": 316 }, "width": 164, @@ -347,8 +353,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0A0F25", + "fill": "#0A0F25", + "stroke": "#FFFFFF", "shadow": false, "3d": false, "multiple": false, @@ -456,13 +462,16 @@ "labelWidth": 74, "labelHeight": 36, "zIndex": 0, - "level": 1 + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" }, { "id": "shipments", "type": "sql_table", "pos": { - "x": 492, + "x": 552, "y": 18 }, "width": 244, @@ -471,8 +480,8 @@ "strokeDash": 0, "strokeWidth": 2, "borderRadius": 0, - "fill": "#FFFFFF", - "stroke": "#0A0F25", + "fill": "#0A0F25", + "stroke": "#FFFFFF", "shadow": false, "3d": false, "multiple": false, @@ -608,7 +617,10 @@ "labelWidth": 116, "labelHeight": 36, "zIndex": 0, - "level": 1 + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" } ], "connections": [ @@ -638,20 +650,20 @@ "labelPercentage": 0, "route": [ { - "x": 104, + "x": 134, "y": 216 }, { - "x": 104, + "x": 134, "y": 256 }, { - "x": 136.8, - "y": 282.2 + "x": 172.8, + "y": 283.2 }, { - "x": 268, - "y": 347 + "x": 328, + "y": 352 } ], "isCurve": true, @@ -686,19 +698,19 @@ "labelPercentage": 0, "route": [ { - "x": 350, + "x": 410, "y": 198 }, { - "x": 350, + "x": 410, "y": 252.4 }, { - "x": 350, + "x": 410, "y": 276 }, { - "x": 350, + "x": 410, "y": 316 } ], @@ -734,19 +746,19 @@ "labelPercentage": 0, "route": [ { - "x": 614, + "x": 674, "y": 198 }, { - "x": 614, + "x": 674, "y": 252.4 }, { - "x": 577.6, + "x": 637.6, "y": 282.8 }, { - "x": 432, + "x": 492, "y": 350 } ], diff --git a/e2etests/testdata/stable/sql_tables/dagre/sketch.exp.svg b/e2etests/testdata/stable/sql_tables/dagre/sketch.exp.svg index d6087ea8a..8b78b0f66 100644 --- a/e2etests/testdata/stable/sql_tables/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sql_tables/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ usersid +int +name +string +email +string +password +string +last_login +datetime +PKproductsid +int +price +decimal +sku +string +name +string +ordersid +int +user_id +int +product_id +int +shipmentsid +int +order_id +int +tracking_number +string +status +string + + usersid -int -name -string -email -string -password -string -last_login -datetime -productsid -int -price -decimal -sku -string -name -string -ordersid -int -user_id -int -product_id -int -shipmentsid -int -order_id -int -tracking_number -string -status -string - - +usersid +int +name +string +email +string +password +string +last_login +datetime +PKproductsid +int +price +decimal +sku +string +name +string +ordersid +int +user_id +int +product_id +int +shipmentsid +int +order_id +int +tracking_number +string +status +string + + \ No newline at end of file diff --git a/d2renderers/d2svg/class.go b/d2renderers/d2svg/class.go index 8e8f707ed..85205db32 100644 --- a/d2renderers/d2svg/class.go +++ b/d2renderers/d2svg/class.go @@ -24,11 +24,10 @@ func classHeader(shape d2target.Shape, box *geo.Box, text string, textWidth, tex ) str += fmt.Sprintf(`%s`, - // TODO use monospace font - "text", + "text-mono", tl.X+textWidth/2, tl.Y+textHeight*3/4, - fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", + fmt.Sprintf(`text-anchor:%s;font-size:%vpx;fill:%s`, "middle", 4+fontSize, shape.Stroke, @@ -56,21 +55,21 @@ func classRow(shape d2target.Shape, box *geo.Box, prefix, nameText, typeText str ) return strings.Join([]string{ - fmt.Sprintf(`%s`, + fmt.Sprintf(`%s`, prefixTL.X, prefixTL.Y+fontSize*3/4, fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, shape.PrimaryAccentColor), prefix, ), - fmt.Sprintf(`%s`, + fmt.Sprintf(`%s`, prefixTL.X+d2target.PrefixWidth, prefixTL.Y+fontSize*3/4, fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "start", fontSize, shape.Fill), svg.EscapeText(nameText), ), - fmt.Sprintf(`%s`, + fmt.Sprintf(`%s`, typeTR.X, typeTR.Y+fontSize*3/4, fmt.Sprintf("text-anchor:%s;font-size:%vpx;fill:%s", "end", fontSize, shape.SecondaryAccentColor), diff --git a/e2etests/testdata/stable/class/dagre/board.exp.json b/e2etests/testdata/stable/class/dagre/board.exp.json index 41edbb9ad..ada2bfc60 100644 --- a/e2etests/testdata/stable/class/dagre/board.exp.json +++ b/e2etests/testdata/stable/class/dagre/board.exp.json @@ -9,7 +9,7 @@ "x": 0, "y": 0 }, - "width": 339, + "width": 422, "height": 368, "opacity": 1, "strokeDash": 0, @@ -68,7 +68,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 150, + "labelWidth": 175, "labelHeight": 36, "zIndex": 0, "level": 1, diff --git a/e2etests/testdata/stable/class/dagre/sketch.exp.svg b/e2etests/testdata/stable/class/dagre/sketch.exp.svg index e016700c8..f47e1aea0 100644 --- a/e2etests/testdata/stable/class/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/class/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ BatchManager- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +void + \ No newline at end of file diff --git a/e2etests/testdata/stable/class/elk/board.exp.json b/e2etests/testdata/stable/class/elk/board.exp.json index b6a2b2864..438953ee7 100644 --- a/e2etests/testdata/stable/class/elk/board.exp.json +++ b/e2etests/testdata/stable/class/elk/board.exp.json @@ -9,7 +9,7 @@ "x": 12, "y": 12 }, - "width": 339, + "width": 422, "height": 368, "opacity": 1, "strokeDash": 0, @@ -68,7 +68,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 150, + "labelWidth": 175, "labelHeight": 36, "zIndex": 0, "level": 1, diff --git a/e2etests/testdata/stable/class/elk/sketch.exp.svg b/e2etests/testdata/stable/class/elk/sketch.exp.svg index 522347026..a433f42f0 100644 --- a/e2etests/testdata/stable/class/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/class/elk/sketch.exp.svg @@ -2,7 +2,7 @@ BatchManager- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +void + \ No newline at end of file From ae2f75890bf7ed8351753e637fbded53df5de9d0 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sat, 24 Dec 2022 16:19:09 -0800 Subject: [PATCH 188/257] fix class header --- d2graph/d2graph.go | 3 + .../dagre/board.exp.json | 182 +++++++++--------- .../dagre/sketch.exp.svg | 26 +-- .../elk/board.exp.json | 182 +++++++++--------- .../elk/sketch.exp.svg | 26 +-- 5 files changed, 211 insertions(+), 208 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 956244dc9..e60aa17c0 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -457,6 +457,9 @@ func (obj *Object) Text() *d2target.MText { if obj.Class != nil || obj.SQLTable != nil { fontSize = d2fonts.FONT_SIZE_XL } + if obj.Class != nil { + isBold = false + } return &d2target.MText{ Text: obj.Attributes.Label.Value, FontSize: fontSize, diff --git a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json index 4b77fb8ae..42c5c962e 100644 --- a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json +++ b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/board.exp.json @@ -86,10 +86,10 @@ "id": "c", "type": "class", "pos": { - "x": 486, + "x": 481, "y": 74 }, - "width": 241, + "width": 302, "height": 184, "opacity": 1, "strokeDash": 0, @@ -127,7 +127,7 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 71, + "labelWidth": 104, "labelHeight": 36, "labelPosition": "INSIDE_MIDDLE_CENTER", "zIndex": 0, @@ -140,7 +140,7 @@ "id": "d", "type": "cloud", "pos": { - "x": 777, + "x": 833, "y": 132 }, "width": 174, @@ -180,7 +180,7 @@ "id": "e", "type": "code", "pos": { - "x": 1016, + "x": 1072, "y": 188 }, "width": 196, @@ -220,7 +220,7 @@ "id": "f", "type": "cylinder", "pos": { - "x": 1289, + "x": 1345, "y": 132 }, "width": 150, @@ -260,7 +260,7 @@ "id": "g", "type": "diamond", "pos": { - "x": 1539, + "x": 1595, "y": 132 }, "width": 150, @@ -300,7 +300,7 @@ "id": "h", "type": "document", "pos": { - "x": 1789, + "x": 1845, "y": 132 }, "width": 150, @@ -340,7 +340,7 @@ "id": "i", "type": "hexagon", "pos": { - "x": 2025, + "x": 2082, "y": 132 }, "width": 177, @@ -380,7 +380,7 @@ "id": "j", "type": "image", "pos": { - "x": 2289, + "x": 2345, "y": 109 }, "width": 150, @@ -431,7 +431,7 @@ "id": "k", "type": "oval", "pos": { - "x": 2539, + "x": 2595, "y": 132 }, "width": 150, @@ -471,7 +471,7 @@ "id": "l", "type": "package", "pos": { - "x": 2789, + "x": 2845, "y": 132 }, "width": 150, @@ -511,7 +511,7 @@ "id": "m", "type": "page", "pos": { - "x": 3027, + "x": 3084, "y": 132 }, "width": 173, @@ -551,7 +551,7 @@ "id": "n", "type": "parallelogram", "pos": { - "x": 3275, + "x": 3332, "y": 116 }, "width": 177, @@ -591,7 +591,7 @@ "id": "o", "type": "person", "pos": { - "x": 3538, + "x": 3595, "y": 79 }, "width": 151, @@ -631,7 +631,7 @@ "id": "p", "type": "queue", "pos": { - "x": 3784, + "x": 3841, "y": 132 }, "width": 159, @@ -671,7 +671,7 @@ "id": "q", "type": "rectangle", "pos": { - "x": 4032, + "x": 4089, "y": 95 }, "width": 163, @@ -711,7 +711,7 @@ "id": "r", "type": "step", "pos": { - "x": 4260, + "x": 4317, "y": 132 }, "width": 207, @@ -751,7 +751,7 @@ "id": "s", "type": "stored_data", "pos": { - "x": 4539, + "x": 4595, "y": 132 }, "width": 150, @@ -791,7 +791,7 @@ "id": "t", "type": "sql_table", "pos": { - "x": 4783, + "x": 4840, "y": 150 }, "width": 161, @@ -958,7 +958,7 @@ "y": 518 }, { - "x": 606.5, + "x": 632, "y": 518 } ], @@ -993,11 +993,11 @@ "labelPercentage": 0, "route": [ { - "x": 606.5, + "x": 632, "y": 648 }, { - "x": 864, + "x": 920, "y": 648 } ], @@ -1032,11 +1032,11 @@ "labelPercentage": 0, "route": [ { - "x": 864, + "x": 920, "y": 778 }, { - "x": 1114, + "x": 1170, "y": 778 } ], @@ -1071,11 +1071,11 @@ "labelPercentage": 0, "route": [ { - "x": 1114, + "x": 1170, "y": 908 }, { - "x": 1364, + "x": 1420, "y": 908 } ], @@ -1110,11 +1110,11 @@ "labelPercentage": 0, "route": [ { - "x": 1364, + "x": 1420, "y": 1038 }, { - "x": 1614, + "x": 1670, "y": 1038 } ], @@ -1149,11 +1149,11 @@ "labelPercentage": 0, "route": [ { - "x": 1614, + "x": 1670, "y": 1168 }, { - "x": 1864, + "x": 1920, "y": 1168 } ], @@ -1188,11 +1188,11 @@ "labelPercentage": 0, "route": [ { - "x": 1864, + "x": 1920, "y": 1298 }, { - "x": 2113.5, + "x": 2170.5, "y": 1298 } ], @@ -1227,11 +1227,11 @@ "labelPercentage": 0, "route": [ { - "x": 2113.5, + "x": 2170.5, "y": 1428 }, { - "x": 2364, + "x": 2420, "y": 1428 } ], @@ -1266,11 +1266,11 @@ "labelPercentage": 0, "route": [ { - "x": 2364, + "x": 2420, "y": 1558 }, { - "x": 2614, + "x": 2670, "y": 1558 } ], @@ -1305,11 +1305,11 @@ "labelPercentage": 0, "route": [ { - "x": 2614, + "x": 2670, "y": 1688 }, { - "x": 2864, + "x": 2920, "y": 1688 } ], @@ -1344,11 +1344,11 @@ "labelPercentage": 0, "route": [ { - "x": 2864, + "x": 2920, "y": 1818 }, { - "x": 3113.5, + "x": 3170.5, "y": 1818 } ], @@ -1383,11 +1383,11 @@ "labelPercentage": 0, "route": [ { - "x": 3113.5, + "x": 3170.5, "y": 1948 }, { - "x": 3363.5, + "x": 3420.5, "y": 1948 } ], @@ -1422,11 +1422,11 @@ "labelPercentage": 0, "route": [ { - "x": 3363.5, + "x": 3420.5, "y": 2078 }, { - "x": 3613.5, + "x": 3670.5, "y": 2078 } ], @@ -1461,11 +1461,11 @@ "labelPercentage": 0, "route": [ { - "x": 3613.5, + "x": 3670.5, "y": 2208 }, { - "x": 3863.5, + "x": 3920.5, "y": 2208 } ], @@ -1500,11 +1500,11 @@ "labelPercentage": 0, "route": [ { - "x": 3863.5, + "x": 3920.5, "y": 2338 }, { - "x": 4113.5, + "x": 4170.5, "y": 2338 } ], @@ -1539,11 +1539,11 @@ "labelPercentage": 0, "route": [ { - "x": 4113.5, + "x": 4170.5, "y": 2468 }, { - "x": 4363.5, + "x": 4420.5, "y": 2468 } ], @@ -1578,11 +1578,11 @@ "labelPercentage": 0, "route": [ { - "x": 4363.5, + "x": 4420.5, "y": 2598 }, { - "x": 4614, + "x": 4670, "y": 2598 } ], @@ -1617,11 +1617,11 @@ "labelPercentage": 0, "route": [ { - "x": 4614, + "x": 4670, "y": 2728 }, { - "x": 4863.5, + "x": 4920.5, "y": 2728 } ], @@ -1734,11 +1734,11 @@ "labelPercentage": 0, "route": [ { - "x": 606.5, + "x": 632, "y": 258 }, { - "x": 606.5, + "x": 632, "y": 2858 } ], @@ -1773,11 +1773,11 @@ "labelPercentage": 0, "route": [ { - "x": 864, + "x": 920, "y": 258 }, { - "x": 864, + "x": 920, "y": 2858 } ], @@ -1812,11 +1812,11 @@ "labelPercentage": 0, "route": [ { - "x": 1114, + "x": 1170, "y": 258 }, { - "x": 1114, + "x": 1170, "y": 2858 } ], @@ -1851,11 +1851,11 @@ "labelPercentage": 0, "route": [ { - "x": 1364, + "x": 1420, "y": 258 }, { - "x": 1364, + "x": 1420, "y": 2858 } ], @@ -1890,11 +1890,11 @@ "labelPercentage": 0, "route": [ { - "x": 1614, + "x": 1670, "y": 258 }, { - "x": 1614, + "x": 1670, "y": 2858 } ], @@ -1929,11 +1929,11 @@ "labelPercentage": 0, "route": [ { - "x": 1864, + "x": 1920, "y": 258 }, { - "x": 1864, + "x": 1920, "y": 2858 } ], @@ -1968,11 +1968,11 @@ "labelPercentage": 0, "route": [ { - "x": 2113.5, + "x": 2170.5, "y": 258 }, { - "x": 2113.5, + "x": 2170.5, "y": 2858 } ], @@ -2007,11 +2007,11 @@ "labelPercentage": 0, "route": [ { - "x": 2364, + "x": 2420, "y": 263 }, { - "x": 2364, + "x": 2420, "y": 2858 } ], @@ -2046,11 +2046,11 @@ "labelPercentage": 0, "route": [ { - "x": 2614, + "x": 2670, "y": 258 }, { - "x": 2614, + "x": 2670, "y": 2858 } ], @@ -2085,11 +2085,11 @@ "labelPercentage": 0, "route": [ { - "x": 2864, + "x": 2920, "y": 258 }, { - "x": 2864, + "x": 2920, "y": 2858 } ], @@ -2124,11 +2124,11 @@ "labelPercentage": 0, "route": [ { - "x": 3113.5, + "x": 3170.5, "y": 258 }, { - "x": 3113.5, + "x": 3170.5, "y": 2858 } ], @@ -2163,11 +2163,11 @@ "labelPercentage": 0, "route": [ { - "x": 3363.5, + "x": 3420.5, "y": 258 }, { - "x": 3363.5, + "x": 3420.5, "y": 2858 } ], @@ -2202,11 +2202,11 @@ "labelPercentage": 0, "route": [ { - "x": 3613.5, + "x": 3670.5, "y": 263 }, { - "x": 3613.5, + "x": 3670.5, "y": 2858 } ], @@ -2241,11 +2241,11 @@ "labelPercentage": 0, "route": [ { - "x": 3863.5, + "x": 3920.5, "y": 258 }, { - "x": 3863.5, + "x": 3920.5, "y": 2858 } ], @@ -2280,11 +2280,11 @@ "labelPercentage": 0, "route": [ { - "x": 4113.5, + "x": 4170.5, "y": 258 }, { - "x": 4113.5, + "x": 4170.5, "y": 2858 } ], @@ -2319,11 +2319,11 @@ "labelPercentage": 0, "route": [ { - "x": 4363.5, + "x": 4420.5, "y": 258 }, { - "x": 4363.5, + "x": 4420.5, "y": 2858 } ], @@ -2358,11 +2358,11 @@ "labelPercentage": 0, "route": [ { - "x": 4614, + "x": 4670, "y": 258 }, { - "x": 4614, + "x": 4670, "y": 2858 } ], @@ -2397,11 +2397,11 @@ "labelPercentage": 0, "route": [ { - "x": 4863.5, + "x": 4920.5, "y": 258 }, { - "x": 4863.5, + "x": 4920.5, "y": 2858 } ], diff --git a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/sketch.exp.svg b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/sketch.exp.svg index c059492d0..2b86d5324 100644 --- a/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/sequence_diagram_all_shapes/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ a labelblabelsa class+ +public() bool +void- +private() int +voidcloudyyyy:= 5 := a + 7 -fmt.Printf("%d", b)cyldiadocssix cornersa random iconoverpackdocs pagetoohard o saysinglepersona queuea squarea step at a timedatausersid -int -name -varchar - result := callThisFunction(obj, 5) midthis sideother side - +fmt.Printf("%d", b)cyldiadocssix cornersa random iconoverpackdocs pagetoohard o saysinglepersona queuea squarea step at a timedatausersid +int +name +varchar + result := callThisFunction(obj, 5) midthis sideother side + - + a labelblabelsa class+ -public() bool -void- -private() int -voidcloudyyyy:= 5 +a labelblabelsa class+ +public() bool +void- +private() int +voidcloudyyyy:= 5 := a + 7 -fmt.Printf("%d", b)cyldiadocssix cornersa random iconoverpackdocs pagetoohard o saysinglepersona queuea squarea step at a timedatausersid -int -name -varchar - result := callThisFunction(obj, 5) midthis sideother side - +fmt.Printf("%d", b)cyldiadocssix cornersa random iconoverpackdocs pagetoohard o saysinglepersona queuea squarea step at a timedatausersid +int +name +varchar + result := callThisFunction(obj, 5) midthis sideother side + - + xy

The top of the mountain

+
JoeDonald

Cats, no less liquid than their shadows, offer no angles to the wind.

+

If we can't fix it, it ain't broke.

+

Dieters live life in the fasting lane.

+

i am top left

+

i am top right

+

i am bottom left

+

i am bottom right

+
+ + +
\ No newline at end of file diff --git a/e2etests/testdata/stable/constant_near/elk/board.exp.json b/e2etests/testdata/stable/constant_near/elk/board.exp.json new file mode 100644 index 000000000..2b2e89b8e --- /dev/null +++ b/e2etests/testdata/stable/constant_near/elk/board.exp.json @@ -0,0 +1,447 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "x", + "type": "", + "pos": { + "x": 1961, + "y": 16 + }, + "width": 113, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "x", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "y", + "type": "", + "pos": { + "x": 1960, + "y": 242 + }, + "width": 114, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "y", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 14, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "The top of the mountain", + "type": "text", + "pos": { + "x": 1936, + "y": -28 + }, + "width": 162, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "The top of the mountain", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 162, + "labelHeight": 24, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Joe", + "type": "person", + "pos": { + "x": 1809, + "y": 129 + }, + "width": 131, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Joe", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 31, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "Donald", + "type": "person", + "pos": { + "x": 2094, + "y": 129 + }, + "width": 155, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "Donald", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 55, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "bottom", + "type": "text", + "pos": { + "x": 1546, + "y": 388 + }, + "width": 943, + "height": 130, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "# Cats, no less liquid than their shadows, offer no angles to the wind.\n\nIf we can't fix it, it ain't broke.\n\nDieters live life in the fasting lane.", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 943, + "labelHeight": 130, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "i am top left", + "type": "text", + "pos": { + "x": 1445, + "y": -28 + }, + "width": 81, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "i am top left", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 81, + "labelHeight": 24, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "i am top right", + "type": "text", + "pos": { + "x": 2509, + "y": -28 + }, + "width": 91, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "i am top right", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 91, + "labelHeight": 24, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "i am bottom left", + "type": "text", + "pos": { + "x": 1418, + "y": 388 + }, + "width": 108, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "i am bottom left", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 108, + "labelHeight": 24, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "i am bottom right", + "type": "text", + "pos": { + "x": 2509, + "y": 388 + }, + "width": 118, + "height": 24, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "i am bottom right", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 118, + "labelHeight": 24, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(x -> y)[0]", + "src": "x", + "srcArrow": "none", + "srcLabel": "", + "dst": "y", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 2017.5, + "y": 142 + }, + { + "x": 2017.5, + "y": 242 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/constant_near/elk/sketch.exp.svg b/e2etests/testdata/stable/constant_near/elk/sketch.exp.svg new file mode 100644 index 000000000..a9a1c7387 --- /dev/null +++ b/e2etests/testdata/stable/constant_near/elk/sketch.exp.svg @@ -0,0 +1,802 @@ + +xy

The top of the mountain

+
JoeDonald

Cats, no less liquid than their shadows, offer no angles to the wind.

+

If we can't fix it, it ain't broke.

+

Dieters live life in the fasting lane.

+

i am top left

+

i am top right

+

i am bottom left

+

i am bottom right

+
+ + +
\ No newline at end of file From 9eaa4e98c4839c49c4d9aea1a04a8f9948646970 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 25 Dec 2022 16:49:19 -0800 Subject: [PATCH 192/257] cleanup --- d2layouts/d2near/layout.go | 41 ++++++++-------- .../stable/constant_near/elk/board.exp.json | 48 +++++++++---------- .../stable/constant_near/elk/sketch.exp.svg | 18 +++---- 3 files changed, 53 insertions(+), 54 deletions(-) diff --git a/d2layouts/d2near/layout.go b/d2layouts/d2near/layout.go index 8a735c4c0..954e6af30 100644 --- a/d2layouts/d2near/layout.go +++ b/d2layouts/d2near/layout.go @@ -22,30 +22,22 @@ func Layout(ctx context.Context, g *d2graph.Graph, constantNears []*d2graph.Obje return nil } - // Imagine the grpah has two long texts, one at top center and one at top left. + // Imagine the graph has two long texts, one at top center and one at top left. // Top left should go left enough to not collide with center. // So place the center ones first, then the later ones will consider them for bounding box - for _, obj := range constantNears { - if strings.Contains(d2graph.Key(obj.Attributes.NearKey)[0], "center") { - obj.TopLeft = geo.NewPoint(place(obj)) + for _, processCenters := range []bool{true, false} { + for _, obj := range constantNears { + if processCenters == strings.Contains(d2graph.Key(obj.Attributes.NearKey)[0], "center") { + obj.TopLeft = geo.NewPoint(place(obj)) + } } - } - for _, obj := range constantNears { - if strings.Contains(d2graph.Key(obj.Attributes.NearKey)[0], "center") { - // The z-index for constant nears does not matter, as it will not collide - g.Objects = append(g.Objects, obj) - } - } - - for _, obj := range constantNears { - if !strings.Contains(d2graph.Key(obj.Attributes.NearKey)[0], "center") { - obj.TopLeft = geo.NewPoint(place(obj)) - } - } - for _, obj := range constantNears { - if !strings.Contains(d2graph.Key(obj.Attributes.NearKey)[0], "center") { - // The z-index for constant nears does not matter, as it will not collide - g.Objects = append(g.Objects, obj) + for _, obj := range constantNears { + if processCenters == strings.Contains(d2graph.Key(obj.Attributes.NearKey)[0], "center") { + // The z-index for constant nears does not matter, as it will not collide + g.Objects = append(g.Objects, obj) + obj.Parent.Children[obj.ID] = obj + obj.Parent.ChildrenArray = append(obj.Parent.ChildrenArray, obj) + } } } @@ -106,6 +98,13 @@ func WithoutConstantNears(ctx context.Context, g *d2graph.Graph) (nears []*d2gra nears = append(nears, obj) g.Objects = append(g.Objects[:i], g.Objects[i+1:]...) i-- + delete(obj.Parent.Children, obj.ID) + for i := 0; i < len(obj.Parent.ChildrenArray); i++ { + if obj.Parent.ChildrenArray[i] == obj { + obj.Parent.ChildrenArray = append(obj.Parent.ChildrenArray[:i], obj.Parent.ChildrenArray[i+1:]...) + break + } + } } } return nears diff --git a/e2etests/testdata/stable/constant_near/elk/board.exp.json b/e2etests/testdata/stable/constant_near/elk/board.exp.json index 2b2e89b8e..3bde4523c 100644 --- a/e2etests/testdata/stable/constant_near/elk/board.exp.json +++ b/e2etests/testdata/stable/constant_near/elk/board.exp.json @@ -6,8 +6,8 @@ "id": "x", "type": "", "pos": { - "x": 1961, - "y": 16 + "x": 12, + "y": 12 }, "width": 113, "height": 126, @@ -46,8 +46,8 @@ "id": "y", "type": "", "pos": { - "x": 1960, - "y": 242 + "x": 12, + "y": 238 }, "width": 114, "height": 126, @@ -86,8 +86,8 @@ "id": "The top of the mountain", "type": "text", "pos": { - "x": 1936, - "y": -28 + "x": -12, + "y": -32 }, "width": 162, "height": 24, @@ -126,8 +126,8 @@ "id": "Joe", "type": "person", "pos": { - "x": 1809, - "y": 129 + "x": -139, + "y": 125 }, "width": 131, "height": 126, @@ -166,8 +166,8 @@ "id": "Donald", "type": "person", "pos": { - "x": 2094, - "y": 129 + "x": 146, + "y": 125 }, "width": 155, "height": 126, @@ -206,8 +206,8 @@ "id": "bottom", "type": "text", "pos": { - "x": 1546, - "y": 388 + "x": -402, + "y": 384 }, "width": 943, "height": 130, @@ -246,8 +246,8 @@ "id": "i am top left", "type": "text", "pos": { - "x": 1445, - "y": -28 + "x": -503, + "y": -32 }, "width": 81, "height": 24, @@ -286,8 +286,8 @@ "id": "i am top right", "type": "text", "pos": { - "x": 2509, - "y": -28 + "x": 560, + "y": -32 }, "width": 91, "height": 24, @@ -326,8 +326,8 @@ "id": "i am bottom left", "type": "text", "pos": { - "x": 1418, - "y": 388 + "x": -530, + "y": 384 }, "width": 108, "height": 24, @@ -366,8 +366,8 @@ "id": "i am bottom right", "type": "text", "pos": { - "x": 2509, - "y": 388 + "x": 560, + "y": 384 }, "width": 118, "height": 24, @@ -430,12 +430,12 @@ "labelPercentage": 0, "route": [ { - "x": 2017.5, - "y": 142 + "x": 69, + "y": 138 }, { - "x": 2017.5, - "y": 242 + "x": 69, + "y": 238 } ], "animated": false, diff --git a/e2etests/testdata/stable/constant_near/elk/sketch.exp.svg b/e2etests/testdata/stable/constant_near/elk/sketch.exp.svg index a9a1c7387..c2022876a 100644 --- a/e2etests/testdata/stable/constant_near/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/constant_near/elk/sketch.exp.svg @@ -2,7 +2,7 @@ \ No newline at end of file diff --git a/e2etests/testdata/stable/constant_near_title/elk/board.exp.json b/e2etests/testdata/stable/constant_near_title/elk/board.exp.json new file mode 100644 index 000000000..cfd0c8a4f --- /dev/null +++ b/e2etests/testdata/stable/constant_near_title/elk/board.exp.json @@ -0,0 +1,459 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "poll the people", + "type": "", + "pos": { + "x": 81, + "y": 12 + }, + "width": 210, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "poll the people", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 110, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "results", + "type": "", + "pos": { + "x": 74, + "y": 238 + }, + "width": 153, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "results", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 53, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "unfavorable", + "type": "", + "pos": { + "x": 232, + "y": 464 + }, + "width": 191, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "unfavorable", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 91, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "favorable", + "type": "", + "pos": { + "x": 39, + "y": 464 + }, + "width": 173, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "favorable", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 73, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "will of the people", + "type": "", + "pos": { + "x": 12, + "y": 690 + }, + "width": 227, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "will of the people", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 127, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "title", + "type": "text", + "pos": { + "x": 84, + "y": -58 + }, + "width": 266, + "height": 50, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "# A winning strategy", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "markdown", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 266, + "labelHeight": 50, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(poll the people -> results)[0]", + "src": "poll the people", + "srcArrow": "none", + "srcLabel": "", + "dst": "results", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 151, + "y": 138 + }, + { + "x": 151, + "y": 238 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(results -> unfavorable)[0]", + "src": "results", + "srcArrow": "none", + "srcLabel": "", + "dst": "unfavorable", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 176.5, + "y": 364 + }, + { + "x": 176.5, + "y": 414 + }, + { + "x": 295.6666666666667, + "y": 414 + }, + { + "x": 295.6666666666667, + "y": 464 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(unfavorable -> poll the people)[0]", + "src": "unfavorable", + "srcArrow": "none", + "srcLabel": "", + "dst": "poll the people", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 359.3333333333333, + "y": 464 + }, + { + "x": 359.3333333333333, + "y": 188 + }, + { + "x": 221, + "y": 188 + }, + { + "x": 221, + "y": 138 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(results -> favorable)[0]", + "src": "results", + "srcArrow": "none", + "srcLabel": "", + "dst": "favorable", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 125.5, + "y": 364 + }, + { + "x": 125.5, + "y": 464 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(favorable -> will of the people)[0]", + "src": "favorable", + "srcArrow": "none", + "srcLabel": "", + "dst": "will of the people", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 125.5, + "y": 590 + }, + { + "x": 125.5, + "y": 690 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/constant_near_title/elk/sketch.exp.svg b/e2etests/testdata/stable/constant_near_title/elk/sketch.exp.svg new file mode 100644 index 000000000..e5ea8add8 --- /dev/null +++ b/e2etests/testdata/stable/constant_near_title/elk/sketch.exp.svg @@ -0,0 +1,796 @@ + +poll the peopleresultsunfavorablefavorablewill of the people

A winning strategy

+
+ + +
\ No newline at end of file From 36e221a6f5649bbf1e6b38324cec7c600ed963c5 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 25 Dec 2022 17:24:48 -0800 Subject: [PATCH 195/257] changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 425aab01c..fbd621f5d 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -18,6 +18,7 @@ Hope everyone is enjoying the holidays this week! - `class` shapes use monospaced font. [#521](https://github.com/terrastruct/d2/pull/521) - Sequence diagram edge group labels have more reasonable padding. [#512](https://github.com/terrastruct/d2/pull/512) - ELK layout engine preserves order of nodes. [#282](https://github.com/terrastruct/d2/issues/282) +- Markdown headings set font-family explicitly, so that external stylesheets with more specific targeting don't override it. [#525](https://github.com/terrastruct/d2/pull/525) #### Bugfixes ⛑️ From 409717b40d97c88525b6e9475afc98cb896c4a5d Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 25 Dec 2022 17:25:35 -0800 Subject: [PATCH 196/257] more specific doc --- ci/release/changelogs/next.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index fbd621f5d..2fe46e9ac 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -9,7 +9,7 @@ Hope everyone is enjoying the holidays this week! #### Features 🚀 - `sketch` flag renders the diagram to look like it was sketched by hand. [#492](https://github.com/terrastruct/d2/pull/492) -- `near` now takes constants like `top-center`, particularly useful for diagram titles. See [docs](https://d2lang.com/tour/text#how-do-i-position-text) for more. [#525](https://github.com/terrastruct/d2/pull/525) +- `near` now takes constants like `top-center`, particularly useful for diagram titles. See [docs](http://localhost:8888/tour/text#near-a-constant) for more. [#525](https://github.com/terrastruct/d2/pull/525) #### Improvements 🧹 From a09f614f5f66a2d3bd4de3c1fd6a357ca22901a6 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 25 Dec 2022 17:30:48 -0800 Subject: [PATCH 197/257] update tests --- d2renderers/d2sketch/testdata/twitter/sketch.exp.svg | 1 + e2etests/testdata/regression/elk_order/dagre/sketch.exp.svg | 1 + e2etests/testdata/regression/elk_order/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/chaos2/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/chaos2/elk/sketch.exp.svg | 1 + .../testdata/stable/giant_markdown_test/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/giant_markdown_test/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/hr/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/hr/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/latex/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/latex/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/li1/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/li1/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/li2/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/li2/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/li3/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/li3/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/li4/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/li4/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/lone_h1/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/lone_h1/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/markdown/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/markdown/elk/sketch.exp.svg | 1 + .../testdata/stable/markdown_stroke_fill/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/markdown_stroke_fill/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/md_2space_newline/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/md_2space_newline/elk/sketch.exp.svg | 1 + .../testdata/stable/md_backslash_newline/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/md_backslash_newline/elk/sketch.exp.svg | 1 + .../testdata/stable/md_code_block_fenced/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/md_code_block_fenced/elk/sketch.exp.svg | 1 + .../testdata/stable/md_code_block_indented/dagre/sketch.exp.svg | 1 + .../testdata/stable/md_code_block_indented/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/md_code_inline/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/md_code_inline/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/p/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/p/elk/sketch.exp.svg | 1 + e2etests/testdata/stable/pre/dagre/sketch.exp.svg | 1 + e2etests/testdata/stable/pre/elk/sketch.exp.svg | 1 + 39 files changed, 39 insertions(+) diff --git a/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg b/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg index 471e8fa0a..f93b93c1f 100644 --- a/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg @@ -282,6 +282,7 @@ width="3454" height="2449" viewBox="-100 -100 3454 2449">bearmama bearpapa bear + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/text_font_sizes/elk/board.exp.json b/e2etests/testdata/stable/text_font_sizes/elk/board.exp.json new file mode 100644 index 000000000..ae4e7c84e --- /dev/null +++ b/e2etests/testdata/stable/text_font_sizes/elk/board.exp.json @@ -0,0 +1,211 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "bear", + "type": "text", + "pos": { + "x": 64, + "y": 153 + }, + "width": 44, + "height": 28, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "bear", + "fontSize": 22, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 44, + "labelHeight": 28, + "zIndex": 0, + "level": 1 + }, + { + "id": "mama bear", + "type": "text", + "pos": { + "x": 12, + "y": 17 + }, + "width": 135, + "height": 36, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "mama bear", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 135, + "labelHeight": 36, + "zIndex": 0, + "level": 1 + }, + { + "id": "papa bear", + "type": "text", + "pos": { + "x": 167, + "y": 12 + }, + "width": 134, + "height": 41, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "transparent", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "papa bear", + "fontSize": 32, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": true, + "labelWidth": 134, + "labelHeight": 41, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(mama bear -> bear)[0]", + "src": "mama bear", + "srcArrow": "none", + "srcLabel": "", + "dst": "bear", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 79.5, + "y": 53 + }, + { + "x": 79.5, + "y": 153 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(papa bear -> bear)[0]", + "src": "papa bear", + "srcArrow": "none", + "srcLabel": "", + "dst": "bear", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 234, + "y": 53 + }, + { + "x": 234, + "y": 103 + }, + { + "x": 94.16666666666666, + "y": 103 + }, + { + "x": 94.16666666666666, + "y": 153 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/text_font_sizes/elk/sketch.exp.svg b/e2etests/testdata/stable/text_font_sizes/elk/sketch.exp.svg new file mode 100644 index 000000000..506609593 --- /dev/null +++ b/e2etests/testdata/stable/text_font_sizes/elk/sketch.exp.svg @@ -0,0 +1,805 @@ + +bearmama bearpapa bear + + + \ No newline at end of file From 9e658adf089c33d04eaf93c906d7352e15c62a94 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Sun, 25 Dec 2022 21:50:40 -0800 Subject: [PATCH 202/257] update tests --- .../d2sketch/testdata/twitter/sketch.exp.svg | 2 +- .../regression/elk_order/dagre/board.exp.json | 8 +- .../regression/elk_order/dagre/sketch.exp.svg | 2 +- .../regression/elk_order/elk/board.exp.json | 8 +- .../regression/elk_order/elk/sketch.exp.svg | 2 +- .../stable/chaos2/dagre/board.exp.json | 132 +++++++++--------- .../stable/chaos2/dagre/sketch.exp.svg | 13 +- .../testdata/stable/chaos2/elk/board.exp.json | 50 +++---- .../testdata/stable/chaos2/elk/sketch.exp.svg | 15 +- .../constant_near_stress/dagre/board.exp.json | 58 ++++---- .../constant_near_stress/dagre/sketch.exp.svg | 13 +- .../constant_near_stress/elk/board.exp.json | 58 ++++---- .../constant_near_stress/elk/sketch.exp.svg | 13 +- .../constant_near_title/dagre/board.exp.json | 2 +- .../constant_near_title/dagre/sketch.exp.svg | 2 +- .../constant_near_title/elk/board.exp.json | 2 +- .../constant_near_title/elk/sketch.exp.svg | 2 +- .../giant_markdown_test/dagre/board.exp.json | 2 +- .../giant_markdown_test/dagre/sketch.exp.svg | 2 +- .../giant_markdown_test/elk/board.exp.json | 2 +- .../giant_markdown_test/elk/sketch.exp.svg | 2 +- .../testdata/stable/hr/dagre/board.exp.json | 2 +- .../testdata/stable/hr/dagre/sketch.exp.svg | 2 +- .../testdata/stable/hr/elk/board.exp.json | 2 +- .../testdata/stable/hr/elk/sketch.exp.svg | 2 +- .../stable/latex/dagre/board.exp.json | 6 +- .../stable/latex/dagre/sketch.exp.svg | 2 +- .../testdata/stable/latex/elk/board.exp.json | 6 +- .../testdata/stable/latex/elk/sketch.exp.svg | 2 +- .../testdata/stable/li1/dagre/board.exp.json | 2 +- .../testdata/stable/li1/dagre/sketch.exp.svg | 2 +- .../testdata/stable/li1/elk/board.exp.json | 2 +- .../testdata/stable/li1/elk/sketch.exp.svg | 2 +- .../testdata/stable/li2/dagre/board.exp.json | 2 +- .../testdata/stable/li2/dagre/sketch.exp.svg | 2 +- .../testdata/stable/li2/elk/board.exp.json | 2 +- .../testdata/stable/li2/elk/sketch.exp.svg | 2 +- .../testdata/stable/li3/dagre/board.exp.json | 2 +- .../testdata/stable/li3/dagre/sketch.exp.svg | 2 +- .../testdata/stable/li3/elk/board.exp.json | 2 +- .../testdata/stable/li3/elk/sketch.exp.svg | 2 +- .../testdata/stable/li4/dagre/board.exp.json | 2 +- .../testdata/stable/li4/dagre/sketch.exp.svg | 2 +- .../testdata/stable/li4/elk/board.exp.json | 2 +- .../testdata/stable/li4/elk/sketch.exp.svg | 2 +- .../stable/lone_h1/dagre/board.exp.json | 2 +- .../stable/lone_h1/dagre/sketch.exp.svg | 2 +- .../stable/lone_h1/elk/board.exp.json | 2 +- .../stable/lone_h1/elk/sketch.exp.svg | 2 +- .../stable/markdown/dagre/board.exp.json | 2 +- .../stable/markdown/dagre/sketch.exp.svg | 2 +- .../stable/markdown/elk/board.exp.json | 2 +- .../stable/markdown/elk/sketch.exp.svg | 2 +- .../markdown_stroke_fill/dagre/board.exp.json | 4 +- .../markdown_stroke_fill/dagre/sketch.exp.svg | 2 +- .../markdown_stroke_fill/elk/board.exp.json | 4 +- .../markdown_stroke_fill/elk/sketch.exp.svg | 2 +- .../md_2space_newline/dagre/board.exp.json | 2 +- .../md_2space_newline/dagre/sketch.exp.svg | 2 +- .../md_2space_newline/elk/board.exp.json | 2 +- .../md_2space_newline/elk/sketch.exp.svg | 2 +- .../md_backslash_newline/dagre/board.exp.json | 2 +- .../md_backslash_newline/dagre/sketch.exp.svg | 2 +- .../md_backslash_newline/elk/board.exp.json | 2 +- .../md_backslash_newline/elk/sketch.exp.svg | 2 +- .../md_code_block_fenced/dagre/board.exp.json | 2 +- .../md_code_block_fenced/dagre/sketch.exp.svg | 2 +- .../md_code_block_fenced/elk/board.exp.json | 2 +- .../md_code_block_fenced/elk/sketch.exp.svg | 2 +- .../dagre/board.exp.json | 2 +- .../dagre/sketch.exp.svg | 2 +- .../md_code_block_indented/elk/board.exp.json | 2 +- .../md_code_block_indented/elk/sketch.exp.svg | 2 +- .../md_code_inline/dagre/board.exp.json | 2 +- .../md_code_inline/dagre/sketch.exp.svg | 2 +- .../stable/md_code_inline/elk/board.exp.json | 2 +- .../stable/md_code_inline/elk/sketch.exp.svg | 2 +- .../testdata/stable/p/dagre/board.exp.json | 2 +- .../testdata/stable/p/dagre/sketch.exp.svg | 2 +- e2etests/testdata/stable/p/elk/board.exp.json | 2 +- e2etests/testdata/stable/p/elk/sketch.exp.svg | 2 +- .../testdata/stable/pre/dagre/board.exp.json | 2 +- .../testdata/stable/pre/dagre/sketch.exp.svg | 2 +- .../testdata/stable/pre/elk/board.exp.json | 2 +- .../testdata/stable/pre/elk/sketch.exp.svg | 2 +- .../TestExport/shape/text_color.exp.json | 2 +- 86 files changed, 258 insertions(+), 274 deletions(-) diff --git a/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg b/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg index f93b93c1f..a45b29f99 100644 --- a/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg +++ b/d2renderers/d2sketch/testdata/twitter/sketch.exp.svg @@ -796,7 +796,7 @@ width="3454" height="2449" viewBox="-100 -100 3454 2449">aabbllmm

nn

-
oocciikkdd

gg

-
hhjj

ee

-
ff1122 334455667788 - +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 + - + - + aabbllmm

nn

-
oocciikkdd

gg

-
hhjj

ee

-
ff1122 334455667788 - +aabbllmmnnoocciikkddgghhjjeeff1122 334455667788 + - + - - + + xy

The top of the mountain

-
JoeDonald

Cats, no less liquid than their shadows, offer no angles to the wind.

+xyThe top of the mountainJoeDonald

Cats, no less liquid than their shadows, offer no angles to the wind.

If we can't fix it, it ain't broke.

Dieters live life in the fasting lane.

-

i am top left

-

i am top right

-

i am bottom left

-

i am bottom right

-
- +
i am top lefti am top righti am bottom lefti am bottom right + xy

The top of the mountain

-
JoeDonald

Cats, no less liquid than their shadows, offer no angles to the wind.

+xyThe top of the mountainJoeDonald

Cats, no less liquid than their shadows, offer no angles to the wind.

If we can't fix it, it ain't broke.

Dieters live life in the fasting lane.

-

i am top left

-

i am top right

-

i am bottom left

-

i am bottom right

-
- +
i am top lefti am top righti am bottom lefti am bottom right + poll the peopleresultsunfavorablefavorablewill of the people

A winning strategy

-
+ poll the peopleresultsunfavorablefavorablewill of the people

A winning strategy

-
+ mixed togethersugarsolution we get +mixed togethersugarsolution we get mixed togethersugarsolution we get +mixed togethersugarsolution we get

Markdown: Syntax

-
ab +ab

Markdown: Syntax

-
ab +ab markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
+ markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
+ markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
+ markdown

Lorem ipsum dolor sit amet, consectetur adipiscing elit,
sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.

-
+

code

-
ab +ab

code

-
ab +ab x + + + + +y + + + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/tooltips/elk/board.exp.json b/e2etests/testdata/stable/tooltips/elk/board.exp.json new file mode 100644 index 000000000..24850e39e --- /dev/null +++ b/e2etests/testdata/stable/tooltips/elk/board.exp.json @@ -0,0 +1,127 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "x", + "type": "", + "pos": { + "x": 12, + "y": 12 + }, + "width": 113, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "Total abstinence is easier than perfect moderation", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "x", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "y", + "type": "", + "pos": { + "x": 12, + "y": 238 + }, + "width": 114, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "Gee, I feel kind of LIGHT in the head now,\nknowing I can't make my satellite dish PAYMENTS!", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "y", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 14, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(x -> y)[0]", + "src": "x", + "srcArrow": "none", + "srcLabel": "", + "dst": "y", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 69, + "y": 138 + }, + { + "x": 69, + "y": 238 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/tooltips/elk/sketch.exp.svg b/e2etests/testdata/stable/tooltips/elk/sketch.exp.svg new file mode 100644 index 000000000..c08153e08 --- /dev/null +++ b/e2etests/testdata/stable/tooltips/elk/sketch.exp.svg @@ -0,0 +1,44 @@ + +x + + + + +y + + + + + + + + \ No newline at end of file From 51d51709b07830fe21eb6b6fde9073642c0386f4 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Tue, 27 Dec 2022 00:20:49 -0800 Subject: [PATCH 216/257] svg works --- d2renderers/d2svg/d2svg.go | 1 + e2etests/testdata/stable/tooltips/dagre/sketch.exp.svg | 5 +++-- e2etests/testdata/stable/tooltips/elk/sketch.exp.svg | 5 +++-- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 8a0a28546..0c6eecd35 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -847,6 +847,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske targetShape.Pos.Y-tooltipIconLen/2, tooltipIcon, ) + fmt.Fprintf(writer, `%s`, targetShape.Tooltip) } fmt.Fprintf(writer, ``) diff --git a/e2etests/testdata/stable/tooltips/dagre/sketch.exp.svg b/e2etests/testdata/stable/tooltips/dagre/sketch.exp.svg index 50bde4261..ef4885b88 100644 --- a/e2etests/testdata/stable/tooltips/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/tooltips/dagre/sketch.exp.svg @@ -23,12 +23,13 @@ width="314" height="552" viewBox="-100 -100 314 552">x - - - +x + + + + + + + + + + + -Total abstinence is easier than perfect moderationy - - - +Total abstinence is easier than perfect moderationy + + + + + + + + + + + Gee, I feel kind of LIGHT in the head now, knowing I can't make my satellite dish PAYMENTS! x - - - +x + + + + + + + + + + + -Total abstinence is easier than perfect moderationy - - - +Total abstinence is easier than perfect moderationy + + + + + + + + + + + Gee, I feel kind of LIGHT in the head now, knowing I can't make my satellite dish PAYMENTS! `, d2fonts.FontEncodings[d2fonts.SourceSansPro.Font(0, d2fonts.FONT_STYLE_REGULAR)]) + } + + closingIndex := strings.LastIndex(svg, "") + svg = svg[:closingIndex] + appendix + svg[closingIndex:] + + return []byte(svg) +} + +func generateTooltipAppendix(diagram *d2target.Diagram, ruler *textmeasure.Ruler, svg string) (string, int, int) { + tl, br := diagram.BoundingBox() + + maxWidth, totalHeight := 0, 0 + + var tooltipLines []string + i := 1 + for _, s := range diagram.Shapes { + if s.Tooltip != "" { + line, w, h := generateTooltipLine(i, br.Y+(PAD_TOP*2)+totalHeight, s.Tooltip, ruler) + i++ + tooltipLines = append(tooltipLines, line) + maxWidth = go2.IntMax(maxWidth, w) + totalHeight += h + SPACER + } + } + + return fmt.Sprintf(`%s +`, tl.X, br.Y, (br.X - tl.X), strings.Join(tooltipLines, "\n")), maxWidth, totalHeight +} + +func generateTooltipLine(i, y int, text string, ruler *textmeasure.Ruler) (string, int, int) { + mtext := &d2target.MText{ + Text: text, + FontSize: FONT_SIZE, + IsBold: false, + IsItalic: false, + Language: "", + } + + dims := d2graph.GetTextDimensions(nil, ruler, mtext, nil) + + // TODO box-shadow: 0px 0px 32px rgba(31, 36, 58, 0.1); + line := fmt.Sprintf(``, + 0, y) + + line += fmt.Sprintf(`%d`, + 0, y+5, 16, i) + + line += fmt.Sprintf(`%s`, + 32, y, FONT_SIZE, d2svg.RenderText(text, 32, float64(dims.Height))) + + return line, dims.Width, dims.Height +} diff --git a/d2renderers/d2svg/appendix/appendix_test.go b/d2renderers/d2svg/appendix/appendix_test.go new file mode 100644 index 000000000..bb26a4372 --- /dev/null +++ b/d2renderers/d2svg/appendix/appendix_test.go @@ -0,0 +1,102 @@ +package appendix_test + +import ( + "context" + "encoding/xml" + "io/ioutil" + "os" + "path/filepath" + "strings" + "testing" + + "cdr.dev/slog" + + tassert "github.com/stretchr/testify/assert" + + "oss.terrastruct.com/util-go/assert" + "oss.terrastruct.com/util-go/diff" + + "oss.terrastruct.com/d2/d2layouts/d2dagrelayout" + "oss.terrastruct.com/d2/d2lib" + "oss.terrastruct.com/d2/d2renderers/d2svg" + "oss.terrastruct.com/d2/d2renderers/d2svg/appendix" + "oss.terrastruct.com/d2/lib/log" + "oss.terrastruct.com/d2/lib/textmeasure" +) + +func TestAppendix(t *testing.T) { + t.Parallel() + + tcs := []testCase{ + { + name: "basic", + script: `x: { tooltip: Total abstinence is easier than perfect moderation } +y: { tooltip: Gee, I feel kind of LIGHT in the head now,\nknowing I can't make my satellite dish PAYMENTS! } +x -> y +`, + }, + } + runa(t, tcs) +} + +type testCase struct { + name string + script string + skip bool +} + +func runa(t *testing.T, tcs []testCase) { + for _, tc := range tcs { + tc := tc + t.Run(tc.name, func(t *testing.T) { + if tc.skip { + t.Skip() + } + t.Parallel() + + run(t, tc) + }) + } +} + +func run(t *testing.T, tc testCase) { + ctx := context.Background() + ctx = log.WithTB(ctx, t, nil) + ctx = log.Leveled(ctx, slog.LevelDebug) + + ruler, err := textmeasure.NewRuler() + if !tassert.Nil(t, err) { + return + } + + diagram, _, err := d2lib.Compile(ctx, tc.script, &d2lib.CompileOptions{ + Ruler: ruler, + ThemeID: 0, + Layout: d2dagrelayout.Layout, + }) + if !tassert.Nil(t, err) { + return + } + + dataPath := filepath.Join("testdata", strings.TrimPrefix(t.Name(), "TestAppendix/")) + pathGotSVG := filepath.Join(dataPath, "sketch.got.svg") + + svgBytes, err := d2svg.Render(diagram, &d2svg.RenderOpts{ + Pad: d2svg.DEFAULT_PADDING, + }) + assert.Success(t, err) + svgBytes = appendix.AppendTooltips(diagram, ruler, svgBytes) + + err = os.MkdirAll(dataPath, 0755) + assert.Success(t, err) + err = ioutil.WriteFile(pathGotSVG, svgBytes, 0600) + assert.Success(t, err) + defer os.Remove(pathGotSVG) + + var xmlParsed interface{} + err = xml.Unmarshal(svgBytes, &xmlParsed) + assert.Success(t, err) + + err = diff.Testdata(filepath.Join(dataPath, "sketch"), ".svg", svgBytes) + assert.Success(t, err) +} diff --git a/d2renderers/d2svg/appendix/testdata/basic/sketch.exp.svg b/d2renderers/d2svg/appendix/testdata/basic/sketch.exp.svg new file mode 100644 index 000000000..f88e30ee3 --- /dev/null +++ b/d2renderers/d2svg/appendix/testdata/basic/sketch.exp.svg @@ -0,0 +1,68 @@ + +x + + + + + + + + + + + + +Total abstinence is easier than perfect moderationy + + + + + + + + + + + + +Gee, I feel kind of LIGHT in the head now, +knowing I can't make my satellite dish PAYMENTS! + + +1Total abstinence is easier than perfect moderation +2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! + \ No newline at end of file diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index 0c6eecd35..2240669a5 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -442,7 +442,7 @@ func drawConnection(writer io.Writer, labelMaskID string, connection d2target.Co fontClass, x, y, textStyle, - renderText(connection.Label, x, float64(connection.LabelHeight)), + RenderText(connection.Label, x, float64(connection.LabelHeight)), ) } @@ -478,7 +478,7 @@ func renderArrowheadLabel(connection d2target.Connection, text string, position, return fmt.Sprintf(`%s`, x, y, textStyle, - renderText(text, x, height), + RenderText(text, x, height), ) } @@ -833,7 +833,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske fontClass, x, y, textStyle, - renderText(targetShape.Label, x, float64(targetShape.LabelHeight)), + RenderText(targetShape.Label, x, float64(targetShape.LabelHeight)), ) if targetShape.Blend { labelMask = makeLabelMask(labelTL, targetShape.LabelWidth, targetShape.LabelHeight-d2graph.INNER_LABEL_PADDING) @@ -854,7 +854,7 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske return labelMask, nil } -func renderText(text string, x, height float64) string { +func RenderText(text string, x, height float64) string { if !strings.Contains(text, "\n") { return svg.EscapeText(text) } diff --git a/lib/svg/appendix.go b/lib/svg/appendix.go deleted file mode 100644 index e5aab7cde..000000000 --- a/lib/svg/appendix.go +++ /dev/null @@ -1,3 +0,0 @@ -// appendix.go writes appendices/footnotes to SVG - -package svg diff --git a/main.go b/main.go index 45d154f1f..e87b5149e 100644 --- a/main.go +++ b/main.go @@ -21,6 +21,7 @@ import ( "oss.terrastruct.com/d2/d2plugin" "oss.terrastruct.com/d2/d2renderers/d2fonts" "oss.terrastruct.com/d2/d2renderers/d2svg" + "oss.terrastruct.com/d2/d2renderers/d2svg/appendix" "oss.terrastruct.com/d2/d2themes" "oss.terrastruct.com/d2/d2themes/d2themescatalog" "oss.terrastruct.com/d2/lib/imgbundler" @@ -247,7 +248,8 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketc out := svg if filepath.Ext(outputPath) == ".png" { - svg := svg + svg := appendix.AppendTooltips(diagram, ruler, svg) + if !bundle { var bundleErr2 error svg, bundleErr2 = imgbundler.BundleRemote(ctx, ms, svg) From 65df91b70ea0580f27b795e91f771414adf00842 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 28 Dec 2022 11:39:20 -0800 Subject: [PATCH 220/257] save --- d2renderers/d2svg/appendix/appendix.go | 36 +++++--- d2renderers/d2svg/appendix/appendix_test.go | 44 +++++++++- .../diagram_wider_than_tooltip/sketch.exp.svg | 87 +++++++++++++++++++ .../sketch.exp.svg | 6 +- 4 files changed, 155 insertions(+), 18 deletions(-) create mode 100644 d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg rename d2renderers/d2svg/appendix/testdata/{basic => tooltip_wider_than_diagram}/sketch.exp.svg (99%) diff --git a/d2renderers/d2svg/appendix/appendix.go b/d2renderers/d2svg/appendix/appendix.go index 368bbefc0..28c5d0f22 100644 --- a/d2renderers/d2svg/appendix/appendix.go +++ b/d2renderers/d2svg/appendix/appendix.go @@ -19,10 +19,11 @@ import ( ) const ( - PAD_TOP = 50 - PAD_SIDES = 40 - FONT_SIZE = 16 - SPACER = 20 + PAD_TOP = 50 + PAD_SIDES = 40 + FONT_SIZE = 16 + SPACER = 20 + ICON_RADIUS = 16 ) var viewboxRegex = regexp.MustCompile(`viewBox=\"([0-9\- ]+)\"`) @@ -47,15 +48,14 @@ func AppendTooltips(diagram *d2target.Diagram, ruler *textmeasure.Ruler, in []by tl, br := diagram.BoundingBox() seperator := fmt.Sprintf(``, - tl.X-PAD_SIDES, br.Y+PAD_TOP, go2.IntMax(w+PAD_SIDES, br.Y)+PAD_SIDES, br.Y+PAD_TOP) + tl.X-PAD_SIDES, br.Y+PAD_TOP, go2.IntMax(w, br.X)+PAD_SIDES, br.Y+PAD_TOP) appendix = seperator + appendix w -= viewboxPadLeft w += PAD_SIDES * 2 if viewboxWidth < w { - viewboxWidth = w + PAD_SIDES + viewboxWidth = w } - viewboxWidth += PAD_SIDES viewboxHeight += h + PAD_TOP @@ -81,6 +81,17 @@ func AppendTooltips(diagram *d2target.Diagram, ruler *textmeasure.Ruler, in []by } ]]>`, d2fonts.FontEncodings[d2fonts.SourceSansPro.Font(0, d2fonts.FONT_STYLE_REGULAR)]) } + if !strings.Contains(svg, `font-family: "font-bold"`) { + appendix += fmt.Sprintf(``, d2fonts.FontEncodings[d2fonts.SourceSansPro.Font(0, d2fonts.FONT_STYLE_BOLD)]) + } closingIndex := strings.LastIndex(svg, "") svg = svg[:closingIndex] + appendix + svg[closingIndex:] @@ -113,22 +124,19 @@ func generateTooltipLine(i, y int, text string, ruler *textmeasure.Ruler) (strin mtext := &d2target.MText{ Text: text, FontSize: FONT_SIZE, - IsBold: false, - IsItalic: false, - Language: "", } dims := d2graph.GetTextDimensions(nil, ruler, mtext, nil) // TODO box-shadow: 0px 0px 32px rgba(31, 36, 58, 0.1); line := fmt.Sprintf(``, - 0, y) + ICON_RADIUS, y) line += fmt.Sprintf(`%d`, - 0, y+5, 16, i) + ICON_RADIUS, y+5, FONT_SIZE, i) line += fmt.Sprintf(`%s`, - 32, y, FONT_SIZE, d2svg.RenderText(text, 32, float64(dims.Height))) + ICON_RADIUS*3, y, FONT_SIZE, d2svg.RenderText(text, ICON_RADIUS*3, float64(dims.Height))) - return line, dims.Width, dims.Height + return line, dims.Width + ICON_RADIUS*3, dims.Height } diff --git a/d2renderers/d2svg/appendix/appendix_test.go b/d2renderers/d2svg/appendix/appendix_test.go index bb26a4372..a589498cf 100644 --- a/d2renderers/d2svg/appendix/appendix_test.go +++ b/d2renderers/d2svg/appendix/appendix_test.go @@ -29,10 +29,52 @@ func TestAppendix(t *testing.T) { tcs := []testCase{ { - name: "basic", + name: "tooltip_wider_than_diagram", script: `x: { tooltip: Total abstinence is easier than perfect moderation } y: { tooltip: Gee, I feel kind of LIGHT in the head now,\nknowing I can't make my satellite dish PAYMENTS! } x -> y +`, + }, + { + name: "diagram_wider_than_tooltip", + script: `shape: sequence_diagram + +customer +issuer +store: { tooltip: Like starbucks or something } +acquirer: { tooltip: I'm not sure what this is } +network +customer bank +store bank + +customer: {shape: person} +customer bank: { + shape: image + icon: https://cdn-icons-png.flaticon.com/512/858/858170.png +} +store bank: { + shape: image + icon: https://cdn-icons-png.flaticon.com/512/858/858170.png +} + +initial transaction: { + customer -> store: 1 banana please + store -> customer: '$10 dollars' +} +customer.internal -> customer.internal: "thinking: wow, inflation" +customer.internal -> customer bank: checks bank account +customer bank -> customer.internal: 'Savings: $11' +customer."An error in judgement is about to occur" +customer -> store: I can do that, here's my card +payment processor behind the scenes: { + store -> acquirer: Run this card + acquirer -> network: Process to card issuer + simplified: { + network -> issuer: Process this payment + issuer -> customer bank: '$10 debit' + acquirer -> store bank: '$10 credit' + } +} `, }, } diff --git a/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg b/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg new file mode 100644 index 000000000..66530c536 --- /dev/null +++ b/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg @@ -0,0 +1,87 @@ + +customerissuerstore + + + + + + + + + + + + +Like starbucks or somethingacquirer + + + + + + + + + + + + +I'm not sure what this isnetworkcustomer bankstore bankinitial transactionpayment processor behind the scenessimplified 1 banana please$10 dollarsthinking: wow, inflationchecks bank accountSavings: $11I can do that, here's my cardRun this cardProcess to card issuerProcess this payment$10 debit$10 creditAn error in judgement is about to occur + + + + + + + + + + + + + + + +1Like starbucks or something +2I'm not sure what this is + \ No newline at end of file diff --git a/d2renderers/d2svg/appendix/testdata/basic/sketch.exp.svg b/d2renderers/d2svg/appendix/testdata/tooltip_wider_than_diagram/sketch.exp.svg similarity index 99% rename from d2renderers/d2svg/appendix/testdata/basic/sketch.exp.svg rename to d2renderers/d2svg/appendix/testdata/tooltip_wider_than_diagram/sketch.exp.svg index f88e30ee3..126c22303 100644 --- a/d2renderers/d2svg/appendix/testdata/basic/sketch.exp.svg +++ b/d2renderers/d2svg/appendix/testdata/tooltip_wider_than_diagram/sketch.exp.svg @@ -2,7 +2,7 @@ 1Total abstinence is easier than perfect moderation +2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! customerissuerstore - - - - - - - - - - - - -Like starbucks or somethingacquirer - - - - - - - - - - - - -I'm not sure what this isnetworkcustomer bankstore bankinitial transactionpayment processor behind the scenessimplified 1 banana please$10 dollarsthinking: wow, inflationchecks bank accountSavings: $11I can do that, here's my cardRun this cardProcess to card issuerProcess this payment$10 debit$10 creditAn error in judgement is about to occur +customerissuerstore1Like starbucks or somethingacquirer2I'm not sure what this isnetworkcustomer bankstore bankinitial transactionpayment processor behind the scenessimplified 1 banana please$10 dollarsthinking: wow, inflationchecks bank accountSavings: $11I can do that, here's my cardRun this cardProcess to card issuerProcess this payment$10 debit$10 creditAn error in judgement is about to occur @@ -74,8 +48,8 @@ width="1959" height="2297" viewBox="-175 -47 1959 2297">1Like starbucks or something -2I'm not sure what this is +}]]>1Like starbucks or something +2I'm not sure what this is x - - - - - - - - - - - - -Total abstinence is easier than perfect moderationy - - - - - - - - - - - - -Gee, I feel kind of LIGHT in the head now, +x1Total abstinence is easier than perfect moderationy2Gee, I feel kind of LIGHT in the head now, knowing I can't make my satellite dish PAYMENTS! @@ -55,8 +29,8 @@ knowing I can't make my satellite dish PAYMENTS!1Total abstinence is easier than perfect moderation -2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! +}]]>1Total abstinence is easier than perfect moderation +2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! x - - - - - +x + + + + + - - + + -Total abstinence is easier than perfect moderationy - - - - - +Total abstinence is easier than perfect moderationy + + + + + - - + + diff --git a/e2etests/testdata/stable/tooltips/elk/sketch.exp.svg b/e2etests/testdata/stable/tooltips/elk/sketch.exp.svg index 5990f5c5c..8c584ce14 100644 --- a/e2etests/testdata/stable/tooltips/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/tooltips/elk/sketch.exp.svg @@ -18,29 +18,29 @@ width="314" height="552" viewBox="-88 -88 314 552">x - - - - - +x + + + + + - - + + -Total abstinence is easier than perfect moderationy - - - - - +Total abstinence is easier than perfect moderationy + + + + + - - + + From 0935ce90af8a176c426f19947e1bdad1b975d7a4 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 28 Dec 2022 14:33:09 -0800 Subject: [PATCH 224/257] changelog --- ci/release/changelogs/next.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index d3ade4923..50ccdb876 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -1,5 +1,7 @@ #### Features 🚀 +- Tooltips on shapes. See [https://d2lang.com/tour/tooltips](https://d2lang.com/tour/tooltips). [#545](https://github.com/terrastruct/d2/pull/545) + #### Improvements 🧹 #### Bugfixes ⛑️ From 6d4e0cd64cbf417d40fd6bc6e4b4657aca0adbc5 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 28 Dec 2022 14:54:04 -0800 Subject: [PATCH 225/257] add ascii diagram --- d2renderers/d2svg/appendix/appendix.go | 29 ++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/d2renderers/d2svg/appendix/appendix.go b/d2renderers/d2svg/appendix/appendix.go index d3eca6479..8dbc399cb 100644 --- a/d2renderers/d2svg/appendix/appendix.go +++ b/d2renderers/d2svg/appendix/appendix.go @@ -18,11 +18,32 @@ import ( "oss.terrastruct.com/util-go/go2" ) +// ┌──────────────┐ +// │ │ +// │ DIAGRAM │ +// │ │ +// PAD_ │ │ +// SIDES │ │ +// │ │ │ +// │ └──────────────┘ +// ▼ ◄────── PAD_TOP +// +// ───────────────────────── +// +// +// 1. asdfasdf +// +// ◄──── SPACER +// 2. qwerqwer +// +// + const ( - PAD_TOP = 50 - PAD_SIDES = 40 + PAD_TOP = 50 + PAD_SIDES = 40 + SPACER = 20 + FONT_SIZE = 16 - SPACER = 20 ICON_RADIUS = 16 ) @@ -63,9 +84,9 @@ func AppendTooltips(diagram *d2target.Diagram, ruler *textmeasure.Ruler, in []by widthMatch := widthRegex.FindStringSubmatch(svg) heightMatch := heightRegex.FindStringSubmatch(svg) - newWidth := fmt.Sprintf(`width="%s"`, strconv.Itoa(viewboxWidth)) newHeight := fmt.Sprintf(`height="%s"`, strconv.Itoa(viewboxHeight)) + svg = strings.Replace(svg, viewboxMatch[0], newViewbox, 1) svg = strings.Replace(svg, widthMatch[0], newWidth, 1) svg = strings.Replace(svg, heightMatch[0], newHeight, 1) From 36ef848a82744b849e21dc0ba25067e1a1817649 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 28 Dec 2022 14:58:27 -0800 Subject: [PATCH 226/257] len -> radius --- d2renderers/d2svg/d2svg.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index bf13bfd72..d6a799274 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -40,7 +40,7 @@ const ( MIN_ARROWHEAD_STROKE_WIDTH = 2 threeDeeOffset = 15 - tooltipIconLen = 32 + tooltipIconRadius = 16 ) var multipleOffset = geo.NewVector(10, -10) @@ -843,8 +843,8 @@ func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2ske if targetShape.Tooltip != "" { fmt.Fprintf(writer, `%s`, - targetShape.Pos.X+targetShape.Width-tooltipIconLen/2, - targetShape.Pos.Y-tooltipIconLen/2, + targetShape.Pos.X+targetShape.Width-tooltipIconRadius, + targetShape.Pos.Y-tooltipIconRadius, TooltipIcon, ) fmt.Fprintf(writer, `%s`, targetShape.Tooltip) From e7aa4f8d1929fab1bcea83d4d1ce22eea5b3b6d8 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 28 Dec 2022 15:15:38 -0800 Subject: [PATCH 227/257] fix tooltip shadow --- d2renderers/d2svg/appendix/appendix.go | 6 ++++-- .../testdata/diagram_wider_than_tooltip/sketch.exp.svg | 9 ++++++--- .../testdata/tooltip_wider_than_diagram/sketch.exp.svg | 9 ++++++--- d2renderers/d2svg/d2svg.go | 4 ++-- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/d2renderers/d2svg/appendix/appendix.go b/d2renderers/d2svg/appendix/appendix.go index 8dbc399cb..e0a131b71 100644 --- a/d2renderers/d2svg/appendix/appendix.go +++ b/d2renderers/d2svg/appendix/appendix.go @@ -169,8 +169,10 @@ func generateTooltipLine(i, y int, text string, ruler *textmeasure.Ruler) (strin dims := d2graph.GetTextDimensions(nil, ruler, mtext, nil) - // TODO box-shadow: 0px 0px 32px rgba(31, 36, 58, 0.1); - line := fmt.Sprintf(`%s`, + // filter: drop-shadow(0px 0px 32px #4444dd); + // filter: drop-shadow(0px 0px 32px rgba(31, 36, 58, 0.1)); + // TODO box-shadow: 0px 0px 32px rgba(31 36 58 0.1); + line := fmt.Sprintf(`%s`, 0, y, generateNumberedIcon(i, 0, 0)) line += fmt.Sprintf(`%s`, diff --git a/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg b/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg index 08a8b08b2..268e98514 100644 --- a/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg +++ b/d2renderers/d2svg/appendix/testdata/diagram_wider_than_tooltip/sketch.exp.svg @@ -18,7 +18,7 @@ width="1959" height="2297" viewBox="-175 -47 1959 2297">customerissuerstore1Like starbucks or somethingacquirer2I'm not sure what this isnetworkcustomer bankstore bankinitial transactionpayment processor behind the scenessimplified 1 banana please$10 dollarsthinking: wow, inflationchecks bank accountSavings: $11I can do that, here's my cardRun this cardProcess to card issuerProcess this payment$10 debit$10 creditAn error in judgement is about to occur +customerissuerstore1Like starbucks or somethingacquirer2I'm not sure what this isnetworkcustomer bankstore bankinitial transactionpayment processor behind the scenessimplified 1 banana please$10 dollarsthinking: wow, inflationchecks bank accountSavings: $11I can do that, here's my cardRun this cardProcess to card issuerProcess this payment$10 debit$10 creditAn error in judgement is about to occur @@ -42,14 +42,17 @@ width="1959" height="2297" viewBox="-175 -47 1959 2297">1Like starbucks or something -2I'm not sure what this is +}]]>1Like starbucks or something +2I'm not sure what this is x1Total abstinence is easier than perfect moderationy2Gee, I feel kind of LIGHT in the head now, +x1Total abstinence is easier than perfect moderationy2Gee, I feel kind of LIGHT in the head now, knowing I can't make my satellite dish PAYMENTS! 1Total abstinence is easier than perfect moderation -2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! +}]]>1Total abstinence is easier than perfect moderation +2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! x +x @@ -31,7 +31,7 @@ width="314" height="552" viewBox="-100 -100 314 552"> -Total abstinence is easier than perfect moderationy +Total abstinence is easier than perfect moderationy @@ -49,6 +49,9 @@ knowing I can't make my satellite dish PAYMENTS! x +x @@ -31,7 +31,7 @@ width="314" height="552" viewBox="-88 -88 314 552"> -Total abstinence is easier than perfect moderationy +Total abstinence is easier than perfect moderationy @@ -49,6 +49,9 @@ knowing I can't make my satellite dish PAYMENTS! x + + + + + + + + + + + +y + + + + + + + + + + + + +Gee, I feel kind of LIGHT in the head now, +knowing I can't make my satellite dish PAYMENTS! + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/links/elk/board.exp.json b/e2etests/testdata/stable/links/elk/board.exp.json new file mode 100644 index 000000000..69c78025b --- /dev/null +++ b/e2etests/testdata/stable/links/elk/board.exp.json @@ -0,0 +1,127 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "x", + "type": "", + "pos": { + "x": 12, + "y": 12 + }, + "width": 113, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "https://d2lang.com", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "x", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "y", + "type": "", + "pos": { + "x": 12, + "y": 238 + }, + "width": 114, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "Gee, I feel kind of LIGHT in the head now,\nknowing I can't make my satellite dish PAYMENTS!", + "link": "https://terrastruct.com", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "y", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 14, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(x -> y)[0]", + "src": "x", + "srcArrow": "none", + "srcLabel": "", + "dst": "y", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 69, + "y": 138 + }, + { + "x": 69, + "y": 238 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/links/elk/sketch.exp.svg b/e2etests/testdata/stable/links/elk/sketch.exp.svg new file mode 100644 index 000000000..083055954 --- /dev/null +++ b/e2etests/testdata/stable/links/elk/sketch.exp.svg @@ -0,0 +1,72 @@ + +x + + + + + + + + + + + +y + + + + + + + + + + + + +Gee, I feel kind of LIGHT in the head now, +knowing I can't make my satellite dish PAYMENTS! + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/tooltips/dagre/sketch.exp.svg b/e2etests/testdata/stable/tooltips/dagre/sketch.exp.svg index a18a668c0..083bb23f6 100644 --- a/e2etests/testdata/stable/tooltips/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/tooltips/dagre/sketch.exp.svg @@ -18,7 +18,7 @@ width="314" height="552" viewBox="-100 -100 314 552">x +x @@ -31,7 +31,7 @@ width="314" height="552" viewBox="-100 -100 314 552"> -Total abstinence is easier than perfect moderationy +Total abstinence is easier than perfect moderationy @@ -49,7 +49,7 @@ knowing I can't make my satellite dish PAYMENTS! x +x @@ -31,7 +31,7 @@ width="314" height="552" viewBox="-88 -88 314 552"> -Total abstinence is easier than perfect moderationy +Total abstinence is easier than perfect moderationy @@ -49,7 +49,7 @@ knowing I can't make my satellite dish PAYMENTS! customerissuerstore1Like starbucks or somethingacquirer2I'm not sure what this isnetworkcustomer bankstore bankinitial transactionpayment processor behind the scenessimplified 1 banana please$10 dollarsthinking: wow, inflationchecks bank accountSavings: $11I can do that, here's my cardRun this cardProcess to card issuerProcess this payment$10 debit$10 creditAn error in judgement is about to occur +customerissuerstore1Like starbucks or somethingacquirer2I'm not sure what this isnetworkcustomer bankstore bankinitial transactionpayment processor behind the scenessimplified 1 banana please$10 dollarsthinking: wow, inflationchecks bank accountSavings: $11I can do that, here's my cardRun this cardProcess to card issuerProcess this payment$10 debit$10 creditAn error in judgement is about to occur @@ -42,7 +42,7 @@ width="1959" height="2297" viewBox="-175 -47 1959 2297">1Like starbucks or something +2I'm not sure what this is x1y2Gee, I feel kind of LIGHT in the head now, +knowing I can't make my satellite dish PAYMENTS!3 + + +1https://d2lang.com +2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! +3https://terrastruct.com + \ No newline at end of file diff --git a/d2renderers/d2svg/appendix/testdata/tooltip_wider_than_diagram/sketch.exp.svg b/d2renderers/d2svg/appendix/testdata/tooltip_wider_than_diagram/sketch.exp.svg index 8c6640ce4..b2b23e46f 100644 --- a/d2renderers/d2svg/appendix/testdata/tooltip_wider_than_diagram/sketch.exp.svg +++ b/d2renderers/d2svg/appendix/testdata/tooltip_wider_than_diagram/sketch.exp.svg @@ -18,12 +18,12 @@ width="564" height="700" viewBox="-100 -100 564 700">x1Total abstinence is easier than perfect moderationy2Gee, I feel kind of LIGHT in the head now, +x1Total abstinence is easier than perfect moderationy2Gee, I feel kind of LIGHT in the head now, knowing I can't make my satellite dish PAYMENTS! 1Total abstinence is easier than perfect moderation -2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! +}]]>1Total abstinence is easier than perfect moderation +2Gee, I feel kind of LIGHT in the head now,knowing I can't make my satellite dish PAYMENTS! x - + - + @@ -45,13 +45,13 @@ width="314" height="552" viewBox="-100 -100 314 552"> Gee, I feel kind of LIGHT in the head now, knowing I can't make my satellite dish PAYMENTS! - + - + diff --git a/e2etests/testdata/stable/links/elk/sketch.exp.svg b/e2etests/testdata/stable/links/elk/sketch.exp.svg index 083055954..e79e1f106 100644 --- a/e2etests/testdata/stable/links/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/links/elk/sketch.exp.svg @@ -19,13 +19,13 @@ width="314" height="552" viewBox="-88 -88 314 552">x - + - + @@ -45,13 +45,13 @@ width="314" height="552" viewBox="-88 -88 314 552"> Gee, I feel kind of LIGHT in the head now, knowing I can't make my satellite dish PAYMENTS! - + - + From d52b3b4db5ac4bd5259f4a65627afde2ce275641 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 28 Dec 2022 16:41:15 -0800 Subject: [PATCH 234/257] add xlink href for older browsers --- d2renderers/d2svg/d2svg.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/d2renderers/d2svg/d2svg.go b/d2renderers/d2svg/d2svg.go index f25d1866e..cc735055a 100644 --- a/d2renderers/d2svg/d2svg.go +++ b/d2renderers/d2svg/d2svg.go @@ -593,7 +593,7 @@ func render3dRect(targetShape d2target.Shape) string { func drawShape(writer io.Writer, targetShape d2target.Shape, sketchRunner *d2sketch.Runner) (labelMask string, err error) { closingTag := "" if targetShape.Link != "" { - fmt.Fprintf(writer, ``, targetShape.Link) + fmt.Fprintf(writer, ``, targetShape.Link) closingTag += "" } fmt.Fprintf(writer, ``, svg.EscapeText(targetShape.ID)) From 51e281d3f657fa3cc4a375ce9988bdbc1044a20e Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 28 Dec 2022 16:42:22 -0800 Subject: [PATCH 235/257] update tests --- d2renderers/d2svg/appendix/testdata/links/sketch.exp.svg | 2 +- e2etests/testdata/stable/links/dagre/sketch.exp.svg | 4 ++-- e2etests/testdata/stable/links/elk/sketch.exp.svg | 4 ++-- main.go | 2 +- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/d2renderers/d2svg/appendix/testdata/links/sketch.exp.svg b/d2renderers/d2svg/appendix/testdata/links/sketch.exp.svg index 4dfb2ef56..e4f4e7c0d 100644 --- a/d2renderers/d2svg/appendix/testdata/links/sketch.exp.svg +++ b/d2renderers/d2svg/appendix/testdata/links/sketch.exp.svg @@ -18,7 +18,7 @@ width="563" height="741" viewBox="-100 -100 563 741">x1y2Gee, I feel kind of LIGHT in the head now, +x1y2Gee, I feel kind of LIGHT in the head now, knowing I can't make my satellite dish PAYMENTS!3 diff --git a/e2etests/testdata/stable/links/dagre/sketch.exp.svg b/e2etests/testdata/stable/links/dagre/sketch.exp.svg index 0be800dac..063f65d26 100644 --- a/e2etests/testdata/stable/links/dagre/sketch.exp.svg +++ b/e2etests/testdata/stable/links/dagre/sketch.exp.svg @@ -18,7 +18,7 @@ width="314" height="552" viewBox="-100 -100 314 552">x +x @@ -30,7 +30,7 @@ width="314" height="552" viewBox="-100 -100 314 552"> -y +y diff --git a/e2etests/testdata/stable/links/elk/sketch.exp.svg b/e2etests/testdata/stable/links/elk/sketch.exp.svg index e79e1f106..3a532dcdc 100644 --- a/e2etests/testdata/stable/links/elk/sketch.exp.svg +++ b/e2etests/testdata/stable/links/elk/sketch.exp.svg @@ -18,7 +18,7 @@ width="314" height="552" viewBox="-88 -88 314 552">x +x @@ -30,7 +30,7 @@ width="314" height="552" viewBox="-88 -88 314 552"> -y +y diff --git a/main.go b/main.go index e87b5149e..0377ac538 100644 --- a/main.go +++ b/main.go @@ -248,7 +248,7 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, sketc out := svg if filepath.Ext(outputPath) == ".png" { - svg := appendix.AppendTooltips(diagram, ruler, svg) + svg := appendix.Append(diagram, ruler, svg) if !bundle { var bundleErr2 error From e24f201c80ab57905e7f01c6c232fc20e078522c Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 28 Dec 2022 20:35:28 -0800 Subject: [PATCH 236/257] add discord --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index ff94c5367..045cc18fa 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,7 @@ let us know and we'll be happy to include it here! - **Vim extension**: [https://github.com/terrastruct/d2-vim](https://github.com/terrastruct/d2-vim) - **Obsidian plugin**: [https://github.com/terrastruct/d2-obsidian](https://github.com/terrastruct/d2-obsidian) - **Slack app**: [https://d2lang.com/tour/slack](https://d2lang.com/tour/slack) +- **Discord plugin**: [https://d2lang.com/tour/discord](https://d2lang.com/tour/discord) ### Community plugins From 17e4ae0e34ad981491614c09234e2e8c4b89f90e Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 21 Dec 2022 21:35:18 -0800 Subject: [PATCH 237/257] add shape_set_width_height test --- e2etests/todo_test.go | 118 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 118 insertions(+) diff --git a/e2etests/todo_test.go b/e2etests/todo_test.go index defa87cd6..925d791c8 100644 --- a/e2etests/todo_test.go +++ b/e2etests/todo_test.go @@ -90,6 +90,124 @@ this is a message group: { } }`, }, + { + // dimensions set on containers are ignored + name: "shape_set_width_height", + script: ` +containers: { + circle container: { + shape: circle + width: 512 + height: 256 + + diamond: { + shape: diamond + width: 128 + height: 64 + } + } + diamond container: { + shape: diamond + width: 512 + height: 256 + + circle: { + shape: circle + width: 128 + height: 64 + } + } + oval container: { + shape: oval + width: 512 + height: 256 + + hexagon: { + shape: hexagon + width: 128 + height: 64 + } + } + hexagon container: { + shape: hexagon + width: 512 + height: 256 + + oval: { + shape: oval + width: 128 + height: 64 + } + } +} + +cloud: { + shape: cloud + width: 512 + height: 256 +} +tall cylinder: { + shape: cylinder + width: 256 + height: 512 +} +cloud -> class -> tall cylinder -> users + +users: { + shape: sql_table + id: int + name: string + email: string + password: string + last_login: datetime + + width: 800 + height: 400 +} + +class: { + shape: class + -num: int + -timeout: int + -pid + + +getStatus(): Enum + +getJobs(): "Job[]" + +setTimeout(seconds int) + + width: 800 + height: 400 +} + +container -> text -> code -> small code + +text: { + label: |md + markdown text expanded to 800x400 +| + height: 800 + width: 400 +} + +code: |go + a := 5 + b := a + 7 + fmt.Printf("%d", b) +| { + width: 400 + height: 300 +} + +small code: |go + a := 5 + b := a + 7 + fmt.Printf("%d", b) +| { + width: 4 + height: 3 +} +`, + }, } runa(t, tcs) From 6cb72cb4175a4b5b46a82b68beafccf4fd2ea43b Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 28 Dec 2022 14:29:13 -0800 Subject: [PATCH 238/257] add unnamed_class_table_code regression test --- e2etests/regression_test.go | 33 ++ .../dagre/board.exp.json | 400 ++++++++++++++++++ .../dagre/sketch.exp.svg | 62 +++ .../elk/board.exp.json | 382 +++++++++++++++++ .../elk/sketch.exp.svg | 62 +++ 5 files changed, 939 insertions(+) create mode 100644 e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/unnamed_class_table_code/elk/board.exp.json create mode 100644 e2etests/testdata/regression/unnamed_class_table_code/elk/sketch.exp.svg diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index d3fe777b6..f823b03c2 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -215,6 +215,39 @@ m6_desc: |md inserted here | m6_desc -> queue.M6 +`, + }, + { + name: "unnamed_class_table_code", + script: ` + +class -> users -> code + +class: "" { + shape: class + -num: int + -timeout: int + -pid + + +getStatus(): Enum + +getJobs(): "Job[]" + +setTimeout(seconds int) +} + +users: "" { + shape: sql_table + id: int + name: string + email: string + password: string + last_login: datetime +} + +code: |go + a := 5 + b := a + 7 + fmt.Printf("%d", b) +| `, }, } diff --git a/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json b/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json new file mode 100644 index 000000000..c01b08b63 --- /dev/null +++ b/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json @@ -0,0 +1,400 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "class", + "type": "class", + "pos": { + "x": 48, + "y": 0 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": [ + { + "name": "num", + "type": "int", + "visibility": "private" + }, + { + "name": "timeout", + "type": "int", + "visibility": "private" + }, + { + "name": "pid", + "type": "", + "visibility": "private" + } + ], + "methods": [ + { + "name": "getStatus()", + "return": "Enum", + "visibility": "public" + }, + { + "name": "getJobs()", + "return": "Job[]", + "visibility": "public" + }, + { + "name": "setTimeout(seconds int)", + "return": "void", + "visibility": "public" + } + ], + "columns": null, + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "users", + "type": "sql_table", + "pos": { + "x": 48, + "y": 200 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": { + "label": "id", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "int", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "name", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "email", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "password", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "last_login", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "datetime", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + } + ], + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "code", + "type": "code", + "pos": { + "x": 0, + "y": 400 + }, + "width": 196, + "height": 70, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a := 5\nb := a + 7\nfmt.Printf(\"%d\", b)", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "golang", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 196, + "labelHeight": 70, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(class -> users)[0]", + "src": "class", + "srcArrow": "none", + "srcLabel": "", + "dst": "users", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 98, + "y": 100 + }, + { + "x": 98, + "y": 140 + }, + { + "x": 98, + "y": 160 + }, + { + "x": 98, + "y": 200 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(users -> code)[0]", + "src": "users", + "srcArrow": "none", + "srcLabel": "", + "dst": "code", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 98, + "y": 300 + }, + { + "x": 98, + "y": 340 + }, + { + "x": 98, + "y": 360 + }, + { + "x": 98, + "y": 400 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg b/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg new file mode 100644 index 000000000..323da486e --- /dev/null +++ b/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg @@ -0,0 +1,62 @@ + +- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidid +int +name +string +email +string +password +string +last_login +datetime +:= 5 +:= a + 7 +fmt.Printf("%d", b) + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/unnamed_class_table_code/elk/board.exp.json b/e2etests/testdata/regression/unnamed_class_table_code/elk/board.exp.json new file mode 100644 index 000000000..f00297fb6 --- /dev/null +++ b/e2etests/testdata/regression/unnamed_class_table_code/elk/board.exp.json @@ -0,0 +1,382 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "class", + "type": "class", + "pos": { + "x": 60, + "y": 12 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": [ + { + "name": "num", + "type": "int", + "visibility": "private" + }, + { + "name": "timeout", + "type": "int", + "visibility": "private" + }, + { + "name": "pid", + "type": "", + "visibility": "private" + } + ], + "methods": [ + { + "name": "getStatus()", + "return": "Enum", + "visibility": "public" + }, + { + "name": "getJobs()", + "return": "Job[]", + "visibility": "public" + }, + { + "name": "setTimeout(seconds int)", + "return": "void", + "visibility": "public" + } + ], + "columns": null, + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "users", + "type": "sql_table", + "pos": { + "x": 60, + "y": 212 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": { + "label": "id", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "int", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "name", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "email", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "password", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "last_login", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "type": { + "label": "datetime", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + } + ], + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "code", + "type": "code", + "pos": { + "x": 12, + "y": 412 + }, + "width": 196, + "height": 70, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a := 5\nb := a + 7\nfmt.Printf(\"%d\", b)", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "golang", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 196, + "labelHeight": 70, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(class -> users)[0]", + "src": "class", + "srcArrow": "none", + "srcLabel": "", + "dst": "users", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 110, + "y": 112 + }, + { + "x": 110, + "y": 212 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(users -> code)[0]", + "src": "users", + "srcArrow": "none", + "srcLabel": "", + "dst": "code", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 110, + "y": 312 + }, + { + "x": 110, + "y": 412 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/regression/unnamed_class_table_code/elk/sketch.exp.svg b/e2etests/testdata/regression/unnamed_class_table_code/elk/sketch.exp.svg new file mode 100644 index 000000000..944f77f35 --- /dev/null +++ b/e2etests/testdata/regression/unnamed_class_table_code/elk/sketch.exp.svg @@ -0,0 +1,62 @@ + +- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidid +int +name +string +email +string +password +string +last_login +datetime +:= 5 +:= a + 7 +fmt.Printf("%d", b) + + + \ No newline at end of file From 5d4059e470692cfd6a4b46d508639f3f68fbab1b Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 21 Dec 2022 21:36:08 -0800 Subject: [PATCH 239/257] support setting width/height on non-image shapes --- d2compiler/compile.go | 7 - d2compiler/compile_test.go | 3 - d2graph/d2graph.go | 101 +- .../dagre/board.exp.json | 98 +- .../dagre/sketch.exp.svg | 52 +- .../elk/board.exp.json | 82 +- .../elk/sketch.exp.svg | 52 +- .../dagre/board.exp.json | 1175 +++++++++++++++++ .../dagre/sketch.exp.svg | 71 + .../shape_set_width_height/elk/board.exp.json | 1097 +++++++++++++++ .../shape_set_width_height/elk/sketch.exp.svg | 71 + .../dimensions_on_nonimage.exp.json | 214 ++- 12 files changed, 2837 insertions(+), 186 deletions(-) create mode 100644 e2etests/testdata/todo/shape_set_width_height/dagre/board.exp.json create mode 100644 e2etests/testdata/todo/shape_set_width_height/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/todo/shape_set_width_height/elk/board.exp.json create mode 100644 e2etests/testdata/todo/shape_set_width_height/elk/sketch.exp.svg diff --git a/d2compiler/compile.go b/d2compiler/compile.go index 86e6e63d3..5429bdea4 100644 --- a/d2compiler/compile.go +++ b/d2compiler/compile.go @@ -801,13 +801,6 @@ func (c *compiler) validateKey(obj *d2graph.Object, m *d2ast.Map, mk *d2ast.Key) c.errorf(mk.Range.Start, mk.Range.End, "image shapes cannot have children.") } - if reserved == "width" && obj.Attributes.Shape.Value != d2target.ShapeImage { - c.errorf(mk.Range.Start, mk.Range.End, "width is only applicable to image shapes.") - } - if reserved == "height" && obj.Attributes.Shape.Value != d2target.ShapeImage { - c.errorf(mk.Range.Start, mk.Range.End, "height is only applicable to image shapes.") - } - in := d2target.IsShape(obj.Attributes.Shape.Value) _, arrowheadIn := d2target.Arrowheads[obj.Attributes.Shape.Value] if !in && arrowheadIn { diff --git a/d2compiler/compile_test.go b/d2compiler/compile_test.go index cf7283649..207211e1d 100644 --- a/d2compiler/compile_test.go +++ b/d2compiler/compile_test.go @@ -94,9 +94,6 @@ x: { width: 200 height: 230 } -`, - expErr: `d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2:3:2: width is only applicable to image shapes. -d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2:4:2: height is only applicable to image shapes. `, }, { diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 6ab44e7f1..53f682942 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -898,17 +898,36 @@ func appendTextDedup(texts []*d2target.MText, t *d2target.MText) []*d2target.MTe func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler, fontFamily *d2fonts.FontFamily) error { for _, obj := range g.Objects { obj.Box = &geo.Box{} - // TODO fix edge cases for unnamed class etc - // Image shapes can set their own widths/heights - if obj.Attributes.Label.Value == "" && obj.Attributes.Shape.Value != d2target.ShapeImage { - obj.Width = 100 - obj.Height = 100 - continue + + var setWidth int + var setHeight int + if obj.Attributes.Width != nil { + setWidth, _ = strconv.Atoi(obj.Attributes.Width.Value) + } + if obj.Attributes.Height != nil { + setHeight, _ = strconv.Atoi(obj.Attributes.Height.Value) + } + shapeType := strings.ToLower(obj.Attributes.Shape.Value) + + switch shapeType { + case d2target.ShapeClass, + d2target.ShapeSQLTable, + d2target.ShapeCode, + d2target.ShapeImage, + d2target.ShapeText: + // edge cases for unnamed class, etc + default: + if obj.Attributes.Label.Value == "" && setWidth == 0 && setHeight == 0 { + obj.Width = 100 + obj.Height = 100 + continue + } } var dims *d2target.TextDimensions var innerLabelPadding = INNER_LABEL_PADDING - if obj.Attributes.Shape.Value == d2target.ShapeText { + switch shapeType { + case d2target.ShapeText: if obj.Attributes.Language == "latex" { width, height, err := d2latex.Measure(obj.Text().Text) if err != nil { @@ -925,20 +944,30 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler dims = GetTextDimensions(mtexts, ruler, obj.Text(), fontFamily) } innerLabelPadding = 0 - } else if obj.Attributes.Shape.Value == d2target.ShapeClass { + + case d2target.ShapeClass: dims = GetTextDimensions(mtexts, ruler, obj.Text(), go2.Pointer(d2fonts.SourceCodePro)) - } else { + + default: dims = GetTextDimensions(mtexts, ruler, obj.Text(), fontFamily) } + + if shapeType == d2target.ShapeSQLTable && obj.Attributes.Label.Value == "" { + // measure with placeholder text to determine height + placeholder := *obj.Text() + placeholder.Text = "Table" + dims = GetTextDimensions(mtexts, ruler, &placeholder, fontFamily) + } + if dims == nil { - if obj.Attributes.Shape.Value == d2target.ShapeImage { + if shapeType == d2target.ShapeImage { dims = d2target.NewTextDimensions(0, 0) } else { return fmt.Errorf("dimensions for object label %#v not found", obj.Text()) } } - switch obj.Attributes.Shape.Value { + switch shapeType { case d2target.ShapeText, d2target.ShapeClass, d2target.ShapeSQLTable, d2target.ShapeCode: // no labels default: @@ -954,29 +983,39 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler obj.Width = float64(dims.Width) obj.Height = float64(dims.Height) - switch strings.ToLower(obj.Attributes.Shape.Value) { + // the set dimensions must be at least as large as the text + if float64(setWidth) > obj.Width { + obj.Width = float64(setWidth) + } + if float64(setHeight) > obj.Height { + obj.Height = float64(setHeight) + } + + switch shapeType { default: - obj.Width += 100 - obj.Height += 100 + if setWidth == 0 { + obj.Width += 100 + } + if setHeight == 0 { + obj.Height += 100 + } case d2target.ShapeImage: - if obj.Attributes.Width != nil { - w, _ := strconv.Atoi(obj.Attributes.Width.Value) - obj.Width = float64(w) - } else { + if setWidth == 0 { obj.Width = 128 } - if obj.Attributes.Height != nil { - h, _ := strconv.Atoi(obj.Attributes.Height.Value) - obj.Height = float64(h) - } else { + if setHeight == 0 { obj.Height = 128 } case d2target.ShapeSquare, d2target.ShapeCircle: sideLength := go2.Max(obj.Width, obj.Height) - obj.Width = sideLength + 100 - obj.Height = sideLength + 100 + padding := 0. + if setWidth == 0 && setHeight == 0 { + padding = 100. + } + obj.Width = sideLength + padding + obj.Height = sideLength + padding case d2target.ShapeClass: maxWidth := dims.Width @@ -1059,6 +1098,20 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler case d2target.ShapeText, d2target.ShapeCode: } + + switch shapeType { + case d2target.ShapeClass, + d2target.ShapeSQLTable, + d2target.ShapeCode, + d2target.ShapeText: + if float64(setWidth) > obj.Width { + obj.Width = float64(setWidth) + } + if float64(setHeight) > obj.Height { + obj.Height = float64(setHeight) + } + } + } for _, edge := range g.Edges { endpointLabels := []string{} diff --git a/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json b/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json index c01b08b63..f96e89a36 100644 --- a/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json +++ b/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json @@ -6,11 +6,11 @@ "id": "class", "type": "class", "pos": { - "x": 48, + "x": 0, "y": 0 }, - "width": 100, - "height": 100, + "width": 422, + "height": 368, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -68,8 +68,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0, + "labelWidth": 5, + "labelHeight": 5, "zIndex": 0, "level": 1, "primaryAccentColor": "#0D32B2", @@ -80,11 +80,11 @@ "id": "users", "type": "sql_table", "pos": { - "x": 48, - "y": 200 + "x": 107, + "y": 468 }, - "width": 100, - "height": 100, + "width": 208, + "height": 216, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -112,8 +112,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 15, + "labelHeight": 26 }, "type": { "label": "int", @@ -124,8 +124,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 23, + "labelHeight": 26 }, "constraint": "", "reference": "" @@ -140,8 +140,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 47, + "labelHeight": 26 }, "type": { "label": "string", @@ -152,8 +152,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 48, + "labelHeight": 26 }, "constraint": "", "reference": "" @@ -168,8 +168,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 47, + "labelHeight": 26 }, "type": { "label": "string", @@ -180,8 +180,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 48, + "labelHeight": 26 }, "constraint": "", "reference": "" @@ -196,8 +196,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 80, + "labelHeight": 26 }, "type": { "label": "string", @@ -208,8 +208,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 48, + "labelHeight": 26 }, "constraint": "", "reference": "" @@ -224,8 +224,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 81, + "labelHeight": 26 }, "type": { "label": "datetime", @@ -236,8 +236,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 0, - "labelHeight": 0 + "labelWidth": 77, + "labelHeight": 26 }, "constraint": "", "reference": "" @@ -251,8 +251,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 0, - "labelHeight": 0, + "labelWidth": 64, + "labelHeight": 36, "zIndex": 0, "level": 1, "primaryAccentColor": "#0D32B2", @@ -263,8 +263,8 @@ "id": "code", "type": "code", "pos": { - "x": 0, - "y": 400 + "x": 113, + "y": 784 }, "width": 196, "height": 70, @@ -326,20 +326,20 @@ "labelPercentage": 0, "route": [ { - "x": 98, - "y": 100 + "x": 211, + "y": 368 }, { - "x": 98, - "y": 140 + "x": 211, + "y": 408 }, { - "x": 98, - "y": 160 + "x": 211, + "y": 428 }, { - "x": 98, - "y": 200 + "x": 211, + "y": 468 } ], "isCurve": true, @@ -374,20 +374,20 @@ "labelPercentage": 0, "route": [ { - "x": 98, - "y": 300 + "x": 211, + "y": 684 }, { - "x": 98, - "y": 340 + "x": 211, + "y": 724 }, { - "x": 98, - "y": 360 + "x": 211, + "y": 744 }, { - "x": 98, - "y": 400 + "x": 211, + "y": 784 } ], "isCurve": true, diff --git a/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg b/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg index 323da486e..15c3051ff 100644 --- a/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ - +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidid +int +name +string +email +string +password +string +last_login +datetime +:= 5 := a + 7 -fmt.Printf("%d", b) - +fmt.Printf("%d", b) + - -num -int- -timeout -int- -pid -+ -getStatus() -Enum+ -getJobs() -Job[]+ -setTimeout(seconds int) -voidid -int -name -string -email -string -password -string -last_login -datetime -:= 5 +- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidid +int +name +string +email +string +password +string +last_login +datetime +:= 5 := a + 7 -fmt.Printf("%d", b) - +fmt.Printf("%d", b) + containerscloudtall cylinderusersid +int +name +string +email +string +password +string +last_login +datetime +class- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidmarkdown text expanded to 800x400:= 5 +:= a + 7 +fmt.Printf("%d", b):= 5 +:= a + 7 +fmt.Printf("%d", b)containercircle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval + + + \ No newline at end of file diff --git a/e2etests/testdata/todo/shape_set_width_height/elk/board.exp.json b/e2etests/testdata/todo/shape_set_width_height/elk/board.exp.json new file mode 100644 index 000000000..61577b1dd --- /dev/null +++ b/e2etests/testdata/todo/shape_set_width_height/elk/board.exp.json @@ -0,0 +1,1097 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "containers", + "type": "", + "pos": { + "x": 12, + "y": 12 + }, + "width": 1322, + "height": 428, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#E3E9FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "containers", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 128, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "containers.circle container", + "type": "oval", + "pos": { + "x": 87, + "y": 119 + }, + "width": 278, + "height": 214, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "circle container", + "fontSize": 24, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 161, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "containers.circle container.diamond", + "type": "diamond", + "pos": { + "x": 162, + "y": 194 + }, + "width": 128, + "height": 64, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#CFD2DD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "diamond", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 68, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "containers.diamond container", + "type": "diamond", + "pos": { + "x": 385, + "y": 87 + }, + "width": 278, + "height": 278, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#CFD2DD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "diamond container", + "fontSize": 24, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 197, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "containers.diamond container.circle", + "type": "oval", + "pos": { + "x": 460, + "y": 162 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "circle", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 44, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "containers.oval container", + "type": "oval", + "pos": { + "x": 683, + "y": 119 + }, + "width": 278, + "height": 214, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "oval container", + "fontSize": 24, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 149, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "containers.oval container.hexagon", + "type": "hexagon", + "pos": { + "x": 758, + "y": 194 + }, + "width": 128, + "height": 64, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "hexagon", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 65, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "containers.hexagon container", + "type": "hexagon", + "pos": { + "x": 981, + "y": 119 + }, + "width": 278, + "height": 214, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#DEE1EB", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "hexagon container", + "fontSize": 24, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 193, + "labelHeight": 36, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "containers.hexagon container.oval", + "type": "oval", + "pos": { + "x": 1056, + "y": 194 + }, + "width": 128, + "height": 64, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "oval", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 36, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 3 + }, + { + "id": "cloud", + "type": "cloud", + "pos": { + "x": 1354, + "y": 184 + }, + "width": 512, + "height": 256, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "cloud", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 45, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "tall cylinder", + "type": "cylinder", + "pos": { + "x": 1482, + "y": 1440 + }, + "width": 256, + "height": 512, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "tall cylinder", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 91, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "users", + "type": "sql_table", + "pos": { + "x": 1210, + "y": 2052 + }, + "width": 800, + "height": 400, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": { + "label": "id", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 15, + "labelHeight": 26 + }, + "type": { + "label": "int", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 23, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "name", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "email", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "password", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 80, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "last_login", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 81, + "labelHeight": 26 + }, + "type": { + "label": "datetime", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 77, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + } + ], + "label": "users", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 61, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "class", + "type": "class", + "pos": { + "x": 1210, + "y": 740 + }, + "width": 800, + "height": 400, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": [ + { + "name": "num", + "type": "int", + "visibility": "private" + }, + { + "name": "timeout", + "type": "int", + "visibility": "private" + }, + { + "name": "pid", + "type": "", + "visibility": "private" + } + ], + "methods": [ + { + "name": "getStatus()", + "return": "Enum", + "visibility": "public" + }, + { + "name": "getJobs()", + "return": "Job[]", + "visibility": "public" + }, + { + "name": "setTimeout(seconds int)", + "return": "void", + "visibility": "public" + } + ], + "columns": null, + "label": "class", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 75, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "text", + "type": "", + "pos": { + "x": 2030, + "y": 540 + }, + "width": 400, + "height": 800, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "markdown text expanded to 800x400", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 266, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "code", + "type": "code", + "pos": { + "x": 2030, + "y": 1546 + }, + "width": 400, + "height": 300, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a := 5\nb := a + 7\nfmt.Printf(\"%d\", b)", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "golang", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 196, + "labelHeight": 70, + "zIndex": 0, + "level": 1 + }, + { + "id": "small code", + "type": "code", + "pos": { + "x": 2132, + "y": 2052 + }, + "width": 196, + "height": 70, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a := 5\nb := a + 7\nfmt.Printf(\"%d\", b)", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "golang", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 196, + "labelHeight": 70, + "zIndex": 0, + "level": 1 + }, + { + "id": "container", + "type": "", + "pos": { + "x": 2143, + "y": 314 + }, + "width": 174, + "height": 126, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "container", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 74, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(cloud -> class)[0]", + "src": "cloud", + "srcArrow": "none", + "srcLabel": "", + "dst": "class", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 1610, + "y": 440 + }, + { + "x": 1610, + "y": 740 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(class -> tall cylinder)[0]", + "src": "class", + "srcArrow": "none", + "srcLabel": "", + "dst": "tall cylinder", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 1610, + "y": 1140 + }, + { + "x": 1610, + "y": 1440 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(tall cylinder -> users)[0]", + "src": "tall cylinder", + "srcArrow": "none", + "srcLabel": "", + "dst": "users", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 1610, + "y": 1952 + }, + { + "x": 1610, + "y": 2052 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(container -> text)[0]", + "src": "container", + "srcArrow": "none", + "srcLabel": "", + "dst": "text", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 2230, + "y": 440 + }, + { + "x": 2230, + "y": 540 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(text -> code)[0]", + "src": "text", + "srcArrow": "none", + "srcLabel": "", + "dst": "code", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 2230, + "y": 1340 + }, + { + "x": 2230, + "y": 1546 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(code -> small code)[0]", + "src": "code", + "srcArrow": "none", + "srcLabel": "", + "dst": "small code", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 2230, + "y": 1846 + }, + { + "x": 2230, + "y": 2052 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/todo/shape_set_width_height/elk/sketch.exp.svg b/e2etests/testdata/todo/shape_set_width_height/elk/sketch.exp.svg new file mode 100644 index 000000000..509a9bf1e --- /dev/null +++ b/e2etests/testdata/todo/shape_set_width_height/elk/sketch.exp.svg @@ -0,0 +1,71 @@ + +containerscloudtall cylinderusersid +int +name +string +email +string +password +string +last_login +datetime +class- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidmarkdown text expanded to 800x400:= 5 +:= a + 7 +fmt.Printf("%d", b):= 5 +:= a + 7 +fmt.Printf("%d", b)containercircle containerdiamond containeroval containerhexagon containerdiamondcirclehexagonoval + + + \ No newline at end of file diff --git a/testdata/d2compiler/TestCompile/dimensions_on_nonimage.exp.json b/testdata/d2compiler/TestCompile/dimensions_on_nonimage.exp.json index 405923ccf..d094c9039 100644 --- a/testdata/d2compiler/TestCompile/dimensions_on_nonimage.exp.json +++ b/testdata/d2compiler/TestCompile/dimensions_on_nonimage.exp.json @@ -1,16 +1,210 @@ { - "graph": null, - "err": { - "ioerr": null, - "errs": [ - { - "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,2:1:28-2:11:38", - "errmsg": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2:3:2: width is only applicable to image shapes." + "graph": { + "ast": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,0:0:0-5:0:54", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,0:0:0-4:1:53", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,0:0:0-0:3:3", + "value": [ + { + "string": "hey", + "raw_string": "hey" + } + ] + } + } + ] + }, + "primary": { + "double_quoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,0:5:5-0:7:7", + "value": null + } + }, + "value": { + "map": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,0:8:8-4:0:52", + "nodes": [ + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,1:2:12-1:16:26", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,1:2:12-1:7:17", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,1:2:12-1:7:17", + "value": [ + { + "string": "shape", + "raw_string": "shape" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,1:9:19-1:16:26", + "value": [ + { + "string": "hexagon", + "raw_string": "hexagon" + } + ] + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,2:1:28-2:11:38", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,2:1:28-2:6:33", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,2:1:28-2:6:33", + "value": [ + { + "string": "width", + "raw_string": "width" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,2:8:35-2:11:38", + "raw": "200", + "value": "200" + } + } + } + }, + { + "map_key": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,3:1:40-3:12:51", + "key": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,3:1:40-3:7:46", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,3:1:40-3:7:46", + "value": [ + { + "string": "height", + "raw_string": "height" + } + ] + } + } + ] + }, + "primary": {}, + "value": { + "number": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,3:9:48-3:12:51", + "raw": "230", + "value": "230" + } + } + } + } + ] + } + } + } + } + ] + }, + "root": { + "id": "", + "id_val": "", + "label_dimensions": { + "width": 0, + "height": 0 }, + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "near_key": null, + "shape": { + "value": "" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 + }, + "edges": null, + "objects": [ { - "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,3:1:40-3:12:51", - "errmsg": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2:4:2: height is only applicable to image shapes." + "id": "hey", + "id_val": "hey", + "label_dimensions": { + "width": 0, + "height": 0 + }, + "references": [ + { + "key": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,0:0:0-0:3:3", + "path": [ + { + "unquoted_string": { + "range": "d2/testdata/d2compiler/TestCompile/dimensions_on_nonimage.d2,0:0:0-0:3:3", + "value": [ + { + "string": "hey", + "raw_string": "hey" + } + ] + } + } + ] + }, + "key_path_index": 0, + "map_key_edge_index": 0 + } + ], + "attributes": { + "label": { + "value": "" + }, + "style": {}, + "width": { + "value": "200" + }, + "height": { + "value": "230" + }, + "near_key": null, + "shape": { + "value": "hexagon" + }, + "direction": { + "value": "" + } + }, + "zIndex": 0 } ] - } + }, + "err": null } From e45f78b50cb4dcb349bb610b37272adeccb2c601 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 21 Dec 2022 21:36:32 -0800 Subject: [PATCH 240/257] changelog --- ci/release/changelogs/next.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 1078069ca..54e278b56 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -5,6 +5,9 @@ #### Improvements 🧹 +- Now the `width` and `height` attributes are no longer restricted to images and can be applied to non-container shapes. [#498](https://github.com/terrastruct/d2/pull/498) + #### Bugfixes ⛑️ - Restricts where `near` key constant values can be used, with good error messages, instead of erroring (e.g. setting `near: top-center` on a container would cause bad layouts or error). [#538](https://github.com/terrastruct/d2/pull/538) +- Fixed rendering classes and tables with empty headers. [#498](https://github.com/terrastruct/d2/pull/498) From 73d1a666e18c347e2cc931871c1b0717dc245ed7 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 28 Dec 2022 15:58:00 -0800 Subject: [PATCH 241/257] cleanup --- ci/release/changelogs/next.md | 5 ++--- d2graph/d2graph.go | 41 +++++++++++++++-------------------- 2 files changed, 19 insertions(+), 27 deletions(-) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 54e278b56..4457be55c 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -2,12 +2,11 @@ - Tooltips can be set on shapes. See [https://d2lang.com/tour/tooltips](https://d2lang.com/tour/interactive). [#548](https://github.com/terrastruct/d2/pull/548) - Links can be set on shapes. See [https://d2lang.com/tour/tooltips](https://d2lang.com/tour/interactive). [#548](https://github.com/terrastruct/d2/pull/548) +- The `width` and `height` attributes are no longer restricted to images and can be applied to non-container shapes. [#498](https://github.com/terrastruct/d2/pull/498) #### Improvements 🧹 -- Now the `width` and `height` attributes are no longer restricted to images and can be applied to non-container shapes. [#498](https://github.com/terrastruct/d2/pull/498) - #### Bugfixes ⛑️ - Restricts where `near` key constant values can be used, with good error messages, instead of erroring (e.g. setting `near: top-center` on a container would cause bad layouts or error). [#538](https://github.com/terrastruct/d2/pull/538) -- Fixed rendering classes and tables with empty headers. [#498](https://github.com/terrastruct/d2/pull/498) +- Fixes rendering classes and tables with empty headers. [#498](https://github.com/terrastruct/d2/pull/498) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 53f682942..1b667c665 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -899,13 +899,13 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler for _, obj := range g.Objects { obj.Box = &geo.Box{} - var setWidth int - var setHeight int + var desiredWidth int + var desiredHeight int if obj.Attributes.Width != nil { - setWidth, _ = strconv.Atoi(obj.Attributes.Width.Value) + desiredWidth, _ = strconv.Atoi(obj.Attributes.Width.Value) } if obj.Attributes.Height != nil { - setHeight, _ = strconv.Atoi(obj.Attributes.Height.Value) + desiredHeight, _ = strconv.Atoi(obj.Attributes.Height.Value) } shapeType := strings.ToLower(obj.Attributes.Shape.Value) @@ -917,7 +917,7 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler d2target.ShapeText: // edge cases for unnamed class, etc default: - if obj.Attributes.Label.Value == "" && setWidth == 0 && setHeight == 0 { + if obj.Attributes.Label.Value == "" && desiredWidth == 0 && desiredHeight == 0 { obj.Width = 100 obj.Height = 100 continue @@ -980,38 +980,31 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler dims.Width += innerLabelPadding dims.Height += innerLabelPadding obj.LabelDimensions = *dims - obj.Width = float64(dims.Width) - obj.Height = float64(dims.Height) - - // the set dimensions must be at least as large as the text - if float64(setWidth) > obj.Width { - obj.Width = float64(setWidth) - } - if float64(setHeight) > obj.Height { - obj.Height = float64(setHeight) - } + // the desired dimensions must be at least as large as the text + obj.Width = float64(go2.Max(dims.Width, desiredWidth)) + obj.Height = float64(go2.Max(dims.Height, desiredHeight)) switch shapeType { default: - if setWidth == 0 { + if desiredWidth == 0 { obj.Width += 100 } - if setHeight == 0 { + if desiredHeight == 0 { obj.Height += 100 } case d2target.ShapeImage: - if setWidth == 0 { + if desiredWidth == 0 { obj.Width = 128 } - if setHeight == 0 { + if desiredHeight == 0 { obj.Height = 128 } case d2target.ShapeSquare, d2target.ShapeCircle: sideLength := go2.Max(obj.Width, obj.Height) padding := 0. - if setWidth == 0 && setHeight == 0 { + if desiredWidth == 0 && desiredHeight == 0 { padding = 100. } obj.Width = sideLength + padding @@ -1104,11 +1097,11 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler d2target.ShapeSQLTable, d2target.ShapeCode, d2target.ShapeText: - if float64(setWidth) > obj.Width { - obj.Width = float64(setWidth) + if float64(desiredWidth) > obj.Width { + obj.Width = float64(desiredWidth) } - if float64(setHeight) > obj.Height { - obj.Height = float64(setHeight) + if float64(desiredHeight) > obj.Height { + obj.Height = float64(desiredHeight) } } From 2f4446ee1895b3f7a8a8ed4b7a6f41d28c5b34fb Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 28 Dec 2022 16:05:56 -0800 Subject: [PATCH 242/257] add tests with only width or height set --- e2etests/stable_test.go | 84 +++ .../unnamed_only_height/dagre/board.exp.json | 574 ++++++++++++++++++ .../unnamed_only_height/dagre/sketch.exp.svg | 62 ++ .../unnamed_only_height/elk/board.exp.json | 538 ++++++++++++++++ .../unnamed_only_height/elk/sketch.exp.svg | 62 ++ .../unnamed_only_width/dagre/board.exp.json | 574 ++++++++++++++++++ .../unnamed_only_width/dagre/sketch.exp.svg | 62 ++ .../unnamed_only_width/elk/board.exp.json | 538 ++++++++++++++++ .../unnamed_only_width/elk/sketch.exp.svg | 62 ++ 9 files changed, 2556 insertions(+) create mode 100644 e2etests/testdata/stable/unnamed_only_height/dagre/board.exp.json create mode 100644 e2etests/testdata/stable/unnamed_only_height/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/stable/unnamed_only_height/elk/board.exp.json create mode 100644 e2etests/testdata/stable/unnamed_only_height/elk/sketch.exp.svg create mode 100644 e2etests/testdata/stable/unnamed_only_width/dagre/board.exp.json create mode 100644 e2etests/testdata/stable/unnamed_only_width/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/stable/unnamed_only_width/elk/board.exp.json create mode 100644 e2etests/testdata/stable/unnamed_only_width/elk/sketch.exp.svg diff --git a/e2etests/stable_test.go b/e2etests/stable_test.go index e43d84921..6590d295e 100644 --- a/e2etests/stable_test.go +++ b/e2etests/stable_test.go @@ -1638,6 +1638,90 @@ x -> y script: `x: { link: https://d2lang.com } y: { link: https://terrastruct.com; tooltip: Gee, I feel kind of LIGHT in the head now,\nknowing I can't make my satellite dish PAYMENTS! } x -> y +`, + }, + { + name: "unnamed_only_width", + script: ` + +class -> users -> code -> package -> no width + +class: "" { + shape: class + -num: int + -timeout: int + -pid + + +getStatus(): Enum + +getJobs(): "Job[]" + +setTimeout(seconds int) +} + +users: "" { + shape: sql_table + id: int + name: string + email: string + password: string + last_login: datetime +} + +code: |go + a := 5 + b := a + 7 + fmt.Printf("%d", b) +| + +package: "" { shape: package } +no width: "" + + +class.width: 512 +users.width: 512 +code.width: 512 +package.width: 512 +`, + }, + { + name: "unnamed_only_height", + script: ` + +class -> users -> code -> package -> no height + +class: "" { + shape: class + -num: int + -timeout: int + -pid + + +getStatus(): Enum + +getJobs(): "Job[]" + +setTimeout(seconds int) +} + +users: "" { + shape: sql_table + id: int + name: string + email: string + password: string + last_login: datetime +} + +code: |go + a := 5 + b := a + 7 + fmt.Printf("%d", b) +| + +package: "" { shape: package } +no height: "" + + +class.height: 512 +users.height: 512 +code.height: 512 +package.height: 512 `, }, } diff --git a/e2etests/testdata/stable/unnamed_only_height/dagre/board.exp.json b/e2etests/testdata/stable/unnamed_only_height/dagre/board.exp.json new file mode 100644 index 000000000..e54467ba5 --- /dev/null +++ b/e2etests/testdata/stable/unnamed_only_height/dagre/board.exp.json @@ -0,0 +1,574 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "class", + "type": "class", + "pos": { + "x": 0, + "y": 0 + }, + "width": 422, + "height": 512, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": [ + { + "name": "num", + "type": "int", + "visibility": "private" + }, + { + "name": "timeout", + "type": "int", + "visibility": "private" + }, + { + "name": "pid", + "type": "", + "visibility": "private" + } + ], + "methods": [ + { + "name": "getStatus()", + "return": "Enum", + "visibility": "public" + }, + { + "name": "getJobs()", + "return": "Job[]", + "visibility": "public" + }, + { + "name": "setTimeout(seconds int)", + "return": "void", + "visibility": "public" + } + ], + "columns": null, + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 5, + "labelHeight": 5, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "users", + "type": "sql_table", + "pos": { + "x": 107, + "y": 612 + }, + "width": 208, + "height": 512, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": { + "label": "id", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 15, + "labelHeight": 26 + }, + "type": { + "label": "int", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 23, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "name", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "email", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "password", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 80, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "last_login", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 81, + "labelHeight": 26 + }, + "type": { + "label": "datetime", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 77, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + } + ], + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 64, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "code", + "type": "code", + "pos": { + "x": 113, + "y": 1224 + }, + "width": 196, + "height": 512, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a := 5\nb := a + 7\nfmt.Printf(\"%d\", b)", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "golang", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 196, + "labelHeight": 70, + "zIndex": 0, + "level": 1 + }, + { + "id": "package", + "type": "package", + "pos": { + "x": 159, + "y": 1836 + }, + "width": 105, + "height": 512, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 5, + "labelHeight": 5, + "zIndex": 0, + "level": 1 + }, + { + "id": "no height", + "type": "", + "pos": { + "x": 161, + "y": 2448 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(class -> users)[0]", + "src": "class", + "srcArrow": "none", + "srcLabel": "", + "dst": "users", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 211, + "y": 512 + }, + { + "x": 211, + "y": 552 + }, + { + "x": 211, + "y": 572 + }, + { + "x": 211, + "y": 612 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(users -> code)[0]", + "src": "users", + "srcArrow": "none", + "srcLabel": "", + "dst": "code", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 211, + "y": 1124 + }, + { + "x": 211, + "y": 1164 + }, + { + "x": 211, + "y": 1184 + }, + { + "x": 211, + "y": 1224 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(code -> package)[0]", + "src": "code", + "srcArrow": "none", + "srcLabel": "", + "dst": "package", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 211, + "y": 1736 + }, + { + "x": 211, + "y": 1776 + }, + { + "x": 211, + "y": 1796 + }, + { + "x": 211, + "y": 1836 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(package -> no height)[0]", + "src": "package", + "srcArrow": "none", + "srcLabel": "", + "dst": "no height", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 211, + "y": 2348 + }, + { + "x": 211, + "y": 2388 + }, + { + "x": 211, + "y": 2408 + }, + { + "x": 211, + "y": 2448 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/unnamed_only_height/dagre/sketch.exp.svg b/e2etests/testdata/stable/unnamed_only_height/dagre/sketch.exp.svg new file mode 100644 index 000000000..0c882d8ca --- /dev/null +++ b/e2etests/testdata/stable/unnamed_only_height/dagre/sketch.exp.svg @@ -0,0 +1,62 @@ + +- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidid +int +name +string +email +string +password +string +last_login +datetime +:= 5 +:= a + 7 +fmt.Printf("%d", b) + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/unnamed_only_height/elk/board.exp.json b/e2etests/testdata/stable/unnamed_only_height/elk/board.exp.json new file mode 100644 index 000000000..86a3b84d8 --- /dev/null +++ b/e2etests/testdata/stable/unnamed_only_height/elk/board.exp.json @@ -0,0 +1,538 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "class", + "type": "class", + "pos": { + "x": 12, + "y": 12 + }, + "width": 422, + "height": 512, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": [ + { + "name": "num", + "type": "int", + "visibility": "private" + }, + { + "name": "timeout", + "type": "int", + "visibility": "private" + }, + { + "name": "pid", + "type": "", + "visibility": "private" + } + ], + "methods": [ + { + "name": "getStatus()", + "return": "Enum", + "visibility": "public" + }, + { + "name": "getJobs()", + "return": "Job[]", + "visibility": "public" + }, + { + "name": "setTimeout(seconds int)", + "return": "void", + "visibility": "public" + } + ], + "columns": null, + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 5, + "labelHeight": 5, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "users", + "type": "sql_table", + "pos": { + "x": 119, + "y": 624 + }, + "width": 208, + "height": 512, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": { + "label": "id", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 15, + "labelHeight": 26 + }, + "type": { + "label": "int", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 23, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "name", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "email", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "password", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 80, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "last_login", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 81, + "labelHeight": 26 + }, + "type": { + "label": "datetime", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 77, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + } + ], + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 64, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "code", + "type": "code", + "pos": { + "x": 125, + "y": 1236 + }, + "width": 196, + "height": 512, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a := 5\nb := a + 7\nfmt.Printf(\"%d\", b)", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "golang", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 196, + "labelHeight": 70, + "zIndex": 0, + "level": 1 + }, + { + "id": "package", + "type": "package", + "pos": { + "x": 170, + "y": 1848 + }, + "width": 105, + "height": 512, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 5, + "labelHeight": 5, + "zIndex": 0, + "level": 1 + }, + { + "id": "no height", + "type": "", + "pos": { + "x": 173, + "y": 2460 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(class -> users)[0]", + "src": "class", + "srcArrow": "none", + "srcLabel": "", + "dst": "users", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 223, + "y": 524 + }, + { + "x": 223, + "y": 624 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(users -> code)[0]", + "src": "users", + "srcArrow": "none", + "srcLabel": "", + "dst": "code", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 223, + "y": 1136 + }, + { + "x": 223, + "y": 1236 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(code -> package)[0]", + "src": "code", + "srcArrow": "none", + "srcLabel": "", + "dst": "package", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 223, + "y": 1748 + }, + { + "x": 224, + "y": 1848 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(package -> no height)[0]", + "src": "package", + "srcArrow": "none", + "srcLabel": "", + "dst": "no height", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 223, + "y": 2360 + }, + { + "x": 223, + "y": 2460 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/unnamed_only_height/elk/sketch.exp.svg b/e2etests/testdata/stable/unnamed_only_height/elk/sketch.exp.svg new file mode 100644 index 000000000..490221200 --- /dev/null +++ b/e2etests/testdata/stable/unnamed_only_height/elk/sketch.exp.svg @@ -0,0 +1,62 @@ + +- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidid +int +name +string +email +string +password +string +last_login +datetime +:= 5 +:= a + 7 +fmt.Printf("%d", b) + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/unnamed_only_width/dagre/board.exp.json b/e2etests/testdata/stable/unnamed_only_width/dagre/board.exp.json new file mode 100644 index 000000000..15add77d7 --- /dev/null +++ b/e2etests/testdata/stable/unnamed_only_width/dagre/board.exp.json @@ -0,0 +1,574 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "class", + "type": "class", + "pos": { + "x": 0, + "y": 0 + }, + "width": 512, + "height": 368, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": [ + { + "name": "num", + "type": "int", + "visibility": "private" + }, + { + "name": "timeout", + "type": "int", + "visibility": "private" + }, + { + "name": "pid", + "type": "", + "visibility": "private" + } + ], + "methods": [ + { + "name": "getStatus()", + "return": "Enum", + "visibility": "public" + }, + { + "name": "getJobs()", + "return": "Job[]", + "visibility": "public" + }, + { + "name": "setTimeout(seconds int)", + "return": "void", + "visibility": "public" + } + ], + "columns": null, + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 5, + "labelHeight": 5, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "users", + "type": "sql_table", + "pos": { + "x": 0, + "y": 468 + }, + "width": 512, + "height": 216, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": { + "label": "id", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 15, + "labelHeight": 26 + }, + "type": { + "label": "int", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 23, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "name", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "email", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "password", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 80, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "last_login", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 81, + "labelHeight": 26 + }, + "type": { + "label": "datetime", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 77, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + } + ], + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 64, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "code", + "type": "code", + "pos": { + "x": 0, + "y": 784 + }, + "width": 512, + "height": 70, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a := 5\nb := a + 7\nfmt.Printf(\"%d\", b)", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "golang", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 196, + "labelHeight": 70, + "zIndex": 0, + "level": 1 + }, + { + "id": "package", + "type": "package", + "pos": { + "x": 0, + "y": 954 + }, + "width": 512, + "height": 105, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 5, + "labelHeight": 5, + "zIndex": 0, + "level": 1 + }, + { + "id": "no width", + "type": "", + "pos": { + "x": 206, + "y": 1159 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(class -> users)[0]", + "src": "class", + "srcArrow": "none", + "srcLabel": "", + "dst": "users", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 256, + "y": 368 + }, + { + "x": 256, + "y": 408 + }, + { + "x": 256, + "y": 428 + }, + { + "x": 256, + "y": 468 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(users -> code)[0]", + "src": "users", + "srcArrow": "none", + "srcLabel": "", + "dst": "code", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 256, + "y": 684 + }, + { + "x": 256, + "y": 724 + }, + { + "x": 256, + "y": 744 + }, + { + "x": 256, + "y": 784 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(code -> package)[0]", + "src": "code", + "srcArrow": "none", + "srcLabel": "", + "dst": "package", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 256, + "y": 854 + }, + { + "x": 256, + "y": 894 + }, + { + "x": 256, + "y": 920.8 + }, + { + "x": 256, + "y": 988 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(package -> no width)[0]", + "src": "package", + "srcArrow": "none", + "srcLabel": "", + "dst": "no width", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 256, + "y": 1059 + }, + { + "x": 256, + "y": 1099 + }, + { + "x": 256, + "y": 1119 + }, + { + "x": 256, + "y": 1159 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/unnamed_only_width/dagre/sketch.exp.svg b/e2etests/testdata/stable/unnamed_only_width/dagre/sketch.exp.svg new file mode 100644 index 000000000..96703e437 --- /dev/null +++ b/e2etests/testdata/stable/unnamed_only_width/dagre/sketch.exp.svg @@ -0,0 +1,62 @@ + +- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidid +int +name +string +email +string +password +string +last_login +datetime +:= 5 +:= a + 7 +fmt.Printf("%d", b) + + + \ No newline at end of file diff --git a/e2etests/testdata/stable/unnamed_only_width/elk/board.exp.json b/e2etests/testdata/stable/unnamed_only_width/elk/board.exp.json new file mode 100644 index 000000000..feb0395df --- /dev/null +++ b/e2etests/testdata/stable/unnamed_only_width/elk/board.exp.json @@ -0,0 +1,538 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "class", + "type": "class", + "pos": { + "x": 12, + "y": 12 + }, + "width": 512, + "height": 368, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": [ + { + "name": "num", + "type": "int", + "visibility": "private" + }, + { + "name": "timeout", + "type": "int", + "visibility": "private" + }, + { + "name": "pid", + "type": "", + "visibility": "private" + } + ], + "methods": [ + { + "name": "getStatus()", + "return": "Enum", + "visibility": "public" + }, + { + "name": "getJobs()", + "return": "Job[]", + "visibility": "public" + }, + { + "name": "setTimeout(seconds int)", + "return": "void", + "visibility": "public" + } + ], + "columns": null, + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 5, + "labelHeight": 5, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "users", + "type": "sql_table", + "pos": { + "x": 12, + "y": 480 + }, + "width": 512, + "height": 216, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": { + "label": "id", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 15, + "labelHeight": 26 + }, + "type": { + "label": "int", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 23, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "name", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "email", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 47, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "password", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 80, + "labelHeight": 26 + }, + "type": { + "label": "string", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 48, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + }, + { + "name": { + "label": "last_login", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 81, + "labelHeight": 26 + }, + "type": { + "label": "datetime", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 77, + "labelHeight": 26 + }, + "constraint": "", + "reference": "" + } + ], + "label": "", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 64, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "code", + "type": "code", + "pos": { + "x": 12, + "y": 796 + }, + "width": 512, + "height": 70, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0A0F25", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "a := 5\nb := a + 7\nfmt.Printf(\"%d\", b)", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "golang", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 196, + "labelHeight": 70, + "zIndex": 0, + "level": 1 + }, + { + "id": "package", + "type": "package", + "pos": { + "x": 12, + "y": 966 + }, + "width": 512, + "height": 105, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#EDF0FD", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 5, + "labelHeight": 5, + "zIndex": 0, + "level": 1 + }, + { + "id": "no width", + "type": "", + "pos": { + "x": 218, + "y": 1171 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1 + } + ], + "connections": [ + { + "id": "(class -> users)[0]", + "src": "class", + "srcArrow": "none", + "srcLabel": "", + "dst": "users", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 268, + "y": 380 + }, + { + "x": 268, + "y": 480 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(users -> code)[0]", + "src": "users", + "srcArrow": "none", + "srcLabel": "", + "dst": "code", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 268, + "y": 696 + }, + { + "x": 268, + "y": 796 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(code -> package)[0]", + "src": "code", + "srcArrow": "none", + "srcLabel": "", + "dst": "package", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 268, + "y": 866 + }, + { + "x": 268, + "y": 1000 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(package -> no width)[0]", + "src": "package", + "srcArrow": "none", + "srcLabel": "", + "dst": "no width", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 268, + "y": 1071 + }, + { + "x": 268, + "y": 1171 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/stable/unnamed_only_width/elk/sketch.exp.svg b/e2etests/testdata/stable/unnamed_only_width/elk/sketch.exp.svg new file mode 100644 index 000000000..5e434c0cb --- /dev/null +++ b/e2etests/testdata/stable/unnamed_only_width/elk/sketch.exp.svg @@ -0,0 +1,62 @@ + +- +num +int- +timeout +int- +pid ++ +getStatus() +Enum+ +getJobs() +Job[]+ +setTimeout(seconds int) +voidid +int +name +string +email +string +password +string +last_login +datetime +:= 5 +:= a + 7 +fmt.Printf("%d", b) + + + \ No newline at end of file From 8384d96763743dd604c3177a5e8887c193497cb9 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 28 Dec 2022 18:14:19 -0800 Subject: [PATCH 243/257] refactor SetDimensions --- d2graph/d2graph.go | 383 ++++++++++++++++++++++++--------------------- 1 file changed, 206 insertions(+), 177 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 1b667c665..60af1b33d 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -3,6 +3,7 @@ package d2graph import ( "errors" "fmt" + "math" "net/url" "strconv" "strings" @@ -21,6 +22,7 @@ import ( ) const INNER_LABEL_PADDING int = 5 +const DEFAULT_SHAPE_PADDING = 100. // TODO: Refactor with a light abstract layer on top of AST implementing scenarios, // variables, imports, substitutions and then a final set of structures representing @@ -668,6 +670,164 @@ func (obj *Object) AppendReferences(ida []string, ref Reference, unresolvedObj * } } +func (obj *Object) GetLabelSize(mtexts []*d2target.MText, ruler *textmeasure.Ruler, fontFamily *d2fonts.FontFamily) (*d2target.TextDimensions, error) { + shapeType := strings.ToLower(obj.Attributes.Shape.Value) + + var dims *d2target.TextDimensions + switch shapeType { + case d2target.ShapeText: + if obj.Attributes.Language == "latex" { + width, height, err := d2latex.Measure(obj.Text().Text) + if err != nil { + return nil, err + } + dims = d2target.NewTextDimensions(width, height) + } else if obj.Attributes.Language != "" { + var err error + dims, err = getMarkdownDimensions(mtexts, ruler, obj.Text(), fontFamily) + if err != nil { + return nil, err + } + } else { + dims = GetTextDimensions(mtexts, ruler, obj.Text(), fontFamily) + } + + case d2target.ShapeClass: + dims = GetTextDimensions(mtexts, ruler, obj.Text(), go2.Pointer(d2fonts.SourceCodePro)) + + default: + dims = GetTextDimensions(mtexts, ruler, obj.Text(), fontFamily) + } + + if shapeType == d2target.ShapeSQLTable && obj.Attributes.Label.Value == "" { + // measure with placeholder text to determine height + placeholder := *obj.Text() + placeholder.Text = "Table" + dims = GetTextDimensions(mtexts, ruler, &placeholder, fontFamily) + } + + if dims == nil { + if shapeType == d2target.ShapeImage { + dims = d2target.NewTextDimensions(0, 0) + } else { + return nil, fmt.Errorf("dimensions for object label %#v not found", obj.Text()) + } + } + + return dims, nil +} + +func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.Ruler, fontFamily *d2fonts.FontFamily, labelDims d2target.TextDimensions) (*d2target.TextDimensions, error) { + dims := d2target.TextDimensions{} + + shapeType := strings.ToLower(obj.Attributes.Shape.Value) + + switch shapeType { + default: + return d2target.NewTextDimensions(labelDims.Width, labelDims.Height), nil + + case d2target.ShapeImage: + return d2target.NewTextDimensions(128, 128), nil + + case d2target.ShapeClass: + maxWidth := labelDims.Width + + for _, f := range obj.Class.Fields { + fdims := GetTextDimensions(mtexts, ruler, f.Text(), go2.Pointer(d2fonts.SourceCodePro)) + if fdims == nil { + return nil, fmt.Errorf("dimensions for class field %#v not found", f.Text()) + } + lineWidth := fdims.Width + if maxWidth < lineWidth { + maxWidth = lineWidth + } + } + for _, m := range obj.Class.Methods { + mdims := GetTextDimensions(mtexts, ruler, m.Text(), go2.Pointer(d2fonts.SourceCodePro)) + if mdims == nil { + return nil, fmt.Errorf("dimensions for class method %#v not found", m.Text()) + } + lineWidth := mdims.Width + if maxWidth < lineWidth { + maxWidth = lineWidth + } + } + dims.Width = maxWidth + + // All rows should be the same height + var anyRowText *d2target.MText + if len(obj.Class.Fields) > 0 { + anyRowText = obj.Class.Fields[0].Text() + } else if len(obj.Class.Methods) > 0 { + anyRowText = obj.Class.Methods[0].Text() + } + if anyRowText != nil { + // 10px of padding top and bottom so text doesn't look squished + rowHeight := GetTextDimensions(mtexts, ruler, anyRowText, go2.Pointer(d2fonts.SourceCodePro)).Height + 20 + dims.Height = rowHeight * (len(obj.Class.Fields) + len(obj.Class.Methods) + 2) + } else { + dims.Height = labelDims.Height + } + + case d2target.ShapeSQLTable: + maxNameWidth := 0 + maxTypeWidth := 0 + constraintWidth := 0 + + for i := range obj.SQLTable.Columns { + // Note: we want to set dimensions of actual column not the for loop copy of the struct + c := &obj.SQLTable.Columns[i] + ctexts := c.Texts() + + nameDims := GetTextDimensions(mtexts, ruler, ctexts[0], fontFamily) + if nameDims == nil { + return nil, fmt.Errorf("dimensions for sql_table name %#v not found", ctexts[0].Text) + } + c.Name.LabelWidth = nameDims.Width + c.Name.LabelHeight = nameDims.Height + if maxNameWidth < nameDims.Width { + maxNameWidth = nameDims.Width + } + + typeDims := GetTextDimensions(mtexts, ruler, ctexts[1], fontFamily) + if typeDims == nil { + return nil, fmt.Errorf("dimensions for sql_table type %#v not found", ctexts[1].Text) + } + c.Type.LabelWidth = typeDims.Width + c.Type.LabelHeight = typeDims.Height + if maxTypeWidth < typeDims.Width { + maxTypeWidth = typeDims.Width + } + + if c.Constraint != "" { + // covers UNQ constraint with padding + constraintWidth = 60 + } + } + + // The rows get padded a little due to header font being larger than row font + dims.Height = labelDims.Height * (len(obj.SQLTable.Columns) + 1) + dims.Width = d2target.NamePadding + maxNameWidth + d2target.TypePadding + maxTypeWidth + d2target.TypePadding + constraintWidth + } + return &dims, nil +} + +func (obj *Object) GetPadding() (x, y float64) { + + switch strings.ToLower(obj.Attributes.Shape.Value) { + case d2target.ShapeImage, + d2target.ShapeSQLTable, + d2target.ShapeText, + d2target.ShapeCode: + return 0., 0. + case d2target.ShapeClass: + // TODO fix class row width measurements (see SQL table) + return 100., 0. + default: + return DEFAULT_SHAPE_PADDING, DEFAULT_SHAPE_PADDING + } +} + type Edge struct { Index int `json:"index"` @@ -909,62 +1069,24 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler } shapeType := strings.ToLower(obj.Attributes.Shape.Value) - switch shapeType { - case d2target.ShapeClass, - d2target.ShapeSQLTable, - d2target.ShapeCode, - d2target.ShapeImage, - d2target.ShapeText: - // edge cases for unnamed class, etc - default: - if obj.Attributes.Label.Value == "" && desiredWidth == 0 && desiredHeight == 0 { - obj.Width = 100 - obj.Height = 100 - continue - } - } + // switch shapeType { + // case d2target.ShapeClass, + // d2target.ShapeSQLTable, + // d2target.ShapeCode, + // d2target.ShapeImage, + // d2target.ShapeText: + // // edge cases for unnamed class, etc + // default: + // if obj.Attributes.Label.Value == "" && desiredWidth == 0 && desiredHeight == 0 { + // obj.Width = 100 + // obj.Height = 100 + // continue + // } + // } - var dims *d2target.TextDimensions - var innerLabelPadding = INNER_LABEL_PADDING - switch shapeType { - case d2target.ShapeText: - if obj.Attributes.Language == "latex" { - width, height, err := d2latex.Measure(obj.Text().Text) - if err != nil { - return err - } - dims = d2target.NewTextDimensions(width, height) - } else if obj.Attributes.Language != "" { - var err error - dims, err = getMarkdownDimensions(mtexts, ruler, obj.Text(), fontFamily) - if err != nil { - return err - } - } else { - dims = GetTextDimensions(mtexts, ruler, obj.Text(), fontFamily) - } - innerLabelPadding = 0 - - case d2target.ShapeClass: - dims = GetTextDimensions(mtexts, ruler, obj.Text(), go2.Pointer(d2fonts.SourceCodePro)) - - default: - dims = GetTextDimensions(mtexts, ruler, obj.Text(), fontFamily) - } - - if shapeType == d2target.ShapeSQLTable && obj.Attributes.Label.Value == "" { - // measure with placeholder text to determine height - placeholder := *obj.Text() - placeholder.Text = "Table" - dims = GetTextDimensions(mtexts, ruler, &placeholder, fontFamily) - } - - if dims == nil { - if shapeType == d2target.ShapeImage { - dims = d2target.NewTextDimensions(0, 0) - } else { - return fmt.Errorf("dimensions for object label %#v not found", obj.Text()) - } + labelDims, err := obj.GetLabelSize(mtexts, ruler, fontFamily) + if err != nil { + return err } switch shapeType { @@ -972,139 +1094,46 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler // no labels default: if obj.Attributes.Label.Value != "" { - obj.LabelWidth = go2.Pointer(dims.Width) - obj.LabelHeight = go2.Pointer(dims.Height) + obj.LabelWidth = go2.Pointer(labelDims.Width) + obj.LabelHeight = go2.Pointer(labelDims.Height) } } - dims.Width += innerLabelPadding - dims.Height += innerLabelPadding - obj.LabelDimensions = *dims - // the desired dimensions must be at least as large as the text - obj.Width = float64(go2.Max(dims.Width, desiredWidth)) - obj.Height = float64(go2.Max(dims.Height, desiredHeight)) + if shapeType != d2target.ShapeText && obj.Attributes.Label.Value != "" { + labelDims.Width += INNER_LABEL_PADDING + labelDims.Height += INNER_LABEL_PADDING + } + obj.LabelDimensions = *labelDims + + defaultDims, err := obj.GetDefaultSize(mtexts, ruler, fontFamily, *labelDims) + if err != nil { + return err + } + + obj.Width = float64(go2.Max(defaultDims.Width, desiredWidth)) + obj.Height = float64(go2.Max(defaultDims.Height, desiredHeight)) + + paddingX, paddingY := obj.GetPadding() switch shapeType { + case d2target.ShapeSquare, d2target.ShapeCircle: + if desiredWidth != 0 || desiredHeight != 0 { + paddingX = 0. + paddingY = 0. + } + + sideLength := math.Max(obj.Width+paddingX, obj.Height+paddingY) + obj.Width = sideLength + obj.Height = sideLength + default: if desiredWidth == 0 { - obj.Width += 100 + obj.Width += float64(paddingX) } if desiredHeight == 0 { - obj.Height += 100 - } - - case d2target.ShapeImage: - if desiredWidth == 0 { - obj.Width = 128 - } - if desiredHeight == 0 { - obj.Height = 128 - } - - case d2target.ShapeSquare, d2target.ShapeCircle: - sideLength := go2.Max(obj.Width, obj.Height) - padding := 0. - if desiredWidth == 0 && desiredHeight == 0 { - padding = 100. - } - obj.Width = sideLength + padding - obj.Height = sideLength + padding - - case d2target.ShapeClass: - maxWidth := dims.Width - - for _, f := range obj.Class.Fields { - fdims := GetTextDimensions(mtexts, ruler, f.Text(), go2.Pointer(d2fonts.SourceCodePro)) - if fdims == nil { - return fmt.Errorf("dimensions for class field %#v not found", f.Text()) - } - lineWidth := fdims.Width - if maxWidth < lineWidth { - maxWidth = lineWidth - } - } - for _, m := range obj.Class.Methods { - mdims := GetTextDimensions(mtexts, ruler, m.Text(), go2.Pointer(d2fonts.SourceCodePro)) - if mdims == nil { - return fmt.Errorf("dimensions for class method %#v not found", m.Text()) - } - lineWidth := mdims.Width - if maxWidth < lineWidth { - maxWidth = lineWidth - } - } - - // All rows should be the same height - var anyRowText *d2target.MText - if len(obj.Class.Fields) > 0 { - anyRowText = obj.Class.Fields[0].Text() - } else if len(obj.Class.Methods) > 0 { - anyRowText = obj.Class.Methods[0].Text() - } - if anyRowText != nil { - // 10px of padding top and bottom so text doesn't look squished - rowHeight := GetTextDimensions(mtexts, ruler, anyRowText, go2.Pointer(d2fonts.SourceCodePro)).Height + 20 - obj.Height = float64(rowHeight * (len(obj.Class.Fields) + len(obj.Class.Methods) + 2)) - } - // Leave room for padding - obj.Width = float64(maxWidth + 100) - - case d2target.ShapeSQLTable: - maxNameWidth := 0 - maxTypeWidth := 0 - constraintWidth := 0 - - for i := range obj.SQLTable.Columns { - // Note: we want to set dimensions of actual column not the for loop copy of the struct - c := &obj.SQLTable.Columns[i] - ctexts := c.Texts() - - nameDims := GetTextDimensions(mtexts, ruler, ctexts[0], fontFamily) - if nameDims == nil { - return fmt.Errorf("dimensions for sql_table name %#v not found", ctexts[0].Text) - } - c.Name.LabelWidth = nameDims.Width - c.Name.LabelHeight = nameDims.Height - if maxNameWidth < nameDims.Width { - maxNameWidth = nameDims.Width - } - - typeDims := GetTextDimensions(mtexts, ruler, ctexts[1], fontFamily) - if typeDims == nil { - return fmt.Errorf("dimensions for sql_table type %#v not found", ctexts[1].Text) - } - c.Type.LabelWidth = typeDims.Width - c.Type.LabelHeight = typeDims.Height - if maxTypeWidth < typeDims.Width { - maxTypeWidth = typeDims.Width - } - - if c.Constraint != "" { - // covers UNQ constraint with padding - constraintWidth = 60 - } - } - - // The rows get padded a little due to header font being larger than row font - obj.Height = float64(dims.Height * (len(obj.SQLTable.Columns) + 1)) - obj.Width = float64(d2target.NamePadding + maxNameWidth + d2target.TypePadding + maxTypeWidth + d2target.TypePadding + constraintWidth) - - case d2target.ShapeText, d2target.ShapeCode: - } - - switch shapeType { - case d2target.ShapeClass, - d2target.ShapeSQLTable, - d2target.ShapeCode, - d2target.ShapeText: - if float64(desiredWidth) > obj.Width { - obj.Width = float64(desiredWidth) - } - if float64(desiredHeight) > obj.Height { - obj.Height = float64(desiredHeight) + obj.Height += float64(paddingY) } } - } for _, edge := range g.Edges { endpointLabels := []string{} From 5509621a43dfc5ccbf0717678807d21d1adcb463 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 28 Dec 2022 18:18:28 -0800 Subject: [PATCH 244/257] update tests --- .../dagre/board.exp.json | 20 ++++---- .../dagre/sketch.exp.svg | 28 +++++------ .../elk/board.exp.json | 16 +++---- .../elk/sketch.exp.svg | 28 +++++------ .../unnamed_only_height/dagre/board.exp.json | 16 +++---- .../unnamed_only_height/dagre/sketch.exp.svg | 2 +- .../unnamed_only_height/elk/board.exp.json | 18 ++++---- .../unnamed_only_height/elk/sketch.exp.svg | 2 +- .../unnamed_only_width/dagre/board.exp.json | 46 +++++++++---------- .../unnamed_only_width/dagre/sketch.exp.svg | 28 +++++------ .../unnamed_only_width/elk/board.exp.json | 34 +++++++------- .../unnamed_only_width/elk/sketch.exp.svg | 28 +++++------ 12 files changed, 133 insertions(+), 133 deletions(-) diff --git a/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json b/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json index f96e89a36..2d10adc2e 100644 --- a/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json +++ b/e2etests/testdata/regression/unnamed_class_table_code/dagre/board.exp.json @@ -68,8 +68,8 @@ "italic": false, "bold": false, "underline": false, - "labelWidth": 5, - "labelHeight": 5, + "labelWidth": 0, + "labelHeight": 0, "zIndex": 0, "level": 1, "primaryAccentColor": "#0D32B2", @@ -84,7 +84,7 @@ "y": 468 }, "width": 208, - "height": 216, + "height": 186, "opacity": 1, "strokeDash": 0, "strokeWidth": 2, @@ -251,8 +251,8 @@ "italic": false, "bold": true, "underline": false, - "labelWidth": 64, - "labelHeight": 36, + "labelWidth": 59, + "labelHeight": 31, "zIndex": 0, "level": 1, "primaryAccentColor": "#0D32B2", @@ -264,7 +264,7 @@ "type": "code", "pos": { "x": 113, - "y": 784 + "y": 754 }, "width": 196, "height": 70, @@ -375,19 +375,19 @@ "route": [ { "x": 211, - "y": 684 + "y": 654 }, { "x": 211, - "y": 724 + "y": 694 }, { "x": 211, - "y": 744 + "y": 714 }, { "x": 211, - "y": 784 + "y": 754 } ], "isCurve": true, diff --git a/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg b/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg index 15c3051ff..2dc724baf 100644 --- a/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/unnamed_class_table_code/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ \ No newline at end of file From f8482ee96a07c739cd188b763c39327391326189 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 28 Dec 2022 23:53:37 -0800 Subject: [PATCH 249/257] fix elk panic with empty label --- d2layouts/d2elklayout/layout.go | 6 +- .../dagre/board.exp.json | 50 ++++++++ .../dagre/sketch.exp.svg | 6 +- .../elk/board.exp.json | 107 ++++++++++++++++++ .../elk/sketch.exp.svg | 24 ++++ 5 files changed, 188 insertions(+), 5 deletions(-) create mode 100644 e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json create mode 100644 e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index 6dd37f828..ada0ca0e7 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -147,8 +147,10 @@ func Layout(ctx context.Context, g *d2graph.Graph) (err error) { walk(g.Root, nil, func(obj, parent *d2graph.Object) { height := obj.Height - if obj.Attributes.Shape.Value == d2target.ShapeImage || obj.Attributes.Icon != nil { - height += float64(*obj.LabelHeight) + label.PADDING + if obj.LabelWidth != nil && obj.LabelHeight != nil { + if obj.Attributes.Shape.Value == d2target.ShapeImage || obj.Attributes.Icon != nil { + height += float64(*obj.LabelHeight) + label.PADDING + } } n := &ELKNode{ diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json b/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json index 3d188b1cf..f1b566716 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/board.exp.json @@ -51,6 +51,56 @@ "labelHeight": 0, "zIndex": 0, "level": 1 + }, + { + "id": "ico", + "type": "", + "pos": { + "x": 188, + "y": 14 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/infra/019-network.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1 } ], "connections": [] diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/sketch.exp.svg b/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/sketch.exp.svg index eff9f32b3..3726c5c2d 100644 --- a/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/dagre/sketch.exp.svg @@ -2,7 +2,7 @@ + \ No newline at end of file diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json new file mode 100644 index 000000000..e37d0a2b3 --- /dev/null +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/board.exp.json @@ -0,0 +1,107 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "img", + "type": "image", + "pos": { + "x": 12, + "y": 12 + }, + "width": 128, + "height": 128, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#FFFFFF", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/infra/019-network.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1 + }, + { + "id": "ico", + "type": "", + "pos": { + "x": 160, + "y": 26 + }, + "width": 100, + "height": 100, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#F7F8FE", + "stroke": "#0D32B2", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": { + "Scheme": "https", + "Opaque": "", + "User": null, + "Host": "icons.terrastruct.com", + "Path": "/infra/019-network.svg", + "RawPath": "", + "ForceQuery": false, + "RawQuery": "", + "Fragment": "", + "RawFragment": "" + }, + "iconPosition": "INSIDE_MIDDLE_CENTER", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "zIndex": 0, + "level": 1 + } + ], + "connections": [] +} diff --git a/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg new file mode 100644 index 000000000..81e2051b4 --- /dev/null +++ b/e2etests/testdata/regression/elk_img_empty_label_panic/elk/sketch.exp.svg @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file From e44662a9b68bb0358143935a45c771cbfb3daac2 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Thu, 29 Dec 2022 00:03:44 -0800 Subject: [PATCH 250/257] changelog --- ci/release/changelogs/next.md | 1 + 1 file changed, 1 insertion(+) diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md index 4457be55c..07a9d41ed 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -9,4 +9,5 @@ #### Bugfixes ⛑️ - Restricts where `near` key constant values can be used, with good error messages, instead of erroring (e.g. setting `near: top-center` on a container would cause bad layouts or error). [#538](https://github.com/terrastruct/d2/pull/538) +- Fixes an error during ELK layout when images had empty labels. [#555](https://github.com/terrastruct/d2/pull/555) - Fixes rendering classes and tables with empty headers. [#498](https://github.com/terrastruct/d2/pull/498) From 51c03985e78b4d05c6bc1bff599364df98f1dd03 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 28 Dec 2022 22:51:16 -0800 Subject: [PATCH 251/257] add only_header_class_table regression test --- e2etests/regression_test.go | 20 ++ .../dagre/board.exp.json | 259 ++++++++++++++++++ .../dagre/sketch.exp.svg | 40 +++ .../elk/board.exp.json | 241 ++++++++++++++++ .../elk/sketch.exp.svg | 40 +++ 5 files changed, 600 insertions(+) create mode 100644 e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/only_header_class_table/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/only_header_class_table/elk/board.exp.json create mode 100644 e2etests/testdata/regression/only_header_class_table/elk/sketch.exp.svg diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index a3698795b..aa8ca3b37 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -262,6 +262,26 @@ ico: { label: "" icon: https://icons.terrastruct.com/infra/019-network.svg } +`, + }, + { + name: "only_header_class_table", + script: ` + +class: RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBuffer { + shape: class +} + +table: RefreshAuthorizationPolicyCache { + shape: sql_table +} + +table with short col: RefreshAuthorizationPolicyCache { + shape: sql_table + ok +} + +class -> table -> table with short col `, }, } diff --git a/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json b/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json new file mode 100644 index 000000000..2b2cfb0cc --- /dev/null +++ b/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json @@ -0,0 +1,259 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "class", + "type": "class", + "pos": { + "x": 0, + "y": 0 + }, + "width": 1082, + "height": 36, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBuffer", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 982, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "table", + "type": "sql_table", + "pos": { + "x": 516, + "y": 136 + }, + "width": 50, + "height": 36, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "RefreshAuthorizationPolicyCache", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 361, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "table with short col", + "type": "sql_table", + "pos": { + "x": 506, + "y": 272 + }, + "width": 71, + "height": 72, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": { + "label": "ok", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 21, + "labelHeight": 26 + }, + "type": { + "label": "", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + } + ], + "label": "RefreshAuthorizationPolicyCache", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 361, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + } + ], + "connections": [ + { + "id": "(class -> table)[0]", + "src": "class", + "srcArrow": "none", + "srcLabel": "", + "dst": "table", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 541, + "y": 36 + }, + { + "x": 541, + "y": 76 + }, + { + "x": 541, + "y": 96 + }, + { + "x": 541, + "y": 136 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(table -> table with short col)[0]", + "src": "table", + "srcArrow": "none", + "srcLabel": "", + "dst": "table with short col", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 541, + "y": 172 + }, + { + "x": 541, + "y": 212 + }, + { + "x": 541, + "y": 232 + }, + { + "x": 541, + "y": 272 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/regression/only_header_class_table/dagre/sketch.exp.svg b/e2etests/testdata/regression/only_header_class_table/dagre/sketch.exp.svg new file mode 100644 index 000000000..8fe8b6bc4 --- /dev/null +++ b/e2etests/testdata/regression/only_header_class_table/dagre/sketch.exp.svg @@ -0,0 +1,40 @@ + +RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBufferRefreshAuthorizationPolicyCacheRefreshAuthorizationPolicyCacheok + + + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/only_header_class_table/elk/board.exp.json b/e2etests/testdata/regression/only_header_class_table/elk/board.exp.json new file mode 100644 index 000000000..142ca5423 --- /dev/null +++ b/e2etests/testdata/regression/only_header_class_table/elk/board.exp.json @@ -0,0 +1,241 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "class", + "type": "class", + "pos": { + "x": 12, + "y": 12 + }, + "width": 1082, + "height": 36, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBuffer", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 982, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "table", + "type": "sql_table", + "pos": { + "x": 528, + "y": 148 + }, + "width": 50, + "height": 36, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": null, + "label": "RefreshAuthorizationPolicyCache", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 361, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + }, + { + "id": "table with short col", + "type": "sql_table", + "pos": { + "x": 517, + "y": 284 + }, + "width": 71, + "height": 72, + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "borderRadius": 0, + "fill": "#0A0F25", + "stroke": "#FFFFFF", + "shadow": false, + "3d": false, + "multiple": false, + "tooltip": "", + "link": "", + "icon": null, + "iconPosition": "", + "blend": false, + "fields": null, + "methods": null, + "columns": [ + { + "name": { + "label": "ok", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 21, + "labelHeight": 26 + }, + "type": { + "label": "", + "fontSize": 0, + "fontFamily": "", + "language": "", + "color": "", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0 + }, + "constraint": "", + "reference": "" + } + ], + "label": "RefreshAuthorizationPolicyCache", + "fontSize": 20, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": true, + "underline": false, + "labelWidth": 361, + "labelHeight": 36, + "zIndex": 0, + "level": 1, + "primaryAccentColor": "#0D32B2", + "secondaryAccentColor": "#4A6FF3", + "neutralAccentColor": "#676C7E" + } + ], + "connections": [ + { + "id": "(class -> table)[0]", + "src": "class", + "srcArrow": "none", + "srcLabel": "", + "dst": "table", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 553, + "y": 48 + }, + { + "x": 553, + "y": 148 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + }, + { + "id": "(table -> table with short col)[0]", + "src": "table", + "srcArrow": "none", + "srcLabel": "", + "dst": "table with short col", + "dstArrow": "triangle", + "dstLabel": "", + "opacity": 1, + "strokeDash": 0, + "strokeWidth": 2, + "stroke": "#0D32B2", + "label": "", + "fontSize": 16, + "fontFamily": "DEFAULT", + "language": "", + "color": "#676C7E", + "italic": true, + "bold": false, + "underline": false, + "labelWidth": 0, + "labelHeight": 0, + "labelPosition": "", + "labelPercentage": 0, + "route": [ + { + "x": 553, + "y": 184 + }, + { + "x": 553, + "y": 284 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/regression/only_header_class_table/elk/sketch.exp.svg b/e2etests/testdata/regression/only_header_class_table/elk/sketch.exp.svg new file mode 100644 index 000000000..1c0e13989 --- /dev/null +++ b/e2etests/testdata/regression/only_header_class_table/elk/sketch.exp.svg @@ -0,0 +1,40 @@ + +RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBufferRefreshAuthorizationPolicyCacheRefreshAuthorizationPolicyCacheok + + + + + \ No newline at end of file From 8b814286939ee3120406e1447a986c028006e367 Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 28 Dec 2022 23:15:16 -0800 Subject: [PATCH 252/257] use header width for sql_tables if larger than row width --- d2graph/d2graph.go | 4 +++- d2renderers/d2svg/table.go | 4 ++-- d2target/sqltable.go | 5 +++-- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/d2graph/d2graph.go b/d2graph/d2graph.go index 7bc38cfa7..7bd59ec6a 100644 --- a/d2graph/d2graph.go +++ b/d2graph/d2graph.go @@ -805,7 +805,9 @@ func (obj *Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.R // The rows get padded a little due to header font being larger than row font dims.Height = labelDims.Height * (len(obj.SQLTable.Columns) + 1) - dims.Width = d2target.NamePadding + maxNameWidth + d2target.TypePadding + maxTypeWidth + d2target.TypePadding + constraintWidth + headerWidth := d2target.HeaderPadding + labelDims.Width + d2target.HeaderPadding + rowsWidth := d2target.NamePadding + maxNameWidth + d2target.TypePadding + maxTypeWidth + d2target.TypePadding + constraintWidth + dims.Width = go2.Max(headerWidth, rowsWidth) } return &dims, nil diff --git a/d2renderers/d2svg/table.go b/d2renderers/d2svg/table.go index 9ec48e0a9..46bdef37c 100644 --- a/d2renderers/d2svg/table.go +++ b/d2renderers/d2svg/table.go @@ -19,8 +19,8 @@ func tableHeader(shape d2target.Shape, box *geo.Box, text string, textWidth, tex if text != "" { tl := label.InsideMiddleLeft.GetPointOnBox( box, - 20, - textWidth, + float64(d2target.HeaderPadding), + float64(shape.Width), textHeight, ) diff --git a/d2target/sqltable.go b/d2target/sqltable.go index f19f2a94b..8332a34c8 100644 --- a/d2target/sqltable.go +++ b/d2target/sqltable.go @@ -3,8 +3,9 @@ package d2target import "oss.terrastruct.com/d2/d2renderers/d2fonts" const ( - NamePadding = 10 - TypePadding = 20 + NamePadding = 10 + TypePadding = 20 + HeaderPadding = 20 ) type SQLTable struct { From 6489f05e81edcf5a0cc2269f8388c70879bedb2e Mon Sep 17 00:00:00 2001 From: Gavin Nishizawa Date: Wed, 28 Dec 2022 23:25:49 -0800 Subject: [PATCH 253/257] update tests --- .../only_header_class_table/dagre/board.exp.json | 8 ++++---- .../only_header_class_table/dagre/sketch.exp.svg | 6 +++--- .../regression/only_header_class_table/elk/board.exp.json | 8 ++++---- .../regression/only_header_class_table/elk/sketch.exp.svg | 6 +++--- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json b/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json index 2b2cfb0cc..c35935f77 100644 --- a/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json +++ b/e2etests/testdata/regression/only_header_class_table/dagre/board.exp.json @@ -48,10 +48,10 @@ "id": "table", "type": "sql_table", "pos": { - "x": 516, + "x": 341, "y": 136 }, - "width": 50, + "width": 401, "height": 36, "opacity": 1, "strokeDash": 0, @@ -90,10 +90,10 @@ "id": "table with short col", "type": "sql_table", "pos": { - "x": 506, + "x": 341, "y": 272 }, - "width": 71, + "width": 401, "height": 72, "opacity": 1, "strokeDash": 0, diff --git a/e2etests/testdata/regression/only_header_class_table/dagre/sketch.exp.svg b/e2etests/testdata/regression/only_header_class_table/dagre/sketch.exp.svg index 8fe8b6bc4..f4ee758ba 100644 --- a/e2etests/testdata/regression/only_header_class_table/dagre/sketch.exp.svg +++ b/e2etests/testdata/regression/only_header_class_table/dagre/sketch.exp.svg @@ -18,9 +18,9 @@ width="1282" height="544" viewBox="-100 -100 1282 544">RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBufferRefreshAuthorizationPolicyCacheRefreshAuthorizationPolicyCacheok - - +RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBufferRefreshAuthorizationPolicyCacheRefreshAuthorizationPolicyCacheok + + RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBufferRefreshAuthorizationPolicyCacheRefreshAuthorizationPolicyCacheok - - +RefreshAuthorizationPolicyProtocolServerSideTranslatorProtocolBufferRefreshAuthorizationPolicyCacheRefreshAuthorizationPolicyCacheok + +