render

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: May 24, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package render provides diagram rendering for capability stacks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RenderD2

func RenderD2(w io.Writer, doc *capstack.CapabilityStack, opts D2Options) error

RenderD2 generates a D2 diagram from a CapabilityStack.

func RenderD2String

func RenderD2String(doc *capstack.CapabilityStack, opts D2Options) (string, error)

RenderD2String is a convenience function that returns the D2 diagram as a string.

func RenderHTML

func RenderHTML(w io.Writer, doc *capstack.CapabilityStack, opts HTMLOptions) error

RenderHTML generates static HTML from a CapabilityStack.

func RenderHTMLString

func RenderHTMLString(doc *capstack.CapabilityStack, opts HTMLOptions) (string, error)

RenderHTMLString is a convenience function that returns HTML as a string.

Types

type CapabilityOverlay added in v0.4.0

type CapabilityOverlay struct {
	// BadgeText is displayed as a badge on the capability (e.g., "M3.5", "L2").
	BadgeText string

	// BadgeColor is the background color for the badge (e.g., "#3b82f6").
	// If empty, a default color based on the badge content may be used.
	BadgeColor string

	// BadgeTextColor is the text color for the badge.
	// If empty, white or black is chosen based on BadgeColor contrast.
	BadgeTextColor string

	// TooltipExtra is additional text appended to the capability's tooltip.
	TooltipExtra string
}

CapabilityOverlay provides additional display data for a capability. This allows external modules (like prism-maturity) to inject supplemental information without creating tight coupling.

type D2Options

type D2Options struct {
	// Title shown at the top of the diagram.
	Title string

	// Style controls the overall rendering approach.
	Style D2Style

	// ShowDependencies renders dependency arrows between capabilities.
	// Ignored when Style is D2StyleGrid.
	ShowDependencies bool

	// ShowFoundational includes foundational capabilities in a separate section.
	ShowFoundational bool

	// ShowLegend displays the status color legend.
	ShowLegend bool

	// ColorByStatus uses status-based colors instead of category colors.
	ColorByStatus bool

	// Direction sets the layout direction ("down" or "right").
	Direction string

	// GridColumns sets the number of columns per layer row (0 = auto).
	// Only used when Style is D2StyleGrid.
	GridColumns int

	// Overlays provides additional display data (badges, tooltips) for capabilities.
	// This allows external modules to inject data like maturity levels.
	Overlays OverlayProvider
}

D2Options configures D2 diagram generation.

func DefaultD2Options

func DefaultD2Options() D2Options

DefaultD2Options returns sensible defaults for D2 rendering.

func GridD2Options

func GridD2Options() D2Options

GridD2Options returns options optimized for executive grid view.

type D2Style

type D2Style string

D2Style defines the rendering style for D2 diagrams.

const (
	// D2StyleDefault renders with dependency arrows and detailed layout.
	D2StyleDefault D2Style = "default"

	// D2StyleGrid renders a clean grid layout suitable for executives.
	// No dependency arrows, capabilities aligned in grid within layers.
	D2StyleGrid D2Style = "grid"
)

type HTMLOptions

type HTMLOptions struct {
	// Title overrides the document title.
	Title string

	// ShowLegend displays the status color legend.
	ShowLegend bool

	// ShowFoundational includes foundational capabilities.
	ShowFoundational bool

	// Standalone generates a complete HTML document (vs. embeddable fragment).
	Standalone bool

	// DarkTheme uses dark color scheme.
	DarkTheme bool

	// Overlays provides additional display data (badges, tooltips) for capabilities.
	// This allows external modules to inject data like maturity levels.
	Overlays OverlayProvider
}

HTMLOptions configures static HTML rendering.

func DefaultHTMLOptions

func DefaultHTMLOptions() HTMLOptions

DefaultHTMLOptions returns sensible defaults for HTML rendering.

type OverlayProvider added in v0.4.0

type OverlayProvider map[string]CapabilityOverlay

OverlayProvider maps capability IDs to their overlay data. This is the primary interface for injecting external data into renderers.

func (OverlayProvider) Get added in v0.4.0

func (op OverlayProvider) Get(capabilityID string) CapabilityOverlay

Get returns the overlay for a capability ID, or an empty overlay if not found.

func (OverlayProvider) Has added in v0.4.0

func (op OverlayProvider) Has(capabilityID string) bool

Has returns true if an overlay exists for the given capability ID.

Jump to

Keyboard shortcuts

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