Documentation
¶
Index ¶
- func Compile(ctx context.Context, input string, compileOpts *CompileOptions, ...) (*d2target.Diagram, *d2graph.Graph, error)
- func Parse(ctx context.Context, input string, compileOpts *CompileOptions) (*d2ast.Map, error)
- func PrepareSketchTransitions(ctx context.Context, root *d2target.Diagram, duration int64) error
- type CompileOptions
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CompileOptions ¶
type CompileOptions struct {
UTF16Pos bool
// AnimateDuration overrides the root animate-duration, in milliseconds.
AnimateDuration *int64
// AnimateTweens controls sampling of step transitions. Nil follows
// the root animate-interval. False compiles only the authored endpoints.
AnimateTweens *bool
// MaxVariableExpansion bounds work added by variable substitutions and the
// automatic copies they induce. Zero uses the secure compiler default.
MaxVariableExpansion int64
// MaxGlobExpansion bounds work performed by glob matching and
// materialization. Zero uses the secure compiler default. Explicit source
// fields are not counted as materialization work.
MaxGlobExpansion int64
// MaxEdgeExpansion bounds distinct edge-segment and endpoint combinations
// considered by edge globs. Zero uses the secure compiler default. Explicit
// edges do not consume this budget.
MaxEdgeExpansion int64
// MaxEdgeExpansionWork bounds all endpoint-pair examinations performed by
// edge globs, including lazy replays. Zero uses the secure compiler default.
MaxEdgeExpansionWork int64
// FS is the file system used for resolving imports in the D2 text. Nil
// disables imports. Callers that accept untrusted input should prefer a
// filesystem constrained to the intended import root; lib/localfile provides
// rooted and explicit unrestricted host-filesystem policies.
FS fs.FS
MeasuredTexts []*d2target.MText
Ruler *textmeasure.Ruler
RouterResolver func(engine string) (d2graph.RouteEdges, error)
LayoutResolver func(engine string) (d2graph.LayoutGraph, error)
// LayoutReuse allows scenarios and steps whose layout inputs are unchanged
// to reuse the geometry of their base board. Callers should enable this only
// when LayoutResolver and RouterResolver return a stable built-in Dagre or
// ELK configuration for the duration of Compile. It is disabled by default
// so custom resolvers retain their existing per-board behavior.
LayoutReuse bool
// LayoutContinuations supplies optional refinements for related boards,
// keyed by lowercase layout engine name. Independent layers start fresh.
LayoutContinuations map[string]d2graph.LayoutContinuation
Layout *string
// FontFamily controls the font family used for all texts that are not the following:
// - code
// - latex
// - pre-measured (web setting)
// TODO maybe some will want to configure code font too, but that's much lower priority
FontFamily *d2fonts.FontFamily
// MonoFontFamily controls the font family used for code/mono texts
MonoFontFamily *d2fonts.FontFamily
InputPath string
}
Click to show internal directories.
Click to hide internal directories.