Documentation
¶
Overview ¶
Package d2 provides functionality for converting database schemas into D2 diagram format. D2 is a modern diagram scripting language that turns text into diagrams. This package implements the dberd.Target interface for D2 diagram generation.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Target ¶
type Target struct {
// contains filtered or unexported fields
}
Target represents a D2 diagram formatter that converts database schemas into D2 format. It handles the conversion of database schemas to D2 diagrams and their subsequent rendering. The formatter uses an embedded template for diagram generation and supports customization through various options for rendering and compilation.
func NewTarget ¶
NewTarget creates a new D2 diagram formatter instance. It initializes the template from the embedded schema.tmpl file and sets up default rendering and compilation options. The formatter uses the ELK layout engine for diagram arrangement.
func (*Target) Capabilities ¶
func (t *Target) Capabilities() dberd.TargetCapabilities
Capabilities returns target capabilities.
func (*Target) FormatSchema ¶
FormatSchema converts a database schema into D2 diagram format.
func (*Target) RenderSchema ¶
RenderSchema renders a formatted D2 diagram to SVG format.
type TargetOpt ¶
type TargetOpt func(*Target)
TargetOpt is a function type that allows customization of a Target instance. It is used to configure various aspects of the D2 diagram generation process.
func WithCompileOpts ¶
func WithCompileOpts(compileOpts *d2lib.CompileOptions) TargetOpt
WithCompileOpts returns a TargetOpt that sets the compilation options for the D2 diagram. These options control the layout and measurement aspects of the diagram generation.
func WithRenderOpts ¶
func WithRenderOpts(renderOpts *d2svg.RenderOpts) TargetOpt
WithRenderOpts returns a TargetOpt that sets the rendering options for the D2 diagram. These options control aspects such as padding, theme, and other visual properties.