remove empty board keywords
This commit is contained in:
parent
efd401a2e1
commit
17846b4169
3 changed files with 22 additions and 3 deletions
|
|
@ -7,6 +7,7 @@
|
||||||
- Lib: removes a dependency on external slog that was causing troubles with installation [#2137](https://github.com/terrastruct/d2/pull/2137)
|
- Lib: removes a dependency on external slog that was causing troubles with installation [#2137](https://github.com/terrastruct/d2/pull/2137)
|
||||||
- CLI: attempts writing to path atomically, falling back to non-atomic if failed [#2141](https://github.com/terrastruct/d2/pull/2141)
|
- CLI: attempts writing to path atomically, falling back to non-atomic if failed [#2141](https://github.com/terrastruct/d2/pull/2141)
|
||||||
- Export: pptx has "created at" metadata removed, so successive runs yield the same result [#2169](https://github.com/terrastruct/d2/pull/2160)
|
- Export: pptx has "created at" metadata removed, so successive runs yield the same result [#2169](https://github.com/terrastruct/d2/pull/2160)
|
||||||
|
- Formatter: empty board keywords (e.g. `layers`) are removed [#2178](https://github.com/terrastruct/d2/pull/2178)
|
||||||
|
|
||||||
#### Bugfixes ⛑️
|
#### Bugfixes ⛑️
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -293,12 +293,19 @@ func (p *printer) _map(m *d2ast.Map) {
|
||||||
if nb.IsBoardNode() {
|
if nb.IsBoardNode() {
|
||||||
switch nb.MapKey.Key.Path[0].Unbox().ScalarString() {
|
switch nb.MapKey.Key.Path[0].Unbox().ScalarString() {
|
||||||
case "layers":
|
case "layers":
|
||||||
|
// remove useless
|
||||||
|
if nb.MapKey.Value.Map != nil && len(nb.MapKey.Value.Map.Nodes) > 0 {
|
||||||
layerNodes = append(layerNodes, nb)
|
layerNodes = append(layerNodes, nb)
|
||||||
|
}
|
||||||
case "scenarios":
|
case "scenarios":
|
||||||
|
if nb.MapKey.Value.Map != nil && len(nb.MapKey.Value.Map.Nodes) > 0 {
|
||||||
scenarioNodes = append(scenarioNodes, nb)
|
scenarioNodes = append(scenarioNodes, nb)
|
||||||
|
}
|
||||||
case "steps":
|
case "steps":
|
||||||
|
if nb.MapKey.Value.Map != nil && len(nb.MapKey.Value.Map.Nodes) > 0 {
|
||||||
stepNodes = append(stepNodes, nb)
|
stepNodes = append(stepNodes, nb)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
prev = n
|
prev = n
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -881,6 +881,17 @@ coop: {
|
||||||
fill: blue
|
fill: blue
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "remove-empty-boards",
|
||||||
|
in: `k
|
||||||
|
|
||||||
|
layers
|
||||||
|
scenarios: {}
|
||||||
|
steps: asdf
|
||||||
|
`,
|
||||||
|
exp: `k
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue