package d2graph

Import Path
	github.com/pancsta/d2/d2graph (on go.dev)

Dependency Relation
	imports 27 packages, and imported by 14 packages


Package-Level Type Names (total 15)
/* sort by: | */
These names are attached to the rendered elements in SVG so that users can target them however they like outside of D2 Constraint []string Direction Scalar GridColumns *Scalar GridGap *Scalar GridRows *Scalar HeightAttr *Scalar HorizontalGap *Scalar Icon *url.URL IconPosition *Scalar IconStyle Style Label Scalar LabelDimensions d2target.TextDimensions LabelPosition *Scalar Language string Left *Scalar Link *Scalar TODO consider separate Attributes struct for shape-specific and edge-specific Shapes only TODO: default to ShapeRectangle instead of empty string Style Style Tooltip *Scalar TooltipPosition *Scalar Top *Scalar VerticalGap *Scalar WidthAttr *Scalar ApplyTextTransform will alter the `Label.Value` of the current object based on the specification of the `text-transform` styling option. This function has side-effects! (*Attributes) ToArrowhead() d2target.Arrowhead
( ContainerLevel) LabelSize() int func (*Object).Level() ContainerLevel
Attributes Attributes These names are attached to the rendered elements in SVG so that users can target them however they like outside of D2 Attributes.Constraint []string Attributes.Direction Scalar Attributes.GridColumns *Scalar Attributes.GridGap *Scalar Attributes.GridRows *Scalar Attributes.HeightAttr *Scalar Attributes.HorizontalGap *Scalar Attributes.Icon *url.URL Attributes.IconPosition *Scalar Attributes.IconStyle Style Attributes.Label Scalar Attributes.LabelDimensions d2target.TextDimensions Attributes.Language string Attributes.Left *Scalar Attributes.Link *Scalar TODO consider separate Attributes struct for shape-specific and edge-specific Shapes only TODO: default to ShapeRectangle instead of empty string Attributes.Style Style Attributes.Tooltip *Scalar Attributes.TooltipPosition *Scalar Attributes.Top *Scalar Attributes.VerticalGap *Scalar Attributes.WidthAttr *Scalar Dst *Object TODO alixander (Mon Sep 12 2022): deprecate SrcArrow and DstArrow and just use SrcArrowhead and DstArrowhead DstArrowhead *Attributes DstTableColumnIndex *int Index int IsCurve bool LabelPercentage *float64 LabelPosition *string References []EdgeReference Route []*geo.Point Src *Object SrcArrow bool SrcArrowhead *Attributes SrcTableColumnIndex *int ZIndex int (*Edge) AbsID() string ApplyTextTransform will alter the `Label.Value` of the current object based on the specification of the `text-transform` styling option. This function has side-effects! (*Edge) ArrowString() string (*Edge) ContainedBy(obj *Object) bool (*Edge) GetAstEdge() *d2ast.Edge (*Edge) GetGroup() *Object (*Edge) GetStroke(dashGapSize interface{}) string IsEquivalent reports whether the given endpoints describe the same edge. Arrowheads are attached to endpoints, so reversing the endpoint order also reverses the arrow fields. (*Edge) Move(dx, dy float64) ShiftEnd moves the ending point of the route by delta either horizontally or vertically if prior points are in line with the movement, they will be removed (unless it is the first point) ShiftStart moves the starting point of the route by delta either horizontally or vertically if subsequent points are in line with the movement, they will be removed (unless it is the last point) start end . ├────┼────┼───┼────┼───┤ before . ├──dx──► . ├──┼───┼────┼───┤ after (*Edge) Text() *d2target.MText (*Edge) ToArrowhead() d2target.Arrowhead (*Edge) TraceToShape(points []*geo.Point, startIndex, endIndex int) (newStart, newEnd int) func (*Object).Connect(srcID, dstID []d2ast.String, srcArrow, dstArrow bool, label string) (*Edge, error) func (*Object).FindEdges(mk *d2ast.Key) ([]*Edge, bool) func (*Object).HasEdge(mk *d2ast.Key) (*Edge, bool) func github.com/pancsta/d2/d2layouts.ExtractSubgraph(container *Object, includeSelf bool) (nestedGraph *Graph, externalEdges []*Edge, externalEdgeIDs []d2layouts.edgeIDs) func CompareSerializedEdge(edge, other *Edge) error func ToSerializedEdge(e *Edge) (SerializedEdge, error) func (*Object).ContainsAnyEdge(edges []*Edge) bool func github.com/pancsta/d2/d2layouts.DefaultRouter(ctx context.Context, graph *Graph, edges []*Edge) error func github.com/pancsta/d2/d2layouts/d2talalayout.RouteEdges(ctx context.Context, g *Graph, edges []*Edge) (err error)
AST *d2ast.Map BaseAST is the AST of the original graph without inherited fields and edges Data embedded from source configuration variables, including layout options. Edges []*Edge FS fs.FS IsFolderOnly indicates a board or scenario itself makes no modifications from its base. Folder only boards do not have a render and are used purely for organizing the board tree. Layers []*Graph Legend *Legend Name string Objects []*Object Parent *Graph Root *Object Object.Level uses the location of a nested graph Scenarios []*Graph Steps []*Graph Theme *d2themes.Theme ApplyTheme applies themes on the graph level This is different than on the render level, which only changes colors A theme applied on the graph level applies special rules that change the graph remove obj and all descendants from graph, as a new Graph (*Graph) GetBoard(name string) *Graph (*Graph) IDA() []string (*Graph) InjectNestedGraph(tempGraph *Graph, parent *Object) (*Graph) PrintString() string (*Graph) RootBoard() *Graph (*Graph) SetDimensions(mtexts []*d2target.MText, ruler *textmeasure.Ruler, fontFamily *d2fonts.FontFamily, monoFontFamily *d2fonts.FontFamily) error (*Graph) SortEdgesByAST() (*Graph) SortObjectsByAST() (*Graph) Texts() []*d2target.MText func NewGraph() *Graph func (*Graph).ExtractAsNestedGraph(obj *Object) *Graph func (*Graph).GetBoard(name string) *Graph func (*Graph).RootBoard() *Graph func github.com/pancsta/d2/d2compiler.Compile(p string, r io.Reader, opts *d2compiler.CompileOptions) (*Graph, *d2target.Config, error) func github.com/pancsta/d2/d2layouts.ExtractSubgraph(container *Object, includeSelf bool) (nestedGraph *Graph, externalEdges []*Edge, externalEdgeIDs []d2layouts.edgeIDs) func github.com/pancsta/d2/d2lib.Compile(ctx context.Context, input string, compileOpts *d2lib.CompileOptions, renderOpts *d2svg.RenderOpts) (*d2target.Diagram, *Graph, error) func CompareSerializedGraph(g, other *Graph) error func DeserializeGraph(bytes []byte, g *Graph) error func SerializeGraph(g *Graph) ([]byte, error) func (*Graph).InjectNestedGraph(tempGraph *Graph, parent *Object) func github.com/pancsta/d2/d2exporter.Export(ctx context.Context, g *Graph, fontFamily *d2fonts.FontFamily, monoFontFamily *d2fonts.FontFamily) (*d2target.Diagram, error) func github.com/pancsta/d2/d2layouts.DefaultRouter(ctx context.Context, graph *Graph, edges []*Edge) error func github.com/pancsta/d2/d2layouts.FitToGraph(container *Object, nestedGraph *Graph, padding geo.Spacing) func github.com/pancsta/d2/d2layouts.InjectNested(container *Object, nestedGraph *Graph, isRoot bool) func github.com/pancsta/d2/d2layouts.LayoutNested(ctx context.Context, g *Graph, graphInfo d2layouts.GraphInfo, coreLayout LayoutGraph, edgeRouter RouteEdges) error func github.com/pancsta/d2/d2layouts.PositionNested(container *Object, nestedGraph *Graph) func github.com/pancsta/d2/d2layouts.SaveOrder(g *Graph) (restoreOrder func()) func github.com/pancsta/d2/d2layouts/d2dagrelayout.DefaultLayout(ctx context.Context, g *Graph) (err error) func github.com/pancsta/d2/d2layouts/d2dagrelayout.Layout(ctx context.Context, g *Graph, opts *d2dagrelayout.ConfigurableOpts) (err error) func github.com/pancsta/d2/d2layouts/d2elklayout.DefaultLayout(ctx context.Context, g *Graph) (err error) func github.com/pancsta/d2/d2layouts/d2elklayout.Layout(ctx context.Context, g *Graph, opts *d2elklayout.ConfigurableOpts) (err error) func github.com/pancsta/d2/d2layouts/d2grid.Layout(ctx context.Context, g *Graph) error func github.com/pancsta/d2/d2layouts/d2near.Layout(ctx context.Context, g *Graph, constantNearGraphs []*Graph) error func github.com/pancsta/d2/d2layouts/d2near.Layout(ctx context.Context, g *Graph, constantNearGraphs []*Graph) error func github.com/pancsta/d2/d2layouts/d2sequence.Layout(ctx context.Context, g *Graph, layout LayoutGraph) error func github.com/pancsta/d2/d2layouts/d2talalayout.DefaultLayout(ctx context.Context, graph *Graph) error func github.com/pancsta/d2/d2layouts/d2talalayout.Layout(ctx context.Context, graph *Graph, opts *d2talalayout.Options) (err error) func github.com/pancsta/d2/d2layouts/d2talalayout.RouteEdges(ctx context.Context, g *Graph, edges []*Edge) (err error) func github.com/pancsta/d2/d2layouts/internal/layoutguard.CheckGraph(ctx context.Context, engine string, g *Graph) error
func github.com/pancsta/d2/d2layouts.LayoutNested(ctx context.Context, g *Graph, graphInfo d2layouts.GraphInfo, coreLayout LayoutGraph, edgeRouter RouteEdges) error func github.com/pancsta/d2/d2layouts/d2sequence.Layout(ctx context.Context, g *Graph, layout LayoutGraph) error
Edges []*Edge Label string Objects []*Object
TODO maybe rename to Shape Attributes Attributes These names are attached to the rendered elements in SVG so that users can target them however they like outside of D2 Attributes.Constraint []string Attributes.Direction Scalar Attributes.GridColumns *Scalar Attributes.GridGap *Scalar Attributes.GridRows *Scalar Attributes.HeightAttr *Scalar Attributes.HorizontalGap *Scalar Attributes.Icon *url.URL Attributes.IconStyle Style Attributes.Label Scalar Attributes.LabelDimensions d2target.TextDimensions Attributes.Language string Attributes.Left *Scalar Attributes.Link *Scalar TODO consider separate Attributes struct for shape-specific and edge-specific Shapes only TODO: default to ShapeRectangle instead of empty string Attributes.Style Style Attributes.Tooltip *Scalar Attributes.TooltipPosition *Scalar Attributes.Top *Scalar Attributes.VerticalGap *Scalar Attributes.WidthAttr *Scalar Box *geo.Box Box.Height float64 Box.TopLeft *geo.Point Box.Width float64 Children map[string]*Object ChildrenArray []*Object Class *d2target.Class ContentAspectRatio *float64 Graph *Graph IDVal is the actual value of the ID whereas ID is the value in d2 syntax. e.g. ID: "yes'\"" IDVal: yes'" ID allows joining on . naively and construct a valid D2 key path IDVal string IconPosition *string LabelPosition *string Map *d2ast.Map Parent *Object References []Reference SQLTable *d2target.SQLTable ZIndex int (*Object) AbsID() string (*Object) AbsIDArray() []string (*Object) AppendReferences(ida []string, ref Reference, unresolvedObj *Object) ApplyTextTransform will alter the `Label.Value` of the current object based on the specification of the `text-transform` styling option. This function has side-effects! ( Object) Center() *geo.Point (*Object) ClosestGridCell() *Object (*Object) ClosestGridDiagram() *Object (*Object) Connect(srcID, dstID []d2ast.String, srcArrow, dstArrow bool, label string) (*Edge, error) (*Object) ContainedBy(obj *Object) bool ( Object) Contains(p *geo.Point) bool (*Object) ContainsAnyEdge(edges []*Edge) bool (*Object) ContainsAnyObject(objects []*Object) bool ( Object) Copy() *geo.Box EnsureChild grabs the child by ids or creates it if it does not exist including all intermediate nodes. TODO: remove edges []edge and scope each edge inside Object. (*Object) GetDefaultSize(mtexts []*d2target.MText, ruler *textmeasure.Ruler, fontFamily *d2fonts.FontFamily, monoFontFamily *d2fonts.FontFamily, labelDims d2target.TextDimensions, withLabelPadding bool) (*d2target.TextDimensions, error) (*Object) GetFill() string (*Object) GetIconTopLeft() *geo.Point (*Object) GetLabelSize(mtexts []*d2target.MText, ruler *textmeasure.Ruler, fontFamily *d2fonts.FontFamily, monoFontFamily *d2fonts.FontFamily) (*d2target.TextDimensions, error) (*Object) GetLabelTopLeft() *geo.Point (*Object) GetMargin() geo.Spacing GetModifierElementAdjustments returns width/height adjustments to account for shapes with 3d or multiple (*Object) GetStroke(dashGapSize interface{}) string (*Object) HasChild(ids []string) (*Object, bool) (*Object) HasEdge(mk *d2ast.Key) (*Edge, bool) (*Object) HasIcon() bool (*Object) HasLabel() bool (*Object) HasOutsideBottomLabel() bool ( Object) Intersections(s geo.Segment) []*geo.Point Intersects returns true if the segment comes within buffer of the box (*Object) Is3D() bool (*Object) IsConstantNear() bool (*Object) IsContainer() bool (*Object) IsDescendantOf(ancestor *Object) bool (*Object) IsGridDiagram() bool (*Object) IsMultiple() bool (*Object) IsSequenceDiagram() bool groups are objects in sequence diagrams that have no messages connected and does not have a note as a child (a note can appear within a group, but it's a child of an actor) notes are descendant of actors with no edges and no children (*Object) IterDescendants(apply func(parent, child *Object)) (*Object) Level() ContainerLevel (*Object) MoveWithDescendants(dx, dy float64) (*Object) MoveWithDescendantsTo(x, y float64) (*Object) OuterNearContainer() *Object (*Object) OuterSequenceDiagram() *Object ( Object) Overlaps(b2 geo.Box) bool (*Object) RemoveChild(child *Object) ShiftDescendants moves Object's descendants (not including itself) descendants' edges are also moved by the same dx and dy (the whole route is moved if both ends are a descendant) resizes the object to fit content of the given width and height in its inner box with the given padding. this accounts for the shape of the object, and if there is a desired width or height set for the object (*Object) Spacing() (margin, padding geo.Spacing) (*Object) SpacingOpt(labelPadding, iconPadding float64, maxIconSize bool) (margin, padding geo.Spacing) (*Object) Text() *d2target.MText (*Object) ToArrowhead() d2target.Arrowhead (*Object) ToShape() shape.Shape ( Object) ToString() string TopGridDiagram returns the least nested (outermost) grid diagram Object : github.com/pancsta/d2/lib/geo.Intersectable func ResolveUnderscoreKey(ida []string, obj *Object) (resolvedObj *Object, resolvedIDA []string, _ error) func (*Edge).GetGroup() *Object func (*Object).ClosestGridCell() *Object func (*Object).ClosestGridDiagram() *Object func (*Object).EnsureChild(ida []d2ast.String) *Object func (*Object).HasChild(ids []string) (*Object, bool) func (*Object).OuterNearContainer() *Object func (*Object).OuterSequenceDiagram() *Object func (*Object).TopGridDiagram() *Object func github.com/pancsta/d2/d2layouts/d2grid.GenLayout(objects []*Object, cutIndices []int) [][]*Object func CompareSerializedObject(obj, other *Object) error func ResolveUnderscoreKey(ida []string, obj *Object) (resolvedObj *Object, resolvedIDA []string, _ error) func (*Edge).ContainedBy(obj *Object) bool func (*Edge).IsEquivalent(src *Object, srcArrow bool, dst *Object, dstArrow bool) bool func (*Edge).IsEquivalent(src *Object, srcArrow bool, dst *Object, dstArrow bool) bool func (*Graph).ExtractAsNestedGraph(obj *Object) *Graph func (*Graph).InjectNestedGraph(tempGraph *Graph, parent *Object) func (*Object).AppendReferences(ida []string, ref Reference, unresolvedObj *Object) func (*Object).ContainedBy(obj *Object) bool func (*Object).ContainsAnyObject(objects []*Object) bool func (*Object).IsDescendantOf(ancestor *Object) bool func (*Object).RemoveChild(child *Object) func github.com/pancsta/d2/d2layouts.ExtractSubgraph(container *Object, includeSelf bool) (nestedGraph *Graph, externalEdges []*Edge, externalEdgeIDs []d2layouts.edgeIDs) func github.com/pancsta/d2/d2layouts.FitToGraph(container *Object, nestedGraph *Graph, padding geo.Spacing) func github.com/pancsta/d2/d2layouts.InjectNested(container *Object, nestedGraph *Graph, isRoot bool) func github.com/pancsta/d2/d2layouts.NestedGraphInfo(obj *Object) (gi d2layouts.GraphInfo) func github.com/pancsta/d2/d2layouts.PositionNested(container *Object, nestedGraph *Graph) func github.com/pancsta/d2/d2layouts.SaveChildrenOrder(container *Object) (restoreOrder func()) func github.com/pancsta/d2/d2layouts/d2grid.GenLayout(objects []*Object, cutIndices []int) [][]*Object func github.com/pancsta/d2/d2layouts/d2sequence.IsLifelineEnd(obj *Object) bool
IsVar bool Key *d2ast.KeyPath KeyPathIndex int MapKey *d2ast.Key MapKeyEdgeIndex int Scope *d2ast.Map ScopeAST *d2ast.Map ScopeObj *Object ( Reference) InEdge() bool ( Reference) MapKeyEdgeDest() bool func (*Object).AppendReferences(ida []string, ref Reference, unresolvedObj *Object)
func github.com/pancsta/d2/d2layouts.LayoutNested(ctx context.Context, g *Graph, graphInfo d2layouts.GraphInfo, coreLayout LayoutGraph, edgeRouter RouteEdges) error
TODO consider having different Scalar types Right now we'll hold any types in Value and just convert, e.g. floats MapKey *d2ast.Key Value string
func ToSerializedEdge(e *Edge) (SerializedEdge, error)
type SerializedObject (map)
Animated *Scalar Bold *Scalar BorderRadius *Scalar DoubleBorder *Scalar Fill *Scalar FillPattern *Scalar Filled *Scalar Font *Scalar FontColor *Scalar FontSize *Scalar Italic *Scalar Multiple *Scalar Opacity *Scalar Shadow *Scalar Stroke *Scalar StrokeDash *Scalar StrokeWidth *Scalar TextTransform *Scalar ThreeDee *Scalar Underline *Scalar (*Style) Apply(key, value string) error NoneTextTransform will return a boolean if the text should not have any transformation applied. This should overwrite theme specific transformations like `CapsLock` from the `terminal` theme.
Package-Level Functions (total 13)
CompareSerializedEdge compares the portions of two edges preserved by SerializeGraph and DeserializeGraph. Deprecated: CompareSerializedEdge is an incomplete, test-only assertion and will be removed after one compatibility release. Tests should compare the specific edge invariants they rely on.
CompareSerializedGraph compares the portions of two graphs preserved by SerializeGraph and DeserializeGraph. Deprecated: CompareSerializedGraph is an incomplete, test-only assertion and will be removed after one compatibility release. Tests should serialize, deserialize, and compare the specific graph invariants they rely on.
CompareSerializedObject compares the portions of two objects preserved by SerializeGraph and DeserializeGraph. Deprecated: CompareSerializedObject is an incomplete, test-only assertion and will be removed after one compatibility release. Tests should compare the specific object invariants they rely on.
Type Parameters: T: any Q: any
func DeserializeGraph(bytes []byte, g *Graph) error
GridCapacity returns rows*columns when both axes and their product are bounded. The division check keeps the multiplication from overflowing an int.
func Key(k *d2ast.KeyPath) []string
func NewGraph() *Graph
TODO: remove once not used anywhere
Package-Level Constants (total 6)
const DEFAULT_SHAPE_SIZE = 100
MaxGridCells bounds the capacity of an explicitly dimensioned grid. Grid layout retains empty cells so that diagrams can add objects in later boards, which makes rows*columns the relevant amount of user-controlled work even when the current board contains few objects.
MaxGridDimension bounds each axis of an explicitly dimensioned grid. In addition to layout work, this limits the coordinate span contributed by empty cells before output-specific resource limits run.
const MIN_SEGMENT_LEN = 10
const MIN_SHAPE_SIZE = 5