replace link and tooltip

This commit is contained in:
Alexander Wang 2023-02-20 14:15:47 -08:00
parent 95eccae9c1
commit aff6723d38
No known key found for this signature in database
GPG key ID: D89FA31966BDBECE
14 changed files with 2280 additions and 8 deletions

View file

@ -266,7 +266,9 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) {
nearKey.Range = scalar.GetRange()
attrs.NearKey = nearKey
case "tooltip":
attrs.Tooltip = scalar.ScalarString()
attrs.Tooltip = &d2graph.Scalar{}
attrs.Tooltip.Value = scalar.ScalarString()
attrs.Tooltip.MapKey = f.LastPrimaryKey()
case "width":
_, err := strconv.Atoi(scalar.ScalarString())
if err != nil {
@ -304,7 +306,9 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) {
attrs.Left.Value = scalar.ScalarString()
attrs.Left.MapKey = f.LastPrimaryKey()
case "link":
attrs.Link = scalar.ScalarString()
attrs.Link = &d2graph.Scalar{}
attrs.Link.Value = scalar.ScalarString()
attrs.Link.MapKey = f.LastPrimaryKey()
case "direction":
dirs := []string{"up", "down", "right", "left"}
if !go2.Contains(dirs, scalar.ScalarString()) {

View file

@ -95,8 +95,8 @@ type Attributes struct {
Label Scalar `json:"label"`
Style Style `json:"style"`
Icon *url.URL `json:"icon,omitempty"`
Tooltip string `json:"tooltip,omitempty"`
Link string `json:"link,omitempty"`
Tooltip *Scalar `json:"tooltip,omitempty"`
Link *Scalar `json:"link,omitempty"`
Width *Scalar `json:"width,omitempty"`
Height *Scalar `json:"height,omitempty"`
@ -1313,10 +1313,10 @@ func (g *Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler
switch shapeType {
case shape.TABLE_TYPE, shape.CLASS_TYPE, shape.CODE_TYPE, shape.IMAGE_TYPE:
default:
if obj.Attributes.Link != "" {
if obj.Attributes.Link != nil {
paddingX += 32
}
if obj.Attributes.Tooltip != "" {
if obj.Attributes.Tooltip != nil {
paddingX += 32
}
}

View file

@ -37,6 +37,7 @@ func Create(g *d2graph.Graph, key string) (_ *d2graph.Graph, newKey string, err
if err != nil {
return nil, "", err
}
g, err = recompile(g)
if err != nil {
return nil, "", err
@ -195,6 +196,20 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error {
reserved = true
toSkip = 1
if len(mk.EdgeKey.Path) > 1 {
switch mk.EdgeKey.Path[len(mk.EdgeKey.Path)-2].Unbox().ScalarString() {
case "source-arrowhead":
if edge.SrcArrowhead != nil {
toSkip++
attrs = edge.SrcArrowhead
}
case "target-arrowhead":
if edge.DstArrowhead != nil {
toSkip++
attrs = edge.DstArrowhead
}
}
}
mk = &d2ast.Key{
Key: cloneKey(mk.EdgeKey),
Value: mk.Value,
@ -234,6 +249,16 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error {
attrs.Shape.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "link":
if attrs.Link.MapKey != nil {
attrs.Link.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "tooltip":
if attrs.Tooltip.MapKey != nil {
attrs.Tooltip.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "width":
if attrs.Width != nil && attrs.Width.MapKey != nil {
attrs.Width.MapKey.SetScalar(mk.Value.ScalarBox())
@ -714,7 +739,9 @@ func deleteMapField(m *d2ast.Map, field string) {
if n.MapKey != nil && n.MapKey.Key != nil {
if n.MapKey.Key.Path[0].Unbox().ScalarString() == field {
deleteFromMap(m, n.MapKey)
} else if n.MapKey.Key.Path[0].Unbox().ScalarString() == "style" {
} else if n.MapKey.Key.Path[0].Unbox().ScalarString() == "style" ||
n.MapKey.Key.Path[0].Unbox().ScalarString() == "source-arrowhead" ||
n.MapKey.Key.Path[0].Unbox().ScalarString() == "target-arrowhead" {
if n.MapKey.Value.Map != nil {
deleteMapField(n.MapKey.Value.Map, field)
if len(n.MapKey.Value.Map.Nodes) == 0 {

View file

@ -741,6 +741,32 @@ square.style.opacity: 0.2
exp: `square: {
width: 200
}
`,
},
{
name: "replace_tooltip",
text: `square: {
tooltip: x
}
`,
key: `square.tooltip`,
value: go2.Pointer(`y`),
exp: `square: {
tooltip: y
}
`,
},
{
name: "replace_link",
text: `square: {
link: https://google.com
}
`,
key: `square.link`,
value: go2.Pointer(`https://apple.com`),
exp: `square: {
link: https://apple.com
}
`,
},
{
@ -1072,6 +1098,38 @@ a.b -> a.c: {style.animated: true}
value: go2.Pointer(`true`),
exp: `x -> y: {style.animated: true}
`,
},
{
name: "edge_set_arrowhead",
text: `x -> y
`,
key: `(x -> y)[0].target-arrowhead.shape`,
value: go2.Pointer(`diamond`),
exp: `x -> y: {target-arrowhead.shape: diamond}
`,
},
{
name: "edge_replace_arrowhead",
text: `x -> y: {target-arrowhead.shape: circle}
`,
key: `(x -> y)[0].target-arrowhead.shape`,
value: go2.Pointer(`diamond`),
exp: `x -> y: {target-arrowhead.shape: diamond}
`,
},
{
name: "edge_replace_arrowhead_indexed",
text: `x -> y
(x -> y)[0].target-arrowhead.shape: circle
`,
key: `(x -> y)[0].target-arrowhead.shape`,
value: go2.Pointer(`diamond`),
exp: `x -> y
(x -> y)[0].target-arrowhead.shape: diamond
`,
},
{
@ -3459,6 +3517,42 @@ x
key: `x`,
exp: `y
`,
},
{
name: "arrowhead",
text: `x -> y: {
target-arrowhead.shape: diamond
}
`,
key: `(x -> y)[0].target-arrowhead`,
exp: `x -> y
`,
},
{
name: "arrowhead_shape",
text: `x -> y: {
target-arrowhead.shape: diamond
}
`,
key: `(x -> y)[0].target-arrowhead.shape`,
exp: `x -> y
`,
},
{
name: "edge-only-style",
text: `x -> y: {
style.stroke: red
}
`,
key: `(x -> y)[0].style.stroke`,
exp: `x -> y
`,
},
{

214
testdata/d2oracle/TestDelete/arrowhead.exp.json generated vendored Normal file
View file

@ -0,0 +1,214 @@
{
"graph": {
"name": "",
"ast": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-1:0:7",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:6:6",
"edges": [
{
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:6:6",
"src": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"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": [
{
"index": 0,
"minWidth": 0,
"minHeight": 0,
"label_dimensions": {
"width": 0,
"height": 0
},
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"references": [
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
],
"objects": [
{
"id": "x",
"id_val": "x",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

214
testdata/d2oracle/TestDelete/arrowhead_shape.exp.json generated vendored Normal file
View file

@ -0,0 +1,214 @@
{
"graph": {
"name": "",
"ast": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-1:0:7",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:6:6",
"edges": [
{
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:6:6",
"src": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"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": [
{
"index": 0,
"minWidth": 0,
"minHeight": 0,
"label_dimensions": {
"width": 0,
"height": 0
},
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"references": [
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
],
"objects": [
{
"id": "x",
"id_val": "x",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/arrowhead_shape.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

View file

@ -209,7 +209,9 @@
"value": "x"
},
"style": {},
"link": "https://google.com",
"link": {
"value": "https://google.com"
},
"near_key": null,
"shape": {
"value": "rectangle"

214
testdata/d2oracle/TestDelete/edge-only-style.exp.json generated vendored Normal file
View file

@ -0,0 +1,214 @@
{
"graph": {
"name": "",
"ast": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-1:0:7",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:6:6",
"edges": [
{
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:6:6",
"src": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"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": [
{
"index": 0,
"minWidth": 0,
"minHeight": 0,
"label_dimensions": {
"width": 0,
"height": 0
},
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"references": [
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
],
"objects": [
{
"id": "x",
"id_val": "x",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestDelete/edge-only-style.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

View file

@ -0,0 +1,280 @@
{
"graph": {
"name": "",
"ast": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-1:0:42",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:41:41",
"edges": [
{
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:6:6",
"src": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:8:8-0:40:40",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:9:9-0:40:40",
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:9:9-0:31:31",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:9:9-0:25:25",
"value": [
{
"string": "target-arrowhead",
"raw_string": "target-arrowhead"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:26:26-0:31:31",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:33:33-0:40:40",
"value": [
{
"string": "diamond",
"raw_string": "diamond"
}
]
}
}
}
}
]
}
}
}
}
]
},
"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": [
{
"index": 0,
"minWidth": 0,
"minHeight": 0,
"label_dimensions": {
"width": 0,
"height": 0
},
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"dstArrowhead": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": "diamond"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"references": [
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
],
"objects": [
{
"id": "x",
"id_val": "x",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

View file

@ -0,0 +1,361 @@
{
"graph": {
"name": "",
"ast": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-2:0:51",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:6:6",
"edges": [
{
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:6:6",
"src": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {}
}
},
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:0:7-1:43:50",
"edges": [
{
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:7:14",
"src": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:3:10",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:2:9",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:5:12-1:7:14",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:6:13-1:7:14",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"edge_index": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:8:15-1:11:18",
"int": 0,
"glob": false
},
"edge_key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:12:19-1:34:41",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:12:19-1:28:35",
"value": [
{
"string": "target-arrowhead",
"raw_string": "target-arrowhead"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:29:36-1:34:41",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:36:43-1:43:50",
"value": [
{
"string": "diamond",
"raw_string": "diamond"
}
]
}
}
}
}
]
},
"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": [
{
"index": 0,
"minWidth": 0,
"minHeight": 0,
"label_dimensions": {
"width": 0,
"height": 0
},
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"dstArrowhead": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": "diamond"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"references": [
{
"map_key_edge_index": 0
},
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
],
"objects": [
{
"id": "x",
"id_val": "x",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
},
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:3:10",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:1:8-1:2:9",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
},
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:5:12-1:7:14",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_arrowhead_indexed.d2,1:6:13-1:7:14",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

280
testdata/d2oracle/TestSet/edge_replace_style.exp.json generated vendored Normal file
View file

@ -0,0 +1,280 @@
{
"graph": {
"name": "",
"ast": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-1:0:42",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:41:41",
"edges": [
{
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:6:6",
"src": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:8:8-0:40:40",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:9:9-0:40:40",
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:9:9-0:31:31",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:9:9-0:25:25",
"value": [
{
"string": "target-arrowhead",
"raw_string": "target-arrowhead"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:26:26-0:31:31",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:33:33-0:40:40",
"value": [
{
"string": "diamond",
"raw_string": "diamond"
}
]
}
}
}
}
]
}
}
}
}
]
},
"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": [
{
"index": 0,
"minWidth": 0,
"minHeight": 0,
"label_dimensions": {
"width": 0,
"height": 0
},
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"dstArrowhead": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": "diamond"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"references": [
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
],
"objects": [
{
"id": "x",
"id_val": "x",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_replace_style.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

280
testdata/d2oracle/TestSet/edge_set_arrowhead.exp.json generated vendored Normal file
View file

@ -0,0 +1,280 @@
{
"graph": {
"name": "",
"ast": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-1:0:42",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:41:41",
"edges": [
{
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:6:6",
"src": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"src_arrow": "",
"dst": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"dst_arrow": ">"
}
],
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:8:8-0:40:40",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:9:9-0:40:40",
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:9:9-0:31:31",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:9:9-0:25:25",
"value": [
{
"string": "target-arrowhead",
"raw_string": "target-arrowhead"
}
]
}
},
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:26:26-0:31:31",
"value": [
{
"string": "shape",
"raw_string": "shape"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:33:33-0:40:40",
"value": [
{
"string": "diamond",
"raw_string": "diamond"
}
]
}
}
}
}
]
}
}
}
}
]
},
"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": [
{
"index": 0,
"minWidth": 0,
"minHeight": 0,
"label_dimensions": {
"width": 0,
"height": 0
},
"isCurve": false,
"src_arrow": false,
"dst_arrow": true,
"dstArrowhead": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": "diamond"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"references": [
{
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": ""
},
"style": {},
"near_key": null,
"shape": {
"value": ""
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
],
"objects": [
{
"id": "x",
"id_val": "x",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:2:2",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:0:0-0:1:1",
"value": [
{
"string": "x",
"raw_string": "x"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "x"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
},
{
"id": "y",
"id_val": "y",
"label_dimensions": {
"width": 0,
"height": 0
},
"references": [
{
"key": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:4:4-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/edge_set_arrowhead.d2,0:5:5-0:6:6",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
]
},
"key_path_index": 0,
"map_key_edge_index": 0
}
],
"attributes": {
"label": {
"value": "y"
},
"style": {},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

151
testdata/d2oracle/TestSet/replace_link.exp.json generated vendored Normal file
View file

@ -0,0 +1,151 @@
{
"graph": {
"name": "",
"ast": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-3:0:38",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-2:1:37",
"key": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:0:0-0:6:6",
"value": [
{
"string": "square",
"raw_string": "square"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.d2,0:8:8-2:0:36",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.d2,1:2:12-1:25:35",
"key": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.d2,1:2:12-1:6:16",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.d2,1:2:12-1:6:16",
"value": [
{
"string": "link",
"raw_string": "link"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.d2,1:8:18-1:25:35",
"value": [
{
"string": "https://apple.com",
"raw_string": "https://apple.com"
}
]
}
}
}
}
]
}
}
}
}
]
},
"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_link.d2,0:0:0-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/replace_link.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": {},
"link": {
"value": "https://apple.com"
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}

151
testdata/d2oracle/TestSet/replace_tooltip.exp.json generated vendored Normal file
View file

@ -0,0 +1,151 @@
{
"graph": {
"name": "",
"ast": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-3:0:25",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-2:1:24",
"key": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:0:0-0:6:6",
"value": [
{
"string": "square",
"raw_string": "square"
}
]
}
}
]
},
"primary": {},
"value": {
"map": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,0:8:8-2:0:23",
"nodes": [
{
"map_key": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,1:2:12-1:12:22",
"key": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,1:2:12-1:9:19",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,1:2:12-1:9:19",
"value": [
{
"string": "tooltip",
"raw_string": "tooltip"
}
]
}
}
]
},
"primary": {},
"value": {
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.d2,1:11:21-1:12:22",
"value": [
{
"string": "y",
"raw_string": "y"
}
]
}
}
}
}
]
}
}
}
}
]
},
"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_tooltip.d2,0:0:0-0:6:6",
"path": [
{
"unquoted_string": {
"range": "d2/testdata/d2oracle/TestSet/replace_tooltip.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": {},
"tooltip": {
"value": "y"
},
"near_key": null,
"shape": {
"value": "rectangle"
},
"direction": {
"value": ""
},
"constraint": {
"value": ""
}
},
"zIndex": 0
}
]
},
"err": "<nil>"
}