Skip to content

Commit

Permalink
Merge pull request #1051 from berniexie/d2oracle-fix-fill-pattern
Browse files Browse the repository at this point in the history
d2Oracle: Fix fill-pattern replacement in d2Oracle
  • Loading branch information
berniexie authored Mar 18, 2023
2 parents 5730e40 + fa8ce11 commit f8ad2a8
Show file tree
Hide file tree
Showing 5 changed files with 356 additions and 0 deletions.
2 changes: 2 additions & 0 deletions ci/release/changelogs/next.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
#### Improvements 🧹

#### Bugfixes ⛑️

- Fixes fill-pattern replacement in the API. [#1051](https://github.com/terrastruct/d2/pull/1051)
5 changes: 5 additions & 0 deletions d2oracle/edit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
21 changes: 21 additions & 0 deletions d2oracle/edit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
`,
},
{
Expand Down
164 changes: 164 additions & 0 deletions testdata/d2oracle/TestSet/replace_fill_pattern.exp.json

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

164 changes: 164 additions & 0 deletions testdata/d2oracle/TestSet/set_fill_pattern.exp.json

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

0 comments on commit f8ad2a8

Please sign in to comment.