Documentation
¶
Overview ¶
Package render provides D2 diagram rendering using the d2 library.
Index ¶
- func Compile(ctx context.Context, d2Code string) (*d2target.Diagram, error)
- func MustRender(d2Code string, format Format) []byte
- func Quick(d2Code string) ([]byte, error)
- func QuickToString(d2Code string) (string, error)
- func SVGDimensions(svg []byte) (width, height int, err error)
- func ThemeID(name string) (int64, error)
- func ThemeNames() []string
- func Validate(ctx context.Context, d2Code string) error
- type Buffer
- type Format
- type Options
- type Renderer
- func (r *Renderer) Render(ctx context.Context, d2Code string, format Format, opts *Options) ([]byte, error)
- func (r *Renderer) RenderPDF(ctx context.Context, d2Code string, opts *Options) ([]byte, error)
- func (r *Renderer) RenderPNG(ctx context.Context, d2Code string, opts *Options) ([]byte, error)
- func (r *Renderer) RenderSVG(ctx context.Context, d2Code string, opts *Options) ([]byte, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MustRender ¶
MustRender renders D2 code and panics on error. Useful for tests.
func QuickToString ¶
QuickToString renders D2 code to SVG string with default options.
func SVGDimensions ¶
SVGDimensions extracts width and height from rendered SVG.
Types ¶
type Format ¶
type Format string
Format represents the output format for rendering.
func FormatFromPath ¶
FormatFromPath infers the format from a file path extension.
type Options ¶
type Options struct {
// ThemeID is the D2 theme to use (0 = default).
ThemeID int64
// Pad is the padding around the diagram in pixels.
Pad int64
// Sketch enables sketch/hand-drawn mode.
Sketch bool
// Center centers the diagram in the output.
Center bool
// Scale is the output scale factor (default 1.0).
Scale float64
}
Options configures rendering behavior.
func DefaultOptions ¶
func DefaultOptions() *Options
DefaultOptions returns default rendering options.
type Renderer ¶
type Renderer struct {
// contains filtered or unexported fields
}
Renderer renders D2 code to various output formats.
func (*Renderer) Render ¶
func (r *Renderer) Render(ctx context.Context, d2Code string, format Format, opts *Options) ([]byte, error)
Render compiles and renders D2 code to the specified format.
Click to show internal directories.
Click to hide internal directories.