Resolved merge conflicts
This commit is contained in:
commit
10ff432f8d
17 changed files with 790 additions and 19 deletions
|
|
@ -4,7 +4,7 @@ cd -- "$(dirname "$0")/../.."
|
|||
. ./ci/sub/lib.sh
|
||||
|
||||
tag="$(sh_c docker build \
|
||||
--build-arg GOVERSION="1.22.2.linux-$ARCH" \
|
||||
--build-arg GOVERSION="1.23.6.linux-$ARCH" \
|
||||
-qf ./ci/release/linux/Dockerfile ./ci/release/linux)"
|
||||
docker_run \
|
||||
-e DRY_RUN \
|
||||
|
|
|
|||
|
|
@ -17,10 +17,12 @@
|
|||
- `salt`
|
||||
- `noXMLTag`
|
||||
- Support relative imports. Improve elk error handling: [#2382](https://github.com/terrastruct/d2/pull/2382)
|
||||
- Support fonts (`fontRegular`, `fontItalic`, `fontBold`, `fontSemiBold`): [#2384](https://github.com/terrastruct/d2/pull/2384)
|
||||
|
||||
#### Bugfixes ⛑️
|
||||
|
||||
- Compiler:
|
||||
- fixes panic when `sql_shape` shape value had mixed casing [#2349](https://github.com/terrastruct/d2/pull/2349)
|
||||
- fixes support for `center` in `d2-config` [#2360](https://github.com/terrastruct/d2/pull/2360)
|
||||
- fixes panic when comment lines appear in arrays [#2378](https://github.com/terrastruct/d2/pull/2378)
|
||||
- CLI: fetch and render remote images of mimetype octet-stream correctly [#2370](https://github.com/terrastruct/d2/pull/2370)
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ var ReservedKeywords map[string]struct{}
|
|||
// Non Style/Holder keywords.
|
||||
var SimpleReservedKeywords = map[string]struct{}{
|
||||
"label": {},
|
||||
"legend-label": {},
|
||||
"shape": {},
|
||||
"icon": {},
|
||||
"constraint": {},
|
||||
|
|
|
|||
|
|
@ -547,6 +547,10 @@ func (c *compiler) compileReserved(attrs *d2graph.Attributes, f *d2ir.Field) {
|
|||
attrs.Tooltip = &d2graph.Scalar{}
|
||||
attrs.Tooltip.Value = scalar.ScalarString()
|
||||
attrs.Tooltip.MapKey = f.LastPrimaryKey()
|
||||
case "legend-label":
|
||||
attrs.LegendLabel = &d2graph.Scalar{}
|
||||
attrs.LegendLabel.Value = scalar.ScalarString()
|
||||
attrs.LegendLabel.MapKey = f.LastPrimaryKey()
|
||||
case "width":
|
||||
_, err := strconv.Atoi(scalar.ScalarString())
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -4409,6 +4409,24 @@ a: {
|
|||
assert.Equal(t, 2, len(g.Objects[0].SQLTable.Columns[0].Constraint))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "comment-array",
|
||||
run: func(t *testing.T) {
|
||||
assertCompile(t, `
|
||||
vars: {
|
||||
list: [
|
||||
"a";
|
||||
"b";
|
||||
"c";
|
||||
"d"
|
||||
# e
|
||||
]
|
||||
}
|
||||
|
||||
a
|
||||
`, "")
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "spread-array",
|
||||
run: func(t *testing.T) {
|
||||
|
|
@ -5415,6 +5433,23 @@ b -> c
|
|||
assert.Equal(t, "red", g.Edges[0].Style.Stroke.Value)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "legend-label",
|
||||
run: func(t *testing.T) {
|
||||
g, _ := assertCompile(t, `
|
||||
a.legend-label: This is A
|
||||
b: {legend-label: This is B}
|
||||
a -> b: {
|
||||
legend-label: "This is a->b"
|
||||
}
|
||||
`, ``)
|
||||
assert.Equal(t, "a", g.Objects[0].ID)
|
||||
assert.Equal(t, "This is A", g.Objects[0].LegendLabel.Value)
|
||||
assert.Equal(t, "b", g.Objects[1].ID)
|
||||
assert.Equal(t, "This is B", g.Objects[1].LegendLabel.Value)
|
||||
assert.Equal(t, "This is a->b", g.Edges[0].LegendLabel.Value)
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tca {
|
||||
|
|
|
|||
|
|
@ -196,6 +196,9 @@ func toShape(obj *d2graph.Object, g *d2graph.Graph) d2target.Shape {
|
|||
if obj.Tooltip != nil {
|
||||
shape.Tooltip = obj.Tooltip.Value
|
||||
}
|
||||
if obj.LegendLabel != nil {
|
||||
shape.LegendLabel = obj.LegendLabel.Value
|
||||
}
|
||||
if obj.Style.Animated != nil {
|
||||
shape.Animated, _ = strconv.ParseBool(obj.Style.Animated.Value)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -222,7 +222,8 @@ type Attributes struct {
|
|||
|
||||
// These names are attached to the rendered elements in SVG
|
||||
// so that users can target them however they like outside of D2
|
||||
Classes []string `json:"classes,omitempty"`
|
||||
Classes []string `json:"classes,omitempty"`
|
||||
LegendLabel *Scalar `json:"legendLabel,omitempty"`
|
||||
}
|
||||
|
||||
// ApplyTextTransform will alter the `Label.Value` of the current object based
|
||||
|
|
|
|||
|
|
@ -1282,6 +1282,8 @@ func (c *compiler) compileArray(dst *Array, a *d2ast.Array, scopeAST *d2ast.Map)
|
|||
Value: []d2ast.InterpolationBox{{Substitution: an.Substitution}},
|
||||
},
|
||||
}
|
||||
case *d2ast.Comment:
|
||||
continue
|
||||
}
|
||||
|
||||
dst.Values = append(dst.Values, irv)
|
||||
|
|
|
|||
|
|
@ -29,7 +29,6 @@ import (
|
|||
"oss.terrastruct.com/d2/lib/textmeasure"
|
||||
"oss.terrastruct.com/d2/lib/urlenc"
|
||||
"oss.terrastruct.com/d2/lib/version"
|
||||
"oss.terrastruct.com/util-go/go2"
|
||||
)
|
||||
|
||||
const DEFAULT_INPUT_PATH = "index"
|
||||
|
|
@ -210,6 +209,30 @@ func Compile(args []js.Value) (interface{}, error) {
|
|||
return nil, &WASMError{Message: fmt.Sprintf("invalid fs input: %s", err.Error()), Code: 400}
|
||||
}
|
||||
|
||||
var fontRegular []byte
|
||||
var fontItalic []byte
|
||||
var fontBold []byte
|
||||
var fontSemibold []byte
|
||||
if input.Opts != nil && (input.Opts.FontRegular != nil) {
|
||||
fontRegular = *input.Opts.FontRegular
|
||||
}
|
||||
if input.Opts != nil && (input.Opts.FontItalic != nil) {
|
||||
fontItalic = *input.Opts.FontItalic
|
||||
}
|
||||
if input.Opts != nil && (input.Opts.FontBold != nil) {
|
||||
fontBold = *input.Opts.FontBold
|
||||
}
|
||||
if input.Opts != nil && (input.Opts.FontSemibold != nil) {
|
||||
fontSemibold = *input.Opts.FontSemibold
|
||||
}
|
||||
if fontRegular != nil || fontItalic != nil || fontBold != nil || fontSemibold != nil {
|
||||
fontFamily, err := d2fonts.AddFontFamily("custom", fontRegular, fontItalic, fontBold, fontSemibold)
|
||||
if err != nil {
|
||||
return nil, &WASMError{Message: fmt.Sprintf("custom fonts could not be initialized: %s", err.Error()), Code: 400}
|
||||
}
|
||||
compileOpts.FontFamily = fontFamily
|
||||
}
|
||||
|
||||
compileOpts.Ruler, err = textmeasure.NewRuler()
|
||||
if err != nil {
|
||||
return nil, &WASMError{Message: fmt.Sprintf("text ruler cannot be initialized: %s", err.Error()), Code: 500}
|
||||
|
|
@ -222,9 +245,6 @@ func Compile(args []js.Value) (interface{}, error) {
|
|||
renderOpts := &d2svg.RenderOpts{}
|
||||
if input.Opts != nil && input.Opts.Sketch != nil {
|
||||
renderOpts.Sketch = input.Opts.Sketch
|
||||
if *input.Opts.Sketch {
|
||||
compileOpts.FontFamily = go2.Pointer(d2fonts.HandDrawn)
|
||||
}
|
||||
}
|
||||
if input.Opts != nil && input.Opts.Pad != nil {
|
||||
renderOpts.Pad = input.Opts.Pad
|
||||
|
|
|
|||
|
|
@ -53,7 +53,11 @@ type RenderOptions struct {
|
|||
|
||||
type CompileOptions struct {
|
||||
RenderOptions
|
||||
Layout *string `json:"layout"`
|
||||
Layout *string `json:"layout"`
|
||||
FontRegular *[]byte `json:"FontRegular"`
|
||||
FontItalic *[]byte `json:"FontItalic"`
|
||||
FontBold *[]byte `json:"FontBold"`
|
||||
FontSemibold *[]byte `json:"FontSemibold"`
|
||||
}
|
||||
|
||||
type CompileResponse struct {
|
||||
|
|
|
|||
|
|
@ -103,6 +103,10 @@ Renders a compiled diagram to SVG.
|
|||
All [RenderOptions](#renderoptions) properties in addition to:
|
||||
|
||||
- `layout`: Layout engine to use ('dagre' | 'elk') [default: 'dagre']
|
||||
- `fontRegular` A byte array containing .ttf file to use for the regular font. If none provided, Source Sans Pro Regular is used.
|
||||
- `fontItalic` A byte array containing .ttf file to use for the italic font. If none provided, Source Sans Pro Italic is used.
|
||||
- `fontBold` A byte array containing .ttf file to use for the bold font. If none provided, Source Sans Pro Bold is used.
|
||||
- `fontSemibold` A byte array containing .ttf file to use for the semibold font. If none provided, Source Sans Pro Semibold is used.
|
||||
|
||||
### `RenderOptions`
|
||||
|
||||
|
|
|
|||
|
|
@ -319,6 +319,53 @@
|
|||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="option">
|
||||
<div class="option-select">
|
||||
<label class="input-label">
|
||||
<span>Regular Font</span>
|
||||
<input
|
||||
type="file"
|
||||
accept=".ttf"
|
||||
id="font-regular-input"
|
||||
class="file-input"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="option">
|
||||
<div class="option-select">
|
||||
<label class="input-label">
|
||||
<span>Italic Font</span>
|
||||
<input
|
||||
type="file"
|
||||
accept=".ttf"
|
||||
id="font-italic-input"
|
||||
class="file-input"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="option">
|
||||
<div class="option-select">
|
||||
<label class="input-label">
|
||||
<span>Bold Font</span>
|
||||
<input type="file" accept=".ttf" id="font-bold-input" class="file-input" />
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
<div class="option">
|
||||
<div class="option-select">
|
||||
<label class="input-label">
|
||||
<span>Semibold Font</span>
|
||||
<input
|
||||
type="file"
|
||||
accept=".ttf"
|
||||
id="font-semibold-input"
|
||||
class="file-input"
|
||||
/>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<button onclick="compile()">Compile</button>
|
||||
</div>
|
||||
|
|
@ -326,6 +373,12 @@
|
|||
<script type="module">
|
||||
import { D2 } from "../dist/browser/index.js";
|
||||
const d2 = new D2();
|
||||
const loadFont = async (file) => {
|
||||
if (file != undefined) {
|
||||
const font = await file.arrayBuffer();
|
||||
return Array.from(new Uint8Array(font));
|
||||
}
|
||||
};
|
||||
window.compile = async () => {
|
||||
const input = document.getElementById("input").value;
|
||||
const layout = document.getElementById("layout-toggle").checked
|
||||
|
|
@ -362,6 +415,18 @@
|
|||
? Number(document.getElementById("animate-interval-input").value)
|
||||
: null;
|
||||
const salt = String(document.getElementById("salt-input").value);
|
||||
const fontRegular = await loadFont(
|
||||
document.getElementById("font-regular-input").files[0]
|
||||
);
|
||||
const fontItalic = await loadFont(
|
||||
document.getElementById("font-italic-input").files[0]
|
||||
);
|
||||
const fontBold = await loadFont(
|
||||
document.getElementById("font-bold-input").files[0]
|
||||
);
|
||||
const fontSemibold = await loadFont(
|
||||
document.getElementById("font-semibold-input").files[0]
|
||||
);
|
||||
try {
|
||||
const result = await d2.compile(input, {
|
||||
layout,
|
||||
|
|
@ -375,6 +440,10 @@
|
|||
target,
|
||||
animateInterval,
|
||||
salt,
|
||||
fontRegular,
|
||||
fontItalic,
|
||||
fontSemibold,
|
||||
fontBold,
|
||||
noXmlTag: true,
|
||||
});
|
||||
const svg = await d2.render(result.diagram, result.renderOptions);
|
||||
|
|
|
|||
|
|
@ -485,6 +485,7 @@ type Shape struct {
|
|||
PrettyLink string `json:"prettyLink,omitempty"`
|
||||
Icon *url.URL `json:"icon"`
|
||||
IconPosition string `json:"iconPosition"`
|
||||
LegendLabel string `json:"legendLabel,omitempty"`
|
||||
|
||||
// Whether the shape should allow shapes behind it to bleed through
|
||||
// Currently just used for sequence diagram groups
|
||||
|
|
@ -613,6 +614,7 @@ type Connection struct {
|
|||
|
||||
Animated bool `json:"animated"`
|
||||
Tooltip string `json:"tooltip"`
|
||||
LegendLabel string `json:"legendLabel,omitempty"`
|
||||
Icon *url.URL `json:"icon"`
|
||||
IconPosition string `json:"iconPosition,omitempty"`
|
||||
|
||||
|
|
|
|||
8
go.mod
generated
8
go.mod
generated
|
|
@ -24,8 +24,8 @@ require (
|
|||
github.com/yuin/goldmark v1.7.4
|
||||
go.uber.org/multierr v1.11.0
|
||||
golang.org/x/image v0.20.0
|
||||
golang.org/x/net v0.29.0
|
||||
golang.org/x/text v0.18.0
|
||||
golang.org/x/net v0.35.0
|
||||
golang.org/x/text v0.22.0
|
||||
golang.org/x/tools v0.25.0
|
||||
golang.org/x/xerrors v0.0.0-20240903120638-7835f813f4da
|
||||
gonum.org/v1/plot v0.14.0
|
||||
|
|
@ -49,8 +49,8 @@ require (
|
|||
github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c // indirect
|
||||
github.com/pmezard/go-difflib v1.0.0 // indirect
|
||||
golang.org/x/exp v0.0.0-20240909161429-701f63a606c0 // indirect
|
||||
golang.org/x/sys v0.25.0 // indirect
|
||||
golang.org/x/term v0.24.0 // indirect
|
||||
golang.org/x/sys v0.30.0 // indirect
|
||||
golang.org/x/term v0.29.0 // indirect
|
||||
gopkg.in/yaml.v2 v2.4.0 // indirect
|
||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
||||
)
|
||||
|
|
|
|||
16
go.sum
generated
16
go.sum
generated
|
|
@ -147,8 +147,8 @@ golang.org/x/net v0.0.0-20221002022538-bcab6841153b/go.mod h1:YDH+HFinaLZZlnHAfS
|
|||
golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs=
|
||||
golang.org/x/net v0.9.0/go.mod h1:d48xBJpPfHeWQsugry2m+kC02ZBRGRgulfHnEXEuWns=
|
||||
golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg=
|
||||
golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo=
|
||||
golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0=
|
||||
golang.org/x/net v0.35.0 h1:T5GQRQb2y08kTAByq9L4/bz8cipCdA8FbRTXewonqY8=
|
||||
golang.org/x/net v0.35.0/go.mod h1:EglIi67kWsHKlRzzVMUD93VMSWGFOMSZgxFjparz1Qk=
|
||||
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
|
||||
|
|
@ -166,24 +166,24 @@ golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
|||
golang.org/x/sys v0.7.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
|
||||
golang.org/x/sys v0.17.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34=
|
||||
golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/sys v0.30.0 h1:QjkSwP/36a20jFYWkSue1YwXzLmsV5Gfq7Eiy72C1uc=
|
||||
golang.org/x/sys v0.30.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
|
||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||
golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8=
|
||||
golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k=
|
||||
golang.org/x/term v0.7.0/go.mod h1:P32HKFT3hSsZrRxla30E9HqToFYAQPCMs/zFMBUFqPY=
|
||||
golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo=
|
||||
golang.org/x/term v0.17.0/go.mod h1:lLRBjIVuehSbZlaOtGMbcMncT+aqLLLmKrsjNrUguwk=
|
||||
golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM=
|
||||
golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8=
|
||||
golang.org/x/term v0.29.0 h1:L6pJp37ocefwRRtYPKSWOWzOtWSxVajvz2ldH/xi3iU=
|
||||
golang.org/x/term v0.29.0/go.mod h1:6bl4lRlvVuDgSf3179VpIxBF0o10JUpXWOnI7nErv7s=
|
||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||
golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ=
|
||||
golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8=
|
||||
golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8=
|
||||
golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
|
||||
golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224=
|
||||
golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY=
|
||||
golang.org/x/text v0.22.0 h1:bofq7m3/HAFvbF51jz3Q9wLg3jkvSPuiZu/pD1XwgtM=
|
||||
golang.org/x/text v0.22.0/go.mod h1:YRoo4H8PVmsu+E3Ou7cqLVH8oXWIHVoX0jqUWALQhfY=
|
||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||
golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
|
||||
golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc=
|
||||
|
|
|
|||
410
testdata/d2compiler/TestCompile2/globs/legend-label.exp.json
generated
vendored
Normal file
410
testdata/d2compiler/TestCompile2/globs/legend-label.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,410 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"isFolderOnly": false,
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,0:0:0-6:0:99",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,1:0:1-1:25:26",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,1:0:1-1:14:15",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,1:0:1-1:1:2",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,1:2:3-1:14:15",
|
||||
"value": [
|
||||
{
|
||||
"string": "legend-label",
|
||||
"raw_string": "legend-label"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,1:16:17-1:25:26",
|
||||
"value": [
|
||||
{
|
||||
"string": "This is A",
|
||||
"raw_string": "This is A"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:0:27-2:28:55",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:0:27-2:1:28",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:0:27-2:1:28",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:3:30-2:28:55",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:4:31-2:27:54",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:4:31-2:16:43",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:4:31-2:16:43",
|
||||
"value": [
|
||||
{
|
||||
"string": "legend-label",
|
||||
"raw_string": "legend-label"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:18:45-2:27:54",
|
||||
"value": [
|
||||
{
|
||||
"string": "This is B",
|
||||
"raw_string": "This is B"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:0:56-5:1:98",
|
||||
"edges": [
|
||||
{
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:0:56-3:6:62",
|
||||
"src": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:0:56-3:1:57",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:0:56-3:1:57",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"src_arrow": "",
|
||||
"dst": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:5:61-3:6:62",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:5:61-3:6:62",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"dst_arrow": ">"
|
||||
}
|
||||
],
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:8:64-5:1:98",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,4:2:68-4:30:96",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,4:2:68-4:14:80",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,4:2:68-4:14:80",
|
||||
"value": [
|
||||
{
|
||||
"string": "legend-label",
|
||||
"raw_string": "legend-label"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"double_quoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,4:16:82-4:30:96",
|
||||
"value": [
|
||||
{
|
||||
"string": "This is a->b",
|
||||
"raw_string": "This is a->b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"root": {
|
||||
"id": "",
|
||||
"id_val": "",
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": ""
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
"edges": [
|
||||
{
|
||||
"index": 0,
|
||||
"isCurve": false,
|
||||
"src_arrow": false,
|
||||
"dst_arrow": true,
|
||||
"references": [
|
||||
{
|
||||
"map_key_edge_index": 0
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": ""
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null,
|
||||
"legendLabel": {
|
||||
"value": "This is a->b"
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
],
|
||||
"objects": [
|
||||
{
|
||||
"id": "a",
|
||||
"id_val": "a",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,1:0:1-1:14:15",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,1:0:1-1:1:2",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,1:2:3-1:14:15",
|
||||
"value": [
|
||||
{
|
||||
"string": "legend-label",
|
||||
"raw_string": "legend-label"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
},
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:0:56-3:1:57",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:0:56-3:1:57",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": 0
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "a"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null,
|
||||
"legendLabel": {
|
||||
"value": "This is A"
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
{
|
||||
"id": "b",
|
||||
"id_val": "b",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:0:27-2:1:28",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,2:0:27-2:1:28",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
},
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:5:61-3:6:62",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/globs/legend-label.d2,3:5:61-3:6:62",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": 0
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "b"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null,
|
||||
"legendLabel": {
|
||||
"value": "This is B"
|
||||
}
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": null
|
||||
}
|
||||
214
testdata/d2compiler/TestCompile2/vars/basic/comment-array.exp.json
generated
vendored
Normal file
214
testdata/d2compiler/TestCompile2/vars/basic/comment-array.exp.json
generated
vendored
Normal file
|
|
@ -0,0 +1,214 @@
|
|||
{
|
||||
"graph": {
|
||||
"name": "",
|
||||
"isFolderOnly": false,
|
||||
"ast": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,0:0:0-12:0:71",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,1:0:1-9:1:67",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,1:0:1-1:4:5",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,1:0:1-1:4:5",
|
||||
"value": [
|
||||
{
|
||||
"string": "vars",
|
||||
"raw_string": "vars"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"map": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,1:6:7-9:1:67",
|
||||
"nodes": [
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,2:2:11-8:3:65",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,2:2:11-2:6:15",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,2:2:11-2:6:15",
|
||||
"value": [
|
||||
{
|
||||
"string": "list",
|
||||
"raw_string": "list"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {
|
||||
"array": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,2:8:17-8:2:64",
|
||||
"nodes": [
|
||||
{
|
||||
"double_quoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,3:4:23-3:7:26",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"double_quoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,4:4:32-4:7:35",
|
||||
"value": [
|
||||
{
|
||||
"string": "b",
|
||||
"raw_string": "b"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"double_quoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,5:4:41-5:7:44",
|
||||
"value": [
|
||||
{
|
||||
"string": "c",
|
||||
"raw_string": "c"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"double_quoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,6:4:50-6:7:53",
|
||||
"value": [
|
||||
{
|
||||
"string": "d",
|
||||
"raw_string": "d"
|
||||
}
|
||||
]
|
||||
}
|
||||
},
|
||||
{
|
||||
"comment": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,7:4:58-7:7:61",
|
||||
"value": "e"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"map_key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,11:0:69-11:1:70",
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,11:0:69-11:1:70",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,11:0:69-11:1:70",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"primary": {},
|
||||
"value": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"root": {
|
||||
"id": "",
|
||||
"id_val": "",
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": ""
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": ""
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
},
|
||||
"edges": null,
|
||||
"objects": [
|
||||
{
|
||||
"id": "a",
|
||||
"id_val": "a",
|
||||
"references": [
|
||||
{
|
||||
"key": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,11:0:69-11:1:70",
|
||||
"path": [
|
||||
{
|
||||
"unquoted_string": {
|
||||
"range": "d2/testdata/d2compiler/TestCompile2/vars/basic/comment-array.d2,11:0:69-11:1:70",
|
||||
"value": [
|
||||
{
|
||||
"string": "a",
|
||||
"raw_string": "a"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"key_path_index": 0,
|
||||
"map_key_edge_index": -1
|
||||
}
|
||||
],
|
||||
"attributes": {
|
||||
"label": {
|
||||
"value": "a"
|
||||
},
|
||||
"labelDimensions": {
|
||||
"width": 0,
|
||||
"height": 0
|
||||
},
|
||||
"style": {},
|
||||
"near_key": null,
|
||||
"shape": {
|
||||
"value": "rectangle"
|
||||
},
|
||||
"direction": {
|
||||
"value": ""
|
||||
},
|
||||
"constraint": null
|
||||
},
|
||||
"zIndex": 0
|
||||
}
|
||||
]
|
||||
},
|
||||
"err": null
|
||||
}
|
||||
Loading…
Reference in a new issue