From f688efcb4835ff43025c19017afeead31d004826 Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 18 Jan 2023 14:34:14 -0800 Subject: [PATCH 1/2] propagate elk config for self loop spacing --- d2layouts/d2elklayout/layout.go | 1 + e2etests/regression_test.go | 10 + .../elk_loop_panic/dagre/board.exp.json | 212 ++++++++++++++++++ .../elk_loop_panic/dagre/sketch.exp.svg | 59 +++++ .../elk_loop_panic/elk/board.exp.json | 175 +++++++++++++++ .../elk_loop_panic/elk/sketch.exp.svg | 59 +++++ 6 files changed, 516 insertions(+) create mode 100644 e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json create mode 100644 e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg create mode 100644 e2etests/testdata/regression/elk_loop_panic/elk/board.exp.json create mode 100644 e2etests/testdata/regression/elk_loop_panic/elk/sketch.exp.svg diff --git a/d2layouts/d2elklayout/layout.go b/d2layouts/d2elklayout/layout.go index ce4a44f34..909a7eab1 100644 --- a/d2layouts/d2elklayout/layout.go +++ b/d2layouts/d2elklayout/layout.go @@ -195,6 +195,7 @@ func Layout(ctx context.Context, g *d2graph.Graph, opts *ConfigurableOpts) (err ConfigurableOpts: ConfigurableOpts{ NodeSpacing: opts.NodeSpacing, EdgeNodeSpacing: opts.EdgeNodeSpacing, + SelfLoopSpacing: opts.SelfLoopSpacing, Padding: opts.Padding, }, } diff --git a/e2etests/regression_test.go b/e2etests/regression_test.go index 5239201c0..13646d942 100644 --- a/e2etests/regression_test.go +++ b/e2etests/regression_test.go @@ -372,6 +372,16 @@ no leading: |python 1. they `), }, + { + name: "elk_loop_panic", + script: `x: { + a + b +} + +x.a -> x.a +`, + }, } runa(t, tcs) diff --git a/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json b/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json new file mode 100644 index 000000000..ca5d11974 --- /dev/null +++ b/e2etests/testdata/regression/elk_loop_panic/dagre/board.exp.json @@ -0,0 +1,212 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "x", + "type": "", + "pos": { + "x": 0, + "y": 0 + }, + "width": 426, + "height": 226, + "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": "x", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 18, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "x.a", + "type": "", + "pos": { + "x": 50, + "y": 50 + }, + "width": 113, + "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": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "x.b", + "type": "", + "pos": { + "x": 263, + "y": 50 + }, + "width": 113, + "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": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [ + { + "id": "x.(a -> a)[0]", + "src": "x.a", + "srcArrow": "none", + "srcLabel": "", + "dst": "x.a", + "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": 163, + "y": 73.37662337662337 + }, + { + "x": 189.66666666666669, + "y": 54.675324675324674 + }, + { + "x": 198, + "y": 50 + }, + { + "x": 200.5, + "y": 50 + }, + { + "x": 203, + "y": 50 + }, + { + "x": 206.33333333333331, + "y": 62.6 + }, + { + "x": 208.83333333333331, + "y": 81.5 + }, + { + "x": 211.33333333333334, + "y": 100.4 + }, + { + "x": 211.33333333333334, + "y": 125.6 + }, + { + "x": 208.83333333333331, + "y": 144.5 + }, + { + "x": 206.33333333333331, + "y": 163.4 + }, + { + "x": 189.66666666666669, + "y": 171.32467532467533 + }, + { + "x": 163, + "y": 152.62337662337663 + } + ], + "isCurve": true, + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg b/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg new file mode 100644 index 000000000..5a3042961 --- /dev/null +++ b/e2etests/testdata/regression/elk_loop_panic/dagre/sketch.exp.svg @@ -0,0 +1,59 @@ + +xab + + + \ No newline at end of file diff --git a/e2etests/testdata/regression/elk_loop_panic/elk/board.exp.json b/e2etests/testdata/regression/elk_loop_panic/elk/board.exp.json new file mode 100644 index 000000000..58c402aea --- /dev/null +++ b/e2etests/testdata/regression/elk_loop_panic/elk/board.exp.json @@ -0,0 +1,175 @@ +{ + "name": "", + "fontFamily": "SourceSansPro", + "shapes": [ + { + "id": "x", + "type": "", + "pos": { + "x": 12, + "y": 12 + }, + "width": 446, + "height": 276, + "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": "x", + "fontSize": 28, + "fontFamily": "DEFAULT", + "language": "", + "color": "#0A0F25", + "italic": false, + "bold": false, + "underline": false, + "labelWidth": 18, + "labelHeight": 41, + "labelPosition": "INSIDE_TOP_CENTER", + "zIndex": 0, + "level": 1 + }, + { + "id": "x.a", + "type": "", + "pos": { + "x": 137, + "y": 87 + }, + "width": 113, + "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": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + }, + { + "id": "x.b", + "type": "", + "pos": { + "x": 270, + "y": 87 + }, + "width": 113, + "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": true, + "underline": false, + "labelWidth": 13, + "labelHeight": 26, + "labelPosition": "INSIDE_MIDDLE_CENTER", + "zIndex": 0, + "level": 2 + } + ], + "connections": [ + { + "id": "x.(a -> a)[0]", + "src": "x.a", + "srcArrow": "none", + "srcLabel": "", + "dst": "x.a", + "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": 137, + "y": 129 + }, + { + "x": 87, + "y": 129 + }, + { + "x": 87, + "y": 171 + }, + { + "x": 137, + "y": 171 + } + ], + "animated": false, + "tooltip": "", + "icon": null, + "zIndex": 0 + } + ] +} diff --git a/e2etests/testdata/regression/elk_loop_panic/elk/sketch.exp.svg b/e2etests/testdata/regression/elk_loop_panic/elk/sketch.exp.svg new file mode 100644 index 000000000..c63d14456 --- /dev/null +++ b/e2etests/testdata/regression/elk_loop_panic/elk/sketch.exp.svg @@ -0,0 +1,59 @@ + +xab + + + \ No newline at end of file From 53c6b5bb62eda1c5840143443e981595b9c97f1b Mon Sep 17 00:00:00 2001 From: Alexander Wang Date: Wed, 18 Jan 2023 14:37:46 -0800 Subject: [PATCH 2/2] 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 7226a211e..0a3afb0f8 100644 --- a/ci/release/changelogs/next.md +++ b/ci/release/changelogs/next.md @@ -20,3 +20,4 @@ - Fixes code snippets not being tall enough with leading newlines. [#664](https://github.com/terrastruct/d2/pull/664) - Icon URLs that needed escaping (e.g. with ampersands) are handled correctly by CLI. [#666](https://github.com/terrastruct/d2/pull/666) - Fixes markdown shapes being slightly too short for their text in some cases. [#665](https://github.com/terrastruct/d2/pull/665) +- Fixes self-connections inside layouts when using ELK. [#676](https://github.com/terrastruct/d2/pull/676)