render

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package render provides diagram renderers for PIDL protocols.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderString

func RenderString(format Format, p *pidl.Protocol) (string, error)

RenderString renders a protocol using the specified format.

Types

type DOTRenderer

type DOTRenderer struct {
	// Title includes the protocol name as graph label.
	Title bool

	// RankDir sets the graph direction (LR, TB, RL, BT).
	RankDir string

	// MergeEdges combines multiple flows between the same entities.
	MergeEdges bool

	// ShowPhases groups nodes by phase using subgraphs.
	ShowPhases bool
}

DOTRenderer renders PIDL protocols as Graphviz DOT data flow diagrams.

func NewDOT

func NewDOT() *DOTRenderer

NewDOT creates a new DOT renderer with default options.

func (*DOTRenderer) Format

func (r *DOTRenderer) Format() Format

Format returns the output format.

func (*DOTRenderer) Render

func (r *DOTRenderer) Render(w io.Writer, p *pidl.Protocol) error

Render writes the DOT diagram to the writer.

func (*DOTRenderer) RenderString

func (r *DOTRenderer) RenderString(p *pidl.Protocol) (string, error)

RenderString returns the DOT diagram as a string.

type Format

type Format string

Format represents a diagram output format.

const (
	FormatPlantUML Format = "plantuml"
	FormatMermaid  Format = "mermaid"
	FormatDOT      Format = "dot"
)

func MustParseFormat

func MustParseFormat(s string) Format

MustParseFormat parses a format string, panicking on error.

func ParseFormat

func ParseFormat(s string) (Format, error)

ParseFormat parses a format string, returning an error if invalid.

func SupportedFormats

func SupportedFormats() []Format

SupportedFormats returns all supported output formats.

func (Format) FileExtension

func (f Format) FileExtension() string

FileExtension returns the conventional file extension for this format.

func (Format) String

func (f Format) String() string

String returns the format as a string.

type MermaidRenderer

type MermaidRenderer struct {
	// Title includes the protocol name as diagram title.
	Title bool

	// Autonumber adds sequence numbers to messages.
	Autonumber bool
}

MermaidRenderer renders PIDL protocols as Mermaid sequence diagrams.

func NewMermaid

func NewMermaid() *MermaidRenderer

NewMermaid creates a new Mermaid renderer with default options.

func (*MermaidRenderer) Format

func (r *MermaidRenderer) Format() Format

Format returns the output format.

func (*MermaidRenderer) Render

func (r *MermaidRenderer) Render(w io.Writer, p *pidl.Protocol) error

Render writes the Mermaid diagram to the writer.

func (*MermaidRenderer) RenderString

func (r *MermaidRenderer) RenderString(p *pidl.Protocol) (string, error)

RenderString returns the Mermaid diagram as a string.

type PlantUMLRenderer

type PlantUMLRenderer struct {
	// Title includes the protocol name as diagram title.
	Title bool

	// ShowDescriptions includes flow descriptions as notes.
	ShowDescriptions bool
}

PlantUMLRenderer renders PIDL protocols as PlantUML sequence diagrams.

func NewPlantUML

func NewPlantUML() *PlantUMLRenderer

NewPlantUML creates a new PlantUML renderer with default options.

func (*PlantUMLRenderer) Format

func (r *PlantUMLRenderer) Format() Format

Format returns the output format.

func (*PlantUMLRenderer) Render

func (r *PlantUMLRenderer) Render(w io.Writer, p *pidl.Protocol) error

Render writes the PlantUML diagram to the writer.

func (*PlantUMLRenderer) RenderString

func (r *PlantUMLRenderer) RenderString(p *pidl.Protocol) (string, error)

RenderString returns the PlantUML diagram as a string.

type Renderer

type Renderer interface {
	// Render writes the diagram to the writer.
	Render(w io.Writer, p *pidl.Protocol) error

	// RenderString returns the diagram as a string.
	RenderString(p *pidl.Protocol) (string, error)

	// Format returns the output format name.
	Format() Format
}

Renderer generates diagram output from a Protocol.

func MustNew

func MustNew(format Format) Renderer

MustNew creates a Renderer for the specified format, panicking on error.

func New

func New(format Format) (Renderer, error)

New creates a Renderer for the specified format.

Jump to

Keyboard shortcuts

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