Documentation
¶
Overview ¶
Package c4 parses Mermaid's C4 diagrams and lays them out, as Pele's src/diagrams/c4 does: a lexer and a parser that read what Mermaid's c4Diagram.jison reads, the model they build (C4Db), the grid of shapes and boundaries Mermaid lays them out in (layout.ts), the routes of the relations between them (route.ts), and Layout, which draws them as a scene (render.ts).
Index ¶
Constants ¶
const ( RoleTitle scene.Role = "c4.title" RoleBoundary scene.Role = "c4.boundary" RoleDeployment scene.Role = "c4.deployment" RoleBoundaryLabel scene.Role = "c4.boundary-label" RoleBoundaryType scene.Role = "c4.boundary-type" RoleBoundaryDescr scene.Role = "c4.boundary-descr" RoleRel scene.Role = "c4.rel" RoleElement scene.Role = "c4.element" RoleElementType scene.Role = "c4.element-type" RoleElementTechn scene.Role = "c4.element-techn" RoleElementDescr scene.Role = "c4.element-descr" RoleRelLabel scene.Role = "c4.rel-label" RoleRelTechn scene.Role = "c4.rel-techn" )
The roles of the items of a C4 diagram.
Variables ¶
This section is empty.
Functions ¶
func Layout ¶
Layout lays out a parsed C4 diagram as a scene, as Pele's renderC4 draws it: on Mermaid's grid with room to spare, and, when that does not fit o.MaxWidth, tightly, with the gap between columns that leaves the fewest relations without a lane of their own. A relation between things the diagram does not have is an error, a *diagram.Error.
Types ¶
type Boundary ¶
type Boundary struct {
Element
// NodeType is set on deployment nodes: node, nodeL or nodeR.
NodeType string
}
Boundary is a boundary or a deployment node, Pele's C4Boundary.
type DB ¶
type DB struct {
// C4Type is the header keyword: C4Context, C4Container, C4Component, C4Dynamic or
// C4Deployment.
C4Type string
// Title is the title, when HasTitle.
Title string
HasTitle bool
// AccTitle is never set: the grammar hands accTitle to the title.
AccTitle string
// AccDescr is the accessible description, when HasAccDescr.
AccDescr string
HasAccDescr bool
Shapes []*Shape
// The first boundary is the unnamed one that holds everything at the top level.
Boundaries []*Boundary
Rels []*Rel
// ShapeInRow and BoundaryInRow are as parseInt reads them, which may be past any int.
ShapeInRow, BoundaryInRow float64
// contains filtered or unexported fields
}
DB is a parsed C4 diagram, Pele's C4Db, and the builder the parser calls.
type Element ¶
type Element struct {
Alias, Label string
// A named argument written where the alias or the label belongs. It is applied to the
// field it names.
AliasAttr, LabelAttr *Named
Parent *Boundary
Type, Descr, Techn, Sprite, Tags, Link string
BgColor, FontColor, BorderColor string
Shadowing, Shape, LegendText, LegendSprite string
// Extra holds the named arguments that set no known field, in the order they were first
// given; a later one of the same key replaces the value.
Extra []Named
// contains filtered or unexported fields
}
Element is what shapes and boundaries share, Pele's C4Element. A field Pele leaves undefined is empty, and Defined tells it from one set to "".
type Named ¶
type Named struct{ Key, Value string }
Named is a `$key="value"` argument, Pele's C4Named.
type Rel ¶
type Rel struct {
Type, From, To, Label string
FromAttr, ToAttr, LabelAttr *Named
Techn, Descr, Sprite, Tags, Link, TextColor, LineColor string
// OffsetX and OffsetY are as parseInt reads them, NaN among them.
OffsetX, OffsetY float64
Extra []Named
// contains filtered or unexported fields
}
Rel is a relation, Pele's C4Rel.