d2ir: Review fixes #714

This commit is contained in:
Anmol Sethi 2023-01-27 12:37:08 -08:00
parent dffcb274cd
commit dce4385644
No known key found for this signature in database
GPG key ID: 25BC68888A99A8BA
8 changed files with 2704 additions and 44 deletions

View file

@ -61,7 +61,6 @@ func (c *compiler) compileSteps(m *Map) {
if sf.Map() == nil { if sf.Map() == nil {
continue continue
} }
var base *Map var base *Map
if i == 0 { if i == 0 {
base = m.CopyBase(sf) base = m.CopyBase(sf)
@ -243,7 +242,7 @@ func (c *compiler) compileArray(dst *Array, a *d2ast.Array) {
Value: v, Value: v,
} }
case *d2ast.Substitution: case *d2ast.Substitution:
panic("TODO") // panic("TODO")
} }
dst.Values = append(dst.Values, irv) dst.Values = append(dst.Values, irv)

View file

@ -268,6 +268,8 @@ type Field struct {
Name string `json:"name"` Name string `json:"name"`
// Primary_ to avoid clashing with Primary(). We need to keep it exported for
// encoding/json to marshal it so cannot prefix _ instead.
Primary_ *Scalar `json:"primary,omitempty"` Primary_ *Scalar `json:"primary,omitempty"`
Composite Composite `json:"composite,omitempty"` Composite Composite `json:"composite,omitempty"`

View file

@ -1877,6 +1877,62 @@ a.sp1 -> a.sp2: redirect
a.sp2 -> b: bar a.sp2 -> b: bar
`, `,
}, },
{
name: "complex-layers",
script: `
desc: Multi-layer diagram of a home.
window: {
style.double-border: true
}
roof
garage
layers: {
window: {
blinds
glass
}
roof: {
shingles
starlink
utility hookup
}
garage: {
tools
vehicles
}
repair: {
desc: How to repair a home.
steps: {
1: {
find contractors: {
craigslist
facebook
}
}
2: {
find contractors -> solicit quotes
}
3: {
obtain quotes -> negotiate
}
4: {
negotiate -> book the best bid
}
}
}
}
scenarios: {
storm: {
water
rain
thunder
}
}`,
},
} }
runa(t, tcs) runa(t, tcs)

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 325 KiB

File diff suppressed because it is too large Load diff

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 325 KiB

File diff suppressed because one or more lines are too long

Before

Width:  |  Height:  |  Size: 652 KiB