func BoardIDA(n Node) (ida []string)
BoardIDA returns the absolute path to n from the nearest board root.
func IDA(n Node) (ida []string)
IDA returns the absolute path to n.
func IsVar(n Node) bool
func OverlayEdge(be, oe *Edge)
func OverlayField(bf, of *Field)
func OverlayMap(base, overlay *Map)
func ParentShape(n Node) string
func RelIDA(p, n Node) (ida []string)
RelIDA returns the path to n relative to p.
type Array struct { Values []Value `json:"values"` // contains filtered or unexported fields }
func (a *Array) AST() d2ast.Node
func (a *Array) Copy(newParent Node) Node
func (a *Array) Equal(n2 Node) bool
func (n *Array) LastPrimaryKey() *d2ast.Key
func (n *Array) LastPrimaryRef() Reference
func (n *Array) LastRef() Reference
func (n *Array) Map() *Map
func (n *Array) Parent() Node
func (n *Array) Primary() *Scalar
func (n *Array) String() string
type BoardKind string
const ( BoardLayer BoardKind = "layer" BoardScenario BoardKind = "scenario" BoardStep BoardKind = "step" )
func NodeBoardKind(n Node) BoardKind
NodeBoardKind reports whether n represents the root of a board. n should be *Field or *Map
type CompileOptions struct { UTF16Pos bool // Pass nil to disable imports. FS fs.FS }
type Composite interface { Node Value // contains filtered or unexported methods }
type Edge struct { ID *EdgeID `json:"edge_id"` Primary_ *Scalar `json:"primary,omitempty"` Map_ *Map `json:"map,omitempty"` References []*EdgeReference `json:"references,omitempty"` // contains filtered or unexported fields }
func ParentEdge(n Node) *Edge
func (e *Edge) AST() d2ast.Node
func (e *Edge) Copy(newParent Node) Node
func (e *Edge) Equal(n2 Node) bool
func (e *Edge) IDString() string
func (e *Edge) LastPrimaryKey() *d2ast.Key
func (e *Edge) LastPrimaryRef() Reference
func (e *Edge) LastRef() Reference
func (n *Edge) Map() *Map
func (n *Edge) Parent() Node
func (n *Edge) Primary() *Scalar
func (n *Edge) String() string
type EdgeID struct { SrcPath []string `json:"src_path"` SrcArrow bool `json:"src_arrow"` DstPath []string `json:"dst_path"` DstArrow bool `json:"dst_arrow"` // If nil, then any EdgeID with equal src/dst/arrows matches. Index *int `json:"index"` Glob bool `json:"glob"` }
func NewEdgeIDs(k *d2ast.Key) (eida []*EdgeID)
func (eid *EdgeID) Copy() *EdgeID
func (eid *EdgeID) Match(eid2 *EdgeID) bool
type EdgeReference struct { Context_ *RefContext `json:"context"` DueToGlob_ bool `json:"due_to_glob"` DueToLazyGlob_ bool `json:"due_to_lazy_glob"` }
func (er *EdgeReference) AST() d2ast.Node
func (r *EdgeReference) Context() *RefContext
func (r *EdgeReference) DueToGlob() bool
func (r *EdgeReference) DueToLazyGlob() bool
func (er *EdgeReference) Primary() bool
Primary returns true if the Value in Context.Key.Value corresponds to the *Edge represented by Context.Edge
type Field struct { Name string `json:"name"` // Primary_ to avoid clashing with Primary(). We need to keep it exported for // encoding/json to marshal it so cannot prefix _ instead. Primary_ *Scalar `json:"primary,omitempty"` Composite Composite `json:"composite,omitempty"` References []*FieldReference `json:"references,omitempty"` // contains filtered or unexported fields }
func ParentField(n Node) *Field
func (f *Field) AST() d2ast.Node
func (f *Field) Copy(newParent Node) Node
func (f *Field) Equal(n2 Node) bool
func (f *Field) LastPrimaryKey() *d2ast.Key
func (f *Field) LastPrimaryRef() Reference
func (f *Field) LastRef() Reference
func (n *Field) Map() *Map
func (n *Field) Parent() Node
func (n *Field) Primary() *Scalar
func (f *Field) Root() bool
func (n *Field) String() string
type FieldReference struct { String d2ast.String `json:"string"` KeyPath *d2ast.KeyPath `json:"key_path"` Context_ *RefContext `json:"context"` DueToGlob_ bool `json:"due_to_glob"` DueToLazyGlob_ bool `json:"due_to_lazy_glob"` }
func (fr *FieldReference) AST() d2ast.Node
func (r *FieldReference) Context() *RefContext
func (r *FieldReference) DueToGlob() bool
func (r *FieldReference) DueToLazyGlob() bool
func (fr *FieldReference) EdgeDest() bool
func (fr *FieldReference) InEdge() bool
func (fr *FieldReference) KeyPathIndex() int
func (fr *FieldReference) Primary() bool
Primary returns true if the Value in Context.Key.Value corresponds to the Field represented by String.
type Map struct { Fields []*Field `json:"fields"` Edges []*Edge `json:"edges"` // contains filtered or unexported fields }
func Compile(ast *d2ast.Map, opts *CompileOptions) (*Map, error)
func ParentMap(n Node) *Map
func RootMap(m *Map) *Map
func (m *Map) AST() d2ast.Node
func (m *Map) Copy(newParent Node) Node
func (m *Map) CopyBase(newParent Node) *Map
CopyBase copies the map m without layers/scenarios/steps.
func (m *Map) CreateEdge(eid *EdgeID, refctx *RefContext, c *compiler) ([]*Edge, error)
func (m *Map) DeleteEdge(eid *EdgeID) *Edge
func (m *Map) DeleteField(ida ...string) *Field
func (m *Map) EdgeCountRecursive() int
func (m *Map) EnsureField(kp *d2ast.KeyPath, refctx *RefContext, create bool, c *compiler) ([]*Field, error)
EnsureField is a bit of a misnomer. It's more of a Query/Ensure combination function at this point.
func (m *Map) Equal(n2 Node) bool
func (m *Map) FieldCountRecursive() int
func (m *Map) GetClassMap(name string) *Map
func (m *Map) GetEdges(eid *EdgeID, refctx *RefContext, c *compiler) []*Edge
func (m *Map) GetField(ida ...string) *Field
func (m *Map) InClass(key *d2ast.Key) bool
func (m *Map) IsClass() bool
func (m *Map) IsContainer() bool
func (n *Map) LastPrimaryKey() *d2ast.Key
func (n *Map) LastPrimaryRef() Reference
func (n *Map) LastRef() Reference
func (n *Map) Map() *Map
func (n *Map) Parent() Node
func (n *Map) Primary() *Scalar
func (m *Map) Query(idStr string) (Node, error)
Query is only for tests and debugging.
func (m *Map) QueryAll(idStr string) (na []Node, _ error)
QueryAll is only for tests and debugging.
func (m *Map) Root() bool
Root reports whether the Map is the root of the D2 tree.
func (n *Map) String() string
Most errors returned by a node should be created with d2parser.Errorf to indicate the offending AST node.
type Node interface { Copy(newParent Node) Node Parent() Node Primary() *Scalar Map() *Map Equal(n2 Node) bool AST() d2ast.Node fmt.Stringer LastRef() Reference LastPrimaryRef() Reference LastPrimaryKey() *d2ast.Key // contains filtered or unexported methods }
func ParentBoard(n Node) Node
type RefContext struct { Edge *d2ast.Edge `json:"edge"` Key *d2ast.Key `json:"key"` Scope *d2ast.Map `json:"-"` ScopeMap *Map `json:"-"` ScopeAST *d2ast.Map `json:"-"` }
func (rc *RefContext) Copy() *RefContext
func (rc *RefContext) EdgeIndex() int
func (rc *RefContext) Equal(rc2 *RefContext) bool
type Reference interface { // Most specific AST node for the reference. AST() d2ast.Node Primary() bool Context() *RefContext // Result of a glob in Context or from above. DueToGlob() bool DueToLazyGlob() bool // contains filtered or unexported methods }
type Scalar struct { Value d2ast.Scalar `json:"value"` // contains filtered or unexported fields }
func (s *Scalar) AST() d2ast.Node
func (s *Scalar) Copy(newParent Node) Node
func (s *Scalar) Equal(n2 Node) bool
func (n *Scalar) LastPrimaryKey() *d2ast.Key
func (n *Scalar) LastPrimaryRef() Reference
func (n *Scalar) LastRef() Reference
func (n *Scalar) Map() *Map
func (n *Scalar) Parent() Node
func (n *Scalar) Primary() *Scalar
func (n *Scalar) String() string
type Value interface { Node // contains filtered or unexported methods }