Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add shape hierarchy #1869

Merged
merged 1 commit into from
Mar 15, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions d2compiler/compile_test.go
Original file line number Diff line number Diff line change
@@ -2848,6 +2848,14 @@ y.source-arrowhead.shape: cf-one
expErr: `d2/testdata/d2compiler/TestCompile/no_arrowheads_in_shape.d2:1:3: "target-arrowhead" can only be used on connections
d2/testdata/d2compiler/TestCompile/no_arrowheads_in_shape.d2:2:3: "source-arrowhead" can only be used on connections`,
},
{
name: "shape-hierarchy",
text: `x: {
shape: hierarchy
a -> b
}
`,
},
}

for _, tc := range testCases {
2 changes: 1 addition & 1 deletion d2renderers/d2svg/d2svg.go
Original file line number Diff line number Diff line change
@@ -1036,7 +1036,7 @@ func drawShape(writer, appendixWriter io.Writer, diagramHash string, targetShape
fmt.Fprint(writer, el.Render())

// TODO should standardize "" to rectangle
case d2target.ShapeRectangle, d2target.ShapeSequenceDiagram, "":
case d2target.ShapeRectangle, d2target.ShapeSequenceDiagram, d2target.ShapeHierarchy, "":
borderRadius := math.MaxFloat64
if targetShape.BorderRadius != 0 {
borderRadius = float64(targetShape.BorderRadius)
3 changes: 3 additions & 0 deletions d2target/d2target.go
Original file line number Diff line number Diff line change
@@ -881,6 +881,7 @@ const (
ShapeSQLTable = "sql_table"
ShapeImage = "image"
ShapeSequenceDiagram = "sequence_diagram"
ShapeHierarchy = "hierarchy"
)

var Shapes = []string{
@@ -907,6 +908,7 @@ var Shapes = []string{
ShapeSQLTable,
ShapeImage,
ShapeSequenceDiagram,
ShapeHierarchy,
}

func IsShape(s string) bool {
@@ -974,6 +976,7 @@ var DSL_SHAPE_TO_SHAPE_TYPE = map[string]string{
ShapeSQLTable: shape.TABLE_TYPE,
ShapeImage: shape.IMAGE_TYPE,
ShapeSequenceDiagram: shape.SQUARE_TYPE,
ShapeHierarchy: shape.SQUARE_TYPE,
}

var SHAPE_TYPE_TO_DSL_SHAPE map[string]string
312 changes: 312 additions & 0 deletions testdata/d2compiler/TestCompile/shape-hierarchy.exp.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading