render

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2026 License: MIT Imports: 6 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.

func RenderJSON added in v0.5.0

func RenderJSON(w io.Writer, doc *capstack.CapabilityStack, opts LitOptions) error

RenderJSON writes the capability stack as JSON for the Lit component.

func RenderJSONString added in v0.5.0

func RenderJSONString(doc *capstack.CapabilityStack, opts LitOptions) (string, error)

RenderJSONString returns the capability stack as a JSON string.

func RenderLitHTML added in v0.5.0

func RenderLitHTML(w io.Writer, doc *capstack.CapabilityStack, opts LitOptions) error

RenderLitHTML generates an HTML page that loads the Lit maturity-grid component.

func RenderLitHTMLString added in v0.5.0

func RenderLitHTMLString(doc *capstack.CapabilityStack, opts LitOptions) (string, error)

RenderLitHTMLString returns the Lit HTML page 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 LitCapability added in v0.5.0

type LitCapability struct {
	ID          string    `json:"id"`
	Name        string    `json:"name"`
	FullName    string    `json:"fullName,omitempty"`
	Description string    `json:"description,omitempty"`
	LayerID     string    `json:"layerId"`
	CategoryID  string    `json:"categoryId,omitempty"`
	Status      string    `json:"status"`
	Priority    string    `json:"priority,omitempty"`
	Importance  string    `json:"importance,omitempty"`
	Order       int       `json:"order,omitempty"`
	Owner       string    `json:"owner,omitempty"`
	Tooling     []LitTool `json:"tooling,omitempty"`
	Tags        []string  `json:"tags,omitempty"`
}

LitCapability represents a capability in the Lit component format.

type LitCategory added in v0.5.0

type LitCategory struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Order       int    `json:"order,omitempty"`
}

LitCategory represents a category in the Lit component format.

type LitGridData added in v0.5.0

type LitGridData struct {
	Title        string                 `json:"title,omitempty"`
	Layers       []LitLayer             `json:"layers"`
	Categories   []LitCategory          `json:"categories"`
	Capabilities []LitCapability        `json:"capabilities"`
	Maturity     map[string]LitMaturity `json:"maturity,omitempty"`
}

LitGridData is the JSON structure consumed by the maturity-grid Lit component. This matches the TypeScript MaturityGridData interface in prism/ui/src/types.ts.

func ToLitGridData added in v0.5.0

func ToLitGridData(doc *capstack.CapabilityStack, opts LitOptions) *LitGridData

ToLitGridData converts a CapabilityStack to LitGridData format.

type LitLayer added in v0.5.0

type LitLayer struct {
	ID          string `json:"id"`
	Name        string `json:"name"`
	Description string `json:"description,omitempty"`
	Order       int    `json:"order,omitempty"`
}

LitLayer represents a layer in the Lit component format.

type LitMaturity added in v0.5.0

type LitMaturity struct {
	CapabilityID string `json:"capabilityId"`
	Level        int    `json:"level"`
	SLICount     int    `json:"sliCount,omitempty"`
}

LitMaturity represents maturity data for a capability.

type LitOptions added in v0.5.0

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

	// Theme is "light" or "dark".
	Theme string

	// View is "by-layer" or "by-category".
	View string

	// ShowLegend displays the status/maturity filters.
	ShowLegend bool

	// ShowViewToggle displays the view mode toggle buttons.
	ShowViewToggle bool

	// ComponentPath is the path to the prism-ui.js component file.
	// Defaults to "prism-ui.js" (same directory as HTML).
	ComponentPath string

	// Overlays provides maturity data to include in the JSON.
	Overlays OverlayProvider
}

LitOptions configures Lit component HTML rendering.

func DefaultLitOptions added in v0.5.0

func DefaultLitOptions() LitOptions

DefaultLitOptions returns sensible defaults for Lit rendering.

type LitTool added in v0.5.0

type LitTool struct {
	Name   string `json:"name"`
	Type   string `json:"type,omitempty"`
	Status string `json:"status,omitempty"`
	URL    string `json:"url,omitempty"`
}

LitTool represents a tool in the Lit component format.

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