2022-11-12 01:31:08PM

This commit is contained in:
Alexander Wang 2022-11-12 13:31:08 -08:00
parent 3f653beb1c
commit 6abbab5a7e
7 changed files with 244 additions and 0 deletions

View file

@ -500,9 +500,11 @@ func drawShape(writer io.Writer, targetShape d2target.Shape) error {
switch targetShape.Type { switch targetShape.Type {
case d2target.ShapeClass: case d2target.ShapeClass:
drawClass(writer, targetShape) drawClass(writer, targetShape)
fmt.Fprintf(writer, `</g>`)
return nil return nil
case d2target.ShapeSQLTable: case d2target.ShapeSQLTable:
drawTable(writer, targetShape) drawTable(writer, targetShape)
fmt.Fprintf(writer, `</g>`)
return nil return nil
case d2target.ShapeOval: case d2target.ShapeOval:
if targetShape.Multiple { if targetShape.Multiple {

View file

@ -2,6 +2,7 @@ package e2etests
import ( import (
"context" "context"
"encoding/xml"
"fmt" "fmt"
"io/ioutil" "io/ioutil"
"os" "os"
@ -127,6 +128,11 @@ func run(t *testing.T, tc testCase) {
t.Fatal(err) t.Fatal(err)
} }
var xmlParsed interface{}
if err := xml.Unmarshal(svgBytes, &xmlParsed); err != nil {
t.Fatalf("invalid SVG: %v", err)
}
err = diff.Testdata(filepath.Join(dataPath, "board"), diagram) err = diff.Testdata(filepath.Join(dataPath, "board"), diagram)
if err != nil { if err != nil {
ioutil.WriteFile(pathGotSVG, svgBytes, 0600) ioutil.WriteFile(pathGotSVG, svgBytes, 0600)

View file

@ -816,6 +816,20 @@ a line of text and an
| |
a -> md -> b a -> md -> b
`,
},
{
name: "class",
script: `manager: BatchManager {
shape: class
-num: int
-timeout: int
-pid
+getStatus(): Enum
+getJobs(): "Job[]"
+setTimeout(seconds int)
}
`, `,
}, },
} }

View file

@ -0,0 +1,75 @@
{
"name": "",
"shapes": [
{
"id": "manager",
"type": "class",
"pos": {
"x": 0,
"y": 0
},
"width": 339,
"height": 368,
"level": 1,
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#FFFFFF",
"stroke": "#0A0F25",
"shadow": false,
"3d": false,
"multiple": false,
"tooltip": "",
"link": "",
"icon": null,
"iconPosition": "",
"fields": [
{
"name": "num",
"type": "int",
"visibility": "private"
},
{
"name": "timeout",
"type": "int",
"visibility": "private"
},
{
"name": "pid",
"type": "",
"visibility": "private"
}
],
"methods": [
{
"name": "getStatus()",
"return": "Enum",
"visibility": "public"
},
{
"name": "getJobs()",
"return": "Job[]",
"visibility": "public"
},
{
"name": "setTimeout(seconds int)",
"return": "void",
"visibility": "public"
}
],
"columns": null,
"label": "BatchManager",
"fontSize": 20,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": true,
"underline": false,
"labelWidth": 150,
"labelHeight": 36
}
],
"connections": []
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 327 KiB

View file

@ -0,0 +1,75 @@
{
"name": "",
"shapes": [
{
"id": "manager",
"type": "class",
"pos": {
"x": 12,
"y": 12
},
"width": 339,
"height": 368,
"level": 1,
"opacity": 1,
"strokeDash": 0,
"strokeWidth": 2,
"borderRadius": 0,
"fill": "#FFFFFF",
"stroke": "#0A0F25",
"shadow": false,
"3d": false,
"multiple": false,
"tooltip": "",
"link": "",
"icon": null,
"iconPosition": "",
"fields": [
{
"name": "num",
"type": "int",
"visibility": "private"
},
{
"name": "timeout",
"type": "int",
"visibility": "private"
},
{
"name": "pid",
"type": "",
"visibility": "private"
}
],
"methods": [
{
"name": "getStatus()",
"return": "Enum",
"visibility": "public"
},
{
"name": "getJobs()",
"return": "Job[]",
"visibility": "public"
},
{
"name": "setTimeout(seconds int)",
"return": "void",
"visibility": "public"
}
],
"columns": null,
"label": "BatchManager",
"fontSize": 20,
"fontFamily": "DEFAULT",
"language": "",
"color": "#0A0F25",
"italic": false,
"bold": true,
"underline": false,
"labelWidth": 150,
"labelHeight": 36
}
],
"connections": []
}

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 327 KiB