diagram

package
v0.4.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2026 License: EUPL-1.2 Imports: 7 Imported by: 0

Documentation

Overview

Package diagram provides DOT format generation for workflow visualization.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckGraphviz

func CheckGraphviz() bool

CheckGraphviz detects if the graphviz dot command is available in PATH. Returns true if dot command is found and executable, false otherwise. Used to validate graphviz availability before image export operations.

func Export

func Export(dot, outputPath string) error

Export converts DOT format input to an image file using graphviz. The output format is determined by the file extension of outputPath:

  • .png → PNG image
  • .svg → SVG vector
  • .pdf → PDF document
  • .dot → raw DOT file (no conversion)

Returns an error if graphviz is not installed or conversion fails.

Types

type DiagramConfig

type DiagramConfig struct {
	Direction  Direction // graph layout direction
	OutputPath string    // file path for image export (empty = stdout)
	Highlight  string    // step name to highlight
	ShowLabels bool      // show transition labels
}

DiagramConfig holds configuration for diagram generation.

func NewDefaultConfig

func NewDefaultConfig() *DiagramConfig

NewDefaultConfig creates a DiagramConfig with sensible defaults.

func (*DiagramConfig) Validate

func (c *DiagramConfig) Validate() error

Validate checks if the configuration is valid.

type Direction

type Direction string

Direction controls the graph layout direction.

const (
	DirectionTB Direction = "TB" // Top to Bottom (default)
	DirectionLR Direction = "LR" // Left to Right
	DirectionBT Direction = "BT" // Bottom to Top
	DirectionRL Direction = "RL" // Right to Left
)

func (Direction) IsValid

func (d Direction) IsValid() bool

IsValid checks if the direction is a valid DOT rankdir value.

func (Direction) String

func (d Direction) String() string

String returns the direction as a string.

type Generator

type Generator struct {
	// contains filtered or unexported fields
}

Generator generates DOT format output from workflow definitions.

func NewGenerator

func NewGenerator(config *DiagramConfig) *Generator

NewGenerator creates a new DOT generator with the given configuration.

func (*Generator) Generate

func (g *Generator) Generate(wf *workflow.Workflow) string

Generate produces a DOT format string from the workflow.

type NodeStyle

type NodeStyle struct {
	Shape     string // DOT shape: box, diamond, oval, hexagon, box3d, folder
	Color     string // border color
	FillColor string // background color
	Style     string // DOT style: filled, dashed, bold, etc.
}

NodeStyle defines visual style for step nodes in the diagram.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL