fix
This commit is contained in:
parent
5730e4054e
commit
1658c05f18
5 changed files with 356 additions and 0 deletions
|
|
@ -3,3 +3,5 @@
|
|||
#### Improvements 🧹
|
||||
|
||||
#### Bugfixes ⛑️
|
||||
|
||||
- Fixes Fill Pattern replacement in the API. [#853](https://github.com/terrastruct/d2/pull/853)
|
||||
|
|
|
|||
|
|
@ -433,6 +433,11 @@ func _set(g *d2graph.Graph, key string, tag, value *string) error {
|
|||
attrs.Style.Underline.MapKey.SetScalar(mk.Value.ScalarBox())
|
||||
return nil
|
||||
}
|
||||
case "fill-pattern":
|
||||
if attrs.Style.FillPattern != nil {
|
||||
attrs.Style.FillPattern.MapKey.SetScalar(mk.Value.ScalarBox())
|
||||
return nil
|
||||
}
|
||||
}
|
||||
case "label":
|
||||
if attrs.Label.MapKey != nil {
|
||||
|
|
|
|||
|
|
@ -838,6 +838,27 @@ square.style.opacity: 0.2
|
|||
style.stroke-width: 1
|
||||
style.stroke-dash: 3
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "set_fill_pattern",
|
||||
text: `square`,
|
||||
key: `square.style.fill-pattern`,
|
||||
value: go2.Pointer(`grain`),
|
||||
exp: `square: {style.fill-pattern: grain}
|
||||
`,
|
||||
},
|
||||
{
|
||||
name: "replace_fill_pattern",
|
||||
text: `square: {
|
||||
style.fill-pattern: lines
|
||||
}
|
||||
`,
|
||||
key: `square.style.fill-pattern`,
|
||||
value: go2.Pointer(`grain`),
|
||||
exp: `square: {
|
||||
style.fill-pattern: grain
|
||||
}
|
||||
`,
|
||||
},
|
||||
{
|
||||
|
|
|
|||
164
testdata/d2oracle/TestSet/replace_fill_pattern.exp.json
generated
vendored
Normal file
164
testdata/d2oracle/TestSet/replace_fill_pattern.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"isFolderOnly": false,
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,0:0:0-3:0:40",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,0:0:0-2:1:39",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,0:0:0-0:6:6",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,0:0:0-0:6:6",
|
||||
"value": [
|
||||
{
|
||||
"string": "square",
|
||||
"raw_string": "square"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,0:8:8-2:0:38",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,1:2:12-1:27:37",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,1:2:12-1:20:30",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,1:2:12-1:7:17",
|
||||
"value": [
|
||||
{
|
||||
"string": "style",
|
||||
"raw_string": "style"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,1:8:18-1:20:30",
|
||||
"value": [
|
||||
{
|
||||
"string": "fill-pattern",
|
||||
"raw_string": "fill-pattern"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.d2,1:22:32-1:27:37",
|
||||
"value": [
|
||||
{
|
||||
"string": "grain",
|
||||
"raw_string": "grain"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"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_fill_pattern.d2,0:0:0-0:6:6",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/replace_fill_pattern.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": {
|
||||
"fillPattern": {
|
||||
"value": "grain"
|
||||
}
|
||||
},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": {
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": "<nil>"
|
||||
}
|
||||
164
testdata/d2oracle/TestSet/set_fill_pattern.exp.json
generated
vendored
Normal file
164
testdata/d2oracle/TestSet/set_fill_pattern.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"isFolderOnly": false,
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:0:0-1:0:36",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:0:0-0:35:35",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:0:0-0:6:6",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:0:0-0:6:6",
|
||||
"value": [
|
||||
{
|
||||
"string": "square",
|
||||
"raw_string": "square"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:8:8-0:34:34",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:9:9-0:34:34",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:9:9-0:27:27",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:9:9-0:14:14",
|
||||
"value": [
|
||||
{
|
||||
"string": "style",
|
||||
"raw_string": "style"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:15:15-0:27:27",
|
||||
"value": [
|
||||
{
|
||||
"string": "fill-pattern",
|
||||
"raw_string": "fill-pattern"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.d2,0:29:29-0:34:34",
|
||||
"value": [
|
||||
{
|
||||
"string": "grain",
|
||||
"raw_string": "grain"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"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_fill_pattern.d2,0:0:0-0:6:6",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2oracle/TestSet/set_fill_pattern.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": {
|
||||
"fillPattern": {
|
||||
"value": "grain"
|
||||
}
|
||||
},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": {
|
||||
"value": ""
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": "<nil>"
|
||||
}
|
||||
Loading…
Reference in a new issue