diff --git a/ci/release/changelogs/next.md b/ci/release/changelogs/next.md
index e07c71298..7519eeeca 100644
--- a/ci/release/changelogs/next.md
+++ b/ci/release/changelogs/next.md
@@ -7,6 +7,7 @@
- Cleaner watch mode logs without timestamps. [830](https://github.com/terrastruct/d2/pull/830)
- `near` key set to direct parent or ancestor throws an appropriate error message. [#851](https://github.com/terrastruct/d2/pull/851)
+- Dimensions and positions are able to be set from API. [#853](https://github.com/terrastruct/d2/pull/853)
#### Bugfixes ⛑️
diff --git a/d2oracle/edit.go b/d2oracle/edit.go
index 3537677b3..8813755bf 100644
--- a/d2oracle/edit.go
+++ b/d2oracle/edit.go
@@ -234,6 +234,26 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error {
attrs.Shape.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
+ case "width":
+ if attrs.Width != nil && attrs.Width.MapKey != nil {
+ attrs.Width.MapKey.SetScalar(mk.Value.ScalarBox())
+ return nil
+ }
+ case "height":
+ if attrs.Height != nil && attrs.Height.MapKey != nil {
+ attrs.Height.MapKey.SetScalar(mk.Value.ScalarBox())
+ return nil
+ }
+ case "top":
+ if attrs.Top != nil && attrs.Top.MapKey != nil {
+ attrs.Top.MapKey.SetScalar(mk.Value.ScalarBox())
+ return nil
+ }
+ case "left":
+ if attrs.Left != nil && attrs.Left.MapKey != nil {
+ attrs.Left.MapKey.SetScalar(mk.Value.ScalarBox())
+ return nil
+ }
case "style":
if len(mk.Key.Path[reservedIndex:]) != 2 {
return errors.New("malformed style setting, expected 2 part path")
@@ -667,6 +687,10 @@ func deleteReserved(g *d2graph.Graph, mk *d2ast.Key) (*d2graph.Graph, error) {
if id == "near" ||
id == "tooltip" ||
id == "icon" ||
+ id == "width" ||
+ id == "height" ||
+ id == "left" ||
+ id == "top" ||
id == "link" {
err := deleteObjField(g, obj, id)
if err != nil {
diff --git a/d2oracle/edit_test.go b/d2oracle/edit_test.go
index 6dd62ffec..f6dc0cf3a 100644
--- a/d2oracle/edit_test.go
+++ b/d2oracle/edit_test.go
@@ -695,6 +695,54 @@ square.style.opacity: 0.2
}
},
},
+ {
+ name: "set_position",
+ text: `square
+`,
+ key: `square.top`,
+ value: go2.Pointer(`200`),
+ exp: `square: {top: 200}
+`,
+ },
+ {
+ name: "replace_position",
+ text: `square: {
+ width: 100
+ top: 32
+ left: 44
+}
+`,
+ key: `square.top`,
+ value: go2.Pointer(`200`),
+ exp: `square: {
+ width: 100
+ top: 200
+ left: 44
+}
+`,
+ },
+ {
+ name: "set_dimensions",
+ text: `square
+`,
+ key: `square.width`,
+ value: go2.Pointer(`200`),
+ exp: `square: {width: 200}
+`,
+ },
+ {
+ name: "replace_dimensions",
+ text: `square: {
+ width: 100
+}
+`,
+ key: `square.width`,
+ value: go2.Pointer(`200`),
+ exp: `square: {
+ width: 200
+}
+`,
+ },
{
name: "label_unset",
text: `square: "Always try to do things in chronological order; it's less confusing that way."
@@ -4459,6 +4507,30 @@ A -> B: {style.stroke: "#2b50c2"}
exp: `A: {style.stroke: "#000e3d"}
B
A -> B
+`,
+ },
+ {
+ name: "width",
+
+ text: `x: {
+ width: 200
+}
+`,
+ key: `x.width`,
+
+ exp: `x
+`,
+ },
+ {
+ name: "left",
+
+ text: `x: {
+ left: 200
+}
+`,
+ key: `x.left`,
+
+ exp: `x
`,
},
}
diff --git a/docs/CONTRIBUTING.md b/docs/CONTRIBUTING.md
index 9c3fb421d..c074c4235 100644
--- a/docs/CONTRIBUTING.md
+++ b/docs/CONTRIBUTING.md
@@ -1,8 +1,8 @@
# Contributing
+- Welcome
- CI
-- Flow
- Logistics
- Dev
- Content
@@ -10,42 +10,68 @@
- Documentation
- Questions
+## Welcome
+
+D2's [long-term mission](https://d2lang.com/tour/future/) is to significantly reduce the
+amount of time and effort it takes to create and maintain high-quality diagrams for every
+software team. We started this because we love the idea of creating diagrams with text --
+but it was clear the existing solutions were inadequete in their state and speed of
+execution for this idea to be widely usable.
+
+We've tried our best to avoid the mistakes of the past and take inspiration from the most
+successful modern programming and configuration languages. D2 has built up each step of
+the text-to-diagram pipeline from scratch, rethinking each one from first principles, from
+the dead simple syntax, to the readable compiler, our own SVG renderer, etc.
+
+D2 is committed to making something people want to use. That means contributions don't
+only have to be in the form of pull requests. Your bug reports, plugins, examples,
+discussions of new ideas, help a great deal.
+
+If you'd like to get involved, we're also committed to helping you merge that first pull
+request. You should be able to freely pick up Issues tagged as "good first issue". If you
+need help getting started, please don't hesitate to pop into Discord -- as long as you
+want to help, we'll find the perfect task (complexity matches your appetite and
+programming experience, in an area you're interested in, etc).
+
## CI
Most of D2's CI is open sourced in its own
-[repository](https://github.com/terrastruct/ci). You can find commands in the Github
-workflows. E.g. run `./make.sh fmt` to run the formatter. Please make sure all CI is
-passing for any PRs.
-
-Most of the CI scripts rely on a submodule shared between many D2 repositories:
-[https://github.com/terrastruct/ci](https://github.com/terrastruct/ci). You should fetch
-the submodule whenever it differs:
-
-```sh
-git submodule update --recursive
-```
-
-If running for the first time for a repo (e.g. new clone), add `--init`:
+[repository](https://github.com/terrastruct/ci), included as a submodule. After you clone
+D2, make sure you initialize the submodules:
```sh
git submodule update --init --recursive
```
-## Flow
+`./make.sh` runs everything. Subcommands to run individual parts of the CI:
-The simplified D2 flow at a package level looks like:
+- `./make.sh fmt`
+- `./make.sh lint`
+- `./make.sh test`
+- `./make.sh race`
+- `./make.sh build`
-
+Here's what a successful run should look like:
+
+
+
+
+Please make sure CI is passing for any PRs submitted for review.
+
+Be sure to update the submodule whenever there are changes:
+
+```sh
+git submodule update --recursive
+```
## Logistics
- Use Go 1.18. Go 1.19's autofmt inexplicably strips spacing from ASCII art in comments.
+ We're working on it.
- Please sign your commits
([https://github.com/terrastruct/d2/pull/557#issuecomment-1367468730](https://github.com/terrastruct/d2/pull/557#issuecomment-1367468730)).
- D2 uses Issues as TODOs. No auto-closing on staleness.
- Branch off `master`.
-- Prefix pull request titles with a short descriptor of the domain, e.g. `d2renderer: Add
- x`.
- If there's an Issue related, include it by adding "[one-word] #[issue]", e.g. "Fixes
#123" somewhere in the description.
- Whenever possible and relevant, include a screenshot or screen-recording.
@@ -54,25 +80,37 @@ The simplified D2 flow at a package level looks like:
### Content
-Please choose an Issue with a "TODO" label. If you'd like to propose new functionality or
-change to current functionality, please create an Issue first with a proposal. When you
-start work on an Issue, please leave a comment so others know that it's being worked on.
+Unless you've contributed before, it's safest to choose an Issue with a "good first issue"
+label. If you'd like to propose new functionality or change to current functionality,
+please create an Issue first with a proposal. When you start work on an Issue, please
+leave a comment so others know that it's being worked on.
### Tests
-All code changes must include tests. D2 mostly has functional tests, and uses
-[diff](https://github.com/terrastruct/diff) as a framework that gives Git-style
-comparisons of expected vs actual output for each stage. There are ample examples in each
-package of this -- try changing some test and run it to see.
+D2 has extensive tests, and all code changes must include tests.
With the exception of changes to the renderer, all code should include a package-specific
-test. If it's a visual change, an e2e test should accompany.
+test. If it's a visual change, an end-to-end (e2e) test should accompany.
+
+Let's say I make some code changes. I can easily see how this affects the end result by
+running:
+
+```
+./ci/e2ereport.sh -delta
+```
+
+This gives me a nice HMTL output of what the test expected vs what it got (this was a PR
+fixing multi-byte character labels):
+
+
+
+Run `./ci/e2ereport.sh -help` for flags, including how to get deltas for a single test.
If you're testing labels and strings, it's encouraged to use 1-letter strings (`x`) in small
functional tests to minimally pinpoint issues. If you are testing something that exercises
variations in strings, or want to mimic more realistic diagram text, it's encouraged you
generate random strings and words from `fortune`. It gives a good range of the English
-language. Sometimes it gives controversial sentences -- don't use those.
+language. (Sometimes it gives controversial sentences -- don't use those.)
Script to generate one line of random text:
```
diff --git a/testdata/d2oracle/TestDelete/left.exp.json b/testdata/d2oracle/TestDelete/left.exp.json
new file mode 100644
index 000000000..0be52a3ad
--- /dev/null
+++ b/testdata/d2oracle/TestDelete/left.exp.json
@@ -0,0 +1,109 @@
+{
+ "graph": {
+ "name": "",
+ "ast": {
+ "range": "d2/testdata/d2oracle/TestDelete/left.d2,0:0:0-1:0:2",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestDelete/left.d2,0:0:0-0:1:1",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestDelete/left.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestDelete/left.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "x",
+ "raw_string": "x"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {}
+ }
+ }
+ ]
+ },
+ "root": {
+ "id": "",
+ "id_val": "",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "attributes": {
+ "label": {
+ "value": ""
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": ""
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ },
+ "edges": null,
+ "objects": [
+ {
+ "id": "x",
+ "id_val": "x",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2oracle/TestDelete/left.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestDelete/left.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "x",
+ "raw_string": "x"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "x"
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ }
+ ]
+ },
+ "err": ""
+}
diff --git a/testdata/d2oracle/TestDelete/width.exp.json b/testdata/d2oracle/TestDelete/width.exp.json
new file mode 100644
index 000000000..c1c010bcb
--- /dev/null
+++ b/testdata/d2oracle/TestDelete/width.exp.json
@@ -0,0 +1,109 @@
+{
+ "graph": {
+ "name": "",
+ "ast": {
+ "range": "d2/testdata/d2oracle/TestDelete/width.d2,0:0:0-1:0:2",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestDelete/width.d2,0:0:0-0:1:1",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestDelete/width.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestDelete/width.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "x",
+ "raw_string": "x"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {}
+ }
+ }
+ ]
+ },
+ "root": {
+ "id": "",
+ "id_val": "",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "attributes": {
+ "label": {
+ "value": ""
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": ""
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ },
+ "edges": null,
+ "objects": [
+ {
+ "id": "x",
+ "id_val": "x",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2oracle/TestDelete/width.d2,0:0:0-0:1:1",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestDelete/width.d2,0:0:0-0:1:1",
+ "value": [
+ {
+ "string": "x",
+ "raw_string": "x"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "x"
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ }
+ ]
+ },
+ "err": ""
+}
diff --git a/testdata/d2oracle/TestSet/replace_dimensions.exp.json b/testdata/d2oracle/TestSet/replace_dimensions.exp.json
new file mode 100644
index 000000000..cfb65d1c3
--- /dev/null
+++ b/testdata/d2oracle/TestSet/replace_dimensions.exp.json
@@ -0,0 +1,147 @@
+{
+ "graph": {
+ "name": "",
+ "ast": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,0:0:0-3:0:25",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,0:0:0-2:1:24",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,0:0:0-0:6:6",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,0:0:0-0:6:6",
+ "value": [
+ {
+ "string": "square",
+ "raw_string": "square"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "map": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,0:8:8-2:0:23",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,1:2:12-1:12:22",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,1:2:12-1:7:17",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,1:2:12-1:7:17",
+ "value": [
+ {
+ "string": "width",
+ "raw_string": "width"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "number": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,1:9:19-1:12:22",
+ "raw": "200",
+ "value": "200"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ },
+ "root": {
+ "id": "",
+ "id_val": "",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "attributes": {
+ "label": {
+ "value": ""
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": ""
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ },
+ "edges": null,
+ "objects": [
+ {
+ "id": "square",
+ "id_val": "square",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,0:0:0-0:6:6",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_dimensions.d2,0:0:0-0:6:6",
+ "value": [
+ {
+ "string": "square",
+ "raw_string": "square"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "square"
+ },
+ "style": {},
+ "width": {
+ "value": "200"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ }
+ ]
+ },
+ "err": ""
+}
diff --git a/testdata/d2oracle/TestSet/replace_position.exp.json b/testdata/d2oracle/TestSet/replace_position.exp.json
new file mode 100644
index 000000000..8a0cfec54
--- /dev/null
+++ b/testdata/d2oracle/TestSet/replace_position.exp.json
@@ -0,0 +1,211 @@
+{
+ "graph": {
+ "name": "",
+ "ast": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,0:0:0-5:0:47",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,0:0:0-4:1:46",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,0:0:0-0:6:6",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,0:0:0-0:6:6",
+ "value": [
+ {
+ "string": "square",
+ "raw_string": "square"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "map": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,0:8:8-4:0:45",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,1:2:12-1:12:22",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,1:2:12-1:7:17",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,1:2:12-1:7:17",
+ "value": [
+ {
+ "string": "width",
+ "raw_string": "width"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "number": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,1:9:19-1:12:22",
+ "raw": "100",
+ "value": "100"
+ }
+ }
+ }
+ },
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,2:2:25-2:10:33",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,2:2:25-2:5:28",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,2:2:25-2:5:28",
+ "value": [
+ {
+ "string": "top",
+ "raw_string": "top"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "number": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,2:7:30-2:10:33",
+ "raw": "200",
+ "value": "200"
+ }
+ }
+ }
+ },
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,3:2:36-3:10:44",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,3:2:36-3:6:40",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,3:2:36-3:6:40",
+ "value": [
+ {
+ "string": "left",
+ "raw_string": "left"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "number": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,3:8:42-3:10:44",
+ "raw": "44",
+ "value": "44"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ },
+ "root": {
+ "id": "",
+ "id_val": "",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "attributes": {
+ "label": {
+ "value": ""
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": ""
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ },
+ "edges": null,
+ "objects": [
+ {
+ "id": "square",
+ "id_val": "square",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,0:0:0-0:6:6",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/replace_position.d2,0:0:0-0:6:6",
+ "value": [
+ {
+ "string": "square",
+ "raw_string": "square"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "square"
+ },
+ "style": {},
+ "width": {
+ "value": "100"
+ },
+ "top": {
+ "value": "200"
+ },
+ "left": {
+ "value": "44"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ }
+ ]
+ },
+ "err": ""
+}
diff --git a/testdata/d2oracle/TestSet/set_dimensions.exp.json b/testdata/d2oracle/TestSet/set_dimensions.exp.json
new file mode 100644
index 000000000..073461ca1
--- /dev/null
+++ b/testdata/d2oracle/TestSet/set_dimensions.exp.json
@@ -0,0 +1,147 @@
+{
+ "graph": {
+ "name": "",
+ "ast": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:0:0-1:0:21",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:0:0-0:20:20",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:0:0-0:6:6",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:0:0-0:6:6",
+ "value": [
+ {
+ "string": "square",
+ "raw_string": "square"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "map": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:8:8-0:19:19",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:9:9-0:19:19",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:9:9-0:14:14",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:9:9-0:14:14",
+ "value": [
+ {
+ "string": "width",
+ "raw_string": "width"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "number": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:16:16-0:19:19",
+ "raw": "200",
+ "value": "200"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ },
+ "root": {
+ "id": "",
+ "id_val": "",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "attributes": {
+ "label": {
+ "value": ""
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": ""
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ },
+ "edges": null,
+ "objects": [
+ {
+ "id": "square",
+ "id_val": "square",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:0:0-0:6:6",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/set_dimensions.d2,0:0:0-0:6:6",
+ "value": [
+ {
+ "string": "square",
+ "raw_string": "square"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "square"
+ },
+ "style": {},
+ "width": {
+ "value": "200"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ }
+ ]
+ },
+ "err": ""
+}
diff --git a/testdata/d2oracle/TestSet/set_position.exp.json b/testdata/d2oracle/TestSet/set_position.exp.json
new file mode 100644
index 000000000..321da083b
--- /dev/null
+++ b/testdata/d2oracle/TestSet/set_position.exp.json
@@ -0,0 +1,147 @@
+{
+ "graph": {
+ "name": "",
+ "ast": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:0:0-1:0:19",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:0:0-0:18:18",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:0:0-0:6:6",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:0:0-0:6:6",
+ "value": [
+ {
+ "string": "square",
+ "raw_string": "square"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "map": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:8:8-0:17:17",
+ "nodes": [
+ {
+ "map_key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:9:9-0:17:17",
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:9:9-0:12:12",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:9:9-0:12:12",
+ "value": [
+ {
+ "string": "top",
+ "raw_string": "top"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "primary": {},
+ "value": {
+ "number": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:14:14-0:17:17",
+ "raw": "200",
+ "value": "200"
+ }
+ }
+ }
+ }
+ ]
+ }
+ }
+ }
+ }
+ ]
+ },
+ "root": {
+ "id": "",
+ "id_val": "",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "attributes": {
+ "label": {
+ "value": ""
+ },
+ "style": {},
+ "near_key": null,
+ "shape": {
+ "value": ""
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ },
+ "edges": null,
+ "objects": [
+ {
+ "id": "square",
+ "id_val": "square",
+ "label_dimensions": {
+ "width": 0,
+ "height": 0
+ },
+ "references": [
+ {
+ "key": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:0:0-0:6:6",
+ "path": [
+ {
+ "unquoted_string": {
+ "range": "d2/testdata/d2oracle/TestSet/set_position.d2,0:0:0-0:6:6",
+ "value": [
+ {
+ "string": "square",
+ "raw_string": "square"
+ }
+ ]
+ }
+ }
+ ]
+ },
+ "key_path_index": 0,
+ "map_key_edge_index": -1
+ }
+ ],
+ "attributes": {
+ "label": {
+ "value": "square"
+ },
+ "style": {},
+ "top": {
+ "value": "200"
+ },
+ "near_key": null,
+ "shape": {
+ "value": "rectangle"
+ },
+ "direction": {
+ "value": ""
+ },
+ "constraint": {
+ "value": ""
+ }
+ },
+ "zIndex": 0
+ }
+ ]
+ },
+ "err": ""
+}