Documentation
¶
Overview ¶
Package core turns a inkline source file into plain D2: it expands per-diagram shorthand and gives every object and connection a semantic role (see spec/roles.md). It knows nothing about how roles look; that is the design system's job.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DiagramNames ¶
func DiagramNames() []string
DiagramNames lists the supported diagram types, sorted.
Types ¶
type File ¶
File is a parsed inkline file.
func (*File) Expand ¶
Expand returns plain D2: prelude, the author's (transformed) source, and a role overlay that gives every object and connection its role.
The prelude comes from the design system; it is compiled together with the source so the overlay sees the final shapes (a class may set shape: sql_table).
type Header ¶
type Header struct {
Diagram string
DesignSystem string
Theme string
// Orientation applies to swimlanes: vertical (default; lanes are columns)
// or horizontal (lanes are rows).
Orientation string
}
Header is the inkline block of a file's vars:
vars: { inkline: { diagram: flowchart; design_system: carbon; theme: light } }
func ReadHeader ¶
ReadHeader reads and validates the inkline header from a parsed file.
type Source ¶
type Source struct {
// Path is the file's path. Imports resolve against its directory within
// FS, or on disk when FS is nil.
Path string
FS fs.FS
Text string
}
Source is one inkline file to expand.
type Spec ¶
type Spec struct {
Name string
Nodes []string
Containers []string
Edges []string
// TopLevelOnly limits object roles to top-level objects, for diagrams whose
// nested keys are not objects (class fields, table columns, sequence spans).
TopLevelOnly bool
// Layout is the layout engine used unless the file or design system says otherwise.
Layout string
// AnalysisShape is given to every top-level object while the core compiles the
// source to find its objects. Diagrams whose keys only compile inside a
// structural shape (sql_table columns with constraints) need it; the final
// shape comes from the role's class.
AnalysisShape string
// DefaultRole, when set, overrides the default-role rule for objects.
DefaultRole func(obj *d2graph.Object) string
// Transform expands the diagram's shorthand, writing the D2 to compile.
// Nil writes the source as it is.
Transform func(ast *d2ast.Map, b *body) error
// Settings is D2 that applies to the diagram as a whole.
Settings string
// Skip reports objects that take no role.
Skip func(obj *d2graph.Object) bool
// Annotate returns further D2 for an object, given its key and role.
Annotate func(obj *d2graph.Object, id, role string) string
// Lanes lays the diagram out as a matrix of lanes and ranks (see
// laneLayout); its connections need the lane router.
Lanes bool
}
Spec describes one diagram type. The first role of each list is the default.