fix empty layer
This commit is contained in:
parent
ccb38606f5
commit
c8dc0f94a2
4 changed files with 115 additions and 14 deletions
|
|
@ -371,21 +371,24 @@ func compile(ctx context.Context, ms *xmain.State, plugin d2plugin.Plugin, rende
|
|||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
out := boards[0]
|
||||
if animateInterval > 0 {
|
||||
out, err = d2animate.Wrap(diagram, boards, renderOpts, int(animateInterval))
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
var out []byte
|
||||
if len(boards) > 0 {
|
||||
out := boards[0]
|
||||
if animateInterval > 0 {
|
||||
out, err = d2animate.Wrap(diagram, boards, renderOpts, int(animateInterval))
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
err = os.MkdirAll(filepath.Dir(outputPath), 0755)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
err = ms.WritePath(outputPath, out)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
ms.Log.Success.Printf("successfully compiled %s to %s in %s", ms.HumanPath(inputPath), ms.HumanPath(outputPath), time.Since(start))
|
||||
}
|
||||
err = os.MkdirAll(filepath.Dir(outputPath), 0755)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
err = ms.WritePath(outputPath, out)
|
||||
if err != nil {
|
||||
return nil, false, err
|
||||
}
|
||||
ms.Log.Success.Printf("successfully compiled %s to %s in %s", ms.HumanPath(inputPath), ms.HumanPath(outputPath), time.Since(start))
|
||||
}
|
||||
return out, true, nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,6 +56,16 @@ func TestCLI_E2E(t *testing.T) {
|
|||
assert.Testdata(t, ".svg", svg)
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "empty-layer",
|
||||
run: func(t *testing.T, ctx context.Context, dir string, env *xos.Env) {
|
||||
writeFile(t, dir, "empty-layer.d2", `layers: { x: {} }`)
|
||||
err := runTestMain(t, ctx, dir, env, "empty-layer.d2")
|
||||
assert.Success(t, err)
|
||||
|
||||
assert.TestdataDir(t, filepath.Join(dir, "empty-layer"))
|
||||
},
|
||||
},
|
||||
{
|
||||
name: "animation",
|
||||
run: func(t *testing.T, ctx context.Context, dir string, env *xos.Env) {
|
||||
|
|
|
|||
88
e2etests-cli/testdata/TestCLI_E2E/empty-layer/x.exp.svg
vendored
Normal file
88
e2etests-cli/testdata/TestCLI_E2E/empty-layer/x.exp.svg
vendored
Normal file
|
|
@ -0,0 +1,88 @@
|
|||
<?xml version="1.0" encoding="utf-8"?><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" d2Version="v0.3.0-HEAD" preserveAspectRatio="xMinYMin meet" viewBox="0 0 200 200"><svg id="d2-svg" class="d2-121760133" width="200" height="200" viewBox="-100 -100 200 200"><rect x="-100.000000" y="-100.000000" width="200.000000" height="200.000000" rx="0.000000" class=" fill-N7" stroke-width="0" /><style type="text/css"><![CDATA[]]></style><style type="text/css"><![CDATA[.shape {
|
||||
shape-rendering: geometricPrecision;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.connection {
|
||||
stroke-linecap: round;
|
||||
stroke-linejoin: round;
|
||||
}
|
||||
.blend {
|
||||
mix-blend-mode: multiply;
|
||||
opacity: 0.5;
|
||||
}
|
||||
|
||||
.d2-121760133 .fill-N1{fill:#0A0F25;}
|
||||
.d2-121760133 .fill-N2{fill:#676C7E;}
|
||||
.d2-121760133 .fill-N3{fill:#9499AB;}
|
||||
.d2-121760133 .fill-N4{fill:#CFD2DD;}
|
||||
.d2-121760133 .fill-N5{fill:#DEE1EB;}
|
||||
.d2-121760133 .fill-N6{fill:#EEF1F8;}
|
||||
.d2-121760133 .fill-N7{fill:#FFFFFF;}
|
||||
.d2-121760133 .fill-B1{fill:#0D32B2;}
|
||||
.d2-121760133 .fill-B2{fill:#0D32B2;}
|
||||
.d2-121760133 .fill-B3{fill:#E3E9FD;}
|
||||
.d2-121760133 .fill-B4{fill:#E3E9FD;}
|
||||
.d2-121760133 .fill-B5{fill:#EDF0FD;}
|
||||
.d2-121760133 .fill-B6{fill:#F7F8FE;}
|
||||
.d2-121760133 .fill-AA2{fill:#4A6FF3;}
|
||||
.d2-121760133 .fill-AA4{fill:#EDF0FD;}
|
||||
.d2-121760133 .fill-AA5{fill:#F7F8FE;}
|
||||
.d2-121760133 .fill-AB4{fill:#EDF0FD;}
|
||||
.d2-121760133 .fill-AB5{fill:#F7F8FE;}
|
||||
.d2-121760133 .stroke-N1{stroke:#0A0F25;}
|
||||
.d2-121760133 .stroke-N2{stroke:#676C7E;}
|
||||
.d2-121760133 .stroke-N3{stroke:#9499AB;}
|
||||
.d2-121760133 .stroke-N4{stroke:#CFD2DD;}
|
||||
.d2-121760133 .stroke-N5{stroke:#DEE1EB;}
|
||||
.d2-121760133 .stroke-N6{stroke:#EEF1F8;}
|
||||
.d2-121760133 .stroke-N7{stroke:#FFFFFF;}
|
||||
.d2-121760133 .stroke-B1{stroke:#0D32B2;}
|
||||
.d2-121760133 .stroke-B2{stroke:#0D32B2;}
|
||||
.d2-121760133 .stroke-B3{stroke:#E3E9FD;}
|
||||
.d2-121760133 .stroke-B4{stroke:#E3E9FD;}
|
||||
.d2-121760133 .stroke-B5{stroke:#EDF0FD;}
|
||||
.d2-121760133 .stroke-B6{stroke:#F7F8FE;}
|
||||
.d2-121760133 .stroke-AA2{stroke:#4A6FF3;}
|
||||
.d2-121760133 .stroke-AA4{stroke:#EDF0FD;}
|
||||
.d2-121760133 .stroke-AA5{stroke:#F7F8FE;}
|
||||
.d2-121760133 .stroke-AB4{stroke:#EDF0FD;}
|
||||
.d2-121760133 .stroke-AB5{stroke:#F7F8FE;}
|
||||
.d2-121760133 .background-color-N1{background-color:#0A0F25;}
|
||||
.d2-121760133 .background-color-N2{background-color:#676C7E;}
|
||||
.d2-121760133 .background-color-N3{background-color:#9499AB;}
|
||||
.d2-121760133 .background-color-N4{background-color:#CFD2DD;}
|
||||
.d2-121760133 .background-color-N5{background-color:#DEE1EB;}
|
||||
.d2-121760133 .background-color-N6{background-color:#EEF1F8;}
|
||||
.d2-121760133 .background-color-N7{background-color:#FFFFFF;}
|
||||
.d2-121760133 .background-color-B1{background-color:#0D32B2;}
|
||||
.d2-121760133 .background-color-B2{background-color:#0D32B2;}
|
||||
.d2-121760133 .background-color-B3{background-color:#E3E9FD;}
|
||||
.d2-121760133 .background-color-B4{background-color:#E3E9FD;}
|
||||
.d2-121760133 .background-color-B5{background-color:#EDF0FD;}
|
||||
.d2-121760133 .background-color-B6{background-color:#F7F8FE;}
|
||||
.d2-121760133 .background-color-AA2{background-color:#4A6FF3;}
|
||||
.d2-121760133 .background-color-AA4{background-color:#EDF0FD;}
|
||||
.d2-121760133 .background-color-AA5{background-color:#F7F8FE;}
|
||||
.d2-121760133 .background-color-AB4{background-color:#EDF0FD;}
|
||||
.d2-121760133 .background-color-AB5{background-color:#F7F8FE;}
|
||||
.d2-121760133 .color-N1{color:#0A0F25;}
|
||||
.d2-121760133 .color-N2{color:#676C7E;}
|
||||
.d2-121760133 .color-N3{color:#9499AB;}
|
||||
.d2-121760133 .color-N4{color:#CFD2DD;}
|
||||
.d2-121760133 .color-N5{color:#DEE1EB;}
|
||||
.d2-121760133 .color-N6{color:#EEF1F8;}
|
||||
.d2-121760133 .color-N7{color:#FFFFFF;}
|
||||
.d2-121760133 .color-B1{color:#0D32B2;}
|
||||
.d2-121760133 .color-B2{color:#0D32B2;}
|
||||
.d2-121760133 .color-B3{color:#E3E9FD;}
|
||||
.d2-121760133 .color-B4{color:#E3E9FD;}
|
||||
.d2-121760133 .color-B5{color:#EDF0FD;}
|
||||
.d2-121760133 .color-B6{color:#F7F8FE;}
|
||||
.d2-121760133 .color-AA2{color:#4A6FF3;}
|
||||
.d2-121760133 .color-AA4{color:#EDF0FD;}
|
||||
.d2-121760133 .color-AA5{color:#F7F8FE;}
|
||||
.d2-121760133 .color-AB4{color:#EDF0FD;}
|
||||
.d2-121760133 .color-AB5{color:#F7F8FE;}.appendix text.text{fill:#0A0F25}.md{--color-fg-default:#0A0F25;--color-fg-muted:#676C7E;--color-fg-subtle:#9499AB;--color-canvas-default:#FFFFFF;--color-canvas-subtle:#EEF1F8;--color-border-default:#0D32B2;--color-border-muted:#0D32B2;--color-neutral-muted:#EEF1F8;--color-accent-fg:#0D32B2;--color-accent-emphasis:#0D32B2;--color-attention-subtle:#676C7E;--color-danger-fg:red;}.sketch-overlay-B1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B2{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-B3{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-B6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-AA4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AA5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB4{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-AB5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N1{fill:url(#streaks-darker);mix-blend-mode:lighten}.sketch-overlay-N2{fill:url(#streaks-dark);mix-blend-mode:overlay}.sketch-overlay-N3{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N4{fill:url(#streaks-normal);mix-blend-mode:color-burn}.sketch-overlay-N5{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N6{fill:url(#streaks-bright);mix-blend-mode:darken}.sketch-overlay-N7{fill:url(#streaks-bright);mix-blend-mode:darken}.light-code{display: block}.dark-code{display: none}]]></style><mask id="d2-121760133" maskUnits="userSpaceOnUse" x="-100" y="-100" width="200" height="200">
|
||||
<rect x="-100" y="-100" width="200" height="200" fill="white"></rect>
|
||||
|
||||
</mask></svg></svg>
|
||||
|
After Width: | Height: | Size: 5.8 KiB |
Binary file not shown.
Loading…
Reference in a new issue