Skip to content

Commit

Permalink
Merge pull request #1847 from alixander/d2oracle-arrowhead-fill
Browse files Browse the repository at this point in the history
d2oracle: fix set arrowhead fill
  • Loading branch information
alixander authored Feb 27, 2024
2 parents 5117d2b + c8fcd11 commit edc3088
Show file tree
Hide file tree
Showing 5 changed files with 1,000 additions and 2 deletions.
4 changes: 2 additions & 2 deletions d2oracle/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -653,8 +653,8 @@ func _set(g *d2graph.Graph, baseAST *d2ast.Map, key string, tag, value *string)
}
if arrowhead != nil {
if reservedTargetKey == "" {
if len(mk.Key.Path[reservedIndex:]) != 2 {
return errors.New("malformed style setting, expected 2 part path")
if len(mk.Key.Path[reservedIndex:]) < 2 {
return errors.New("malformed style setting, expected >= 2 part path")
}
reservedTargetKey = mk.Key.Path[reservedIndex+1].Unbox().ScalarString()
}
Expand Down
44 changes: 44 additions & 0 deletions d2oracle/edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1518,6 +1518,50 @@ a.b -> a.c: {style.animated: true}
value: go2.Pointer(`diamond`),

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

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

exp: `x -> y: {
target-arrowhead: * {
shape: diamond
style.filled: true
}
}
`,
},
{
name: "edge-arrowhead-filled/3",
text: `x -> y: {
target-arrowhead.shape: diamond
}
`,
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
283 changes: 283 additions & 0 deletions testdata/d2oracle/TestSet/edge-arrowhead-filled/1.exp.json

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

Loading

0 comments on commit edc3088

Please sign in to comment.