Skip to content

Commit

Permalink
Merge pull request #1848 from alixander/d2oracle-arrowhead-fill-2
Browse files Browse the repository at this point in the history
followup fix to #1847
  • Loading branch information
alixander authored Feb 27, 2024
2 parents edc3088 + 9444a63 commit 68a9af9
Show file tree
Hide file tree
Showing 4 changed files with 720 additions and 0 deletions.
12 changes: 12 additions & 0 deletions d2oracle/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,8 +647,14 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
case "source-arrowhead", "target-arrowhead":
var arrowhead *d2graph.Attributes
if reservedKey == "source-arrowhead" {
if edge.SrcArrowhead != nil {
attrs = *edge.SrcArrowhead
}
arrowhead = edge.SrcArrowhead
} else {
if edge.DstArrowhead != nil {
attrs = *edge.DstArrowhead
}
arrowhead = edge.DstArrowhead
}
if arrowhead != nil {
Expand All @@ -669,6 +675,12 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
arrowhead.Label.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
case "style":
reservedTargetKey = mk.Key.Path[len(mk.Key.Path)-1].Unbox().ScalarString()
if inlined(attrs.Style.Filled) {
attrs.Style.Filled.MapKey.SetScalar(mk.Value.ScalarBox())
return nil
}
}
}
case "style":
Expand Down
36 changes: 36 additions & 0 deletions d2oracle/edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1562,6 +1562,42 @@ a.b -> a.c: {style.animated: true}
target-arrowhead.shape: diamond
target-arrowhead.style.filled: true
}
`,
},
{
name: "edge-arrowhead-filled/4",
text: `x -> y: {
target-arrowhead.shape: diamond
target-arrowhead.style.filled: true
}
`,
key: `(x -> y)[0].target-arrowhead.style.filled`,
value: go2.Pointer(`false`),

exp: `x -> y: {
target-arrowhead.shape: diamond
target-arrowhead.style.filled: false
}
`,
},
{
name: "edge-arrowhead-filled/5",
text: `x -> y: {
target-arrowhead.shape: diamond
target-arrowhead.style: {
filled: false
}
}
`,
key: `(x -> y)[0].target-arrowhead.style.filled`,
value: go2.Pointer(`true`),

exp: `x -> y: {
target-arrowhead.shape: diamond
target-arrowhead.style: {
filled: true
}
}
`,
},
{
Expand Down
327 changes: 327 additions & 0 deletions testdata/d2oracle/TestSet/edge-arrowhead-filled/4.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 68a9af9

Please sign in to comment.