Skip to content

package graphprint

import "github.com/cloudboss/unobin/pkg/graphprint"

Package graphprint renders a runtime DAG as either a human-readable indented listing or a Graphviz DOT document. Both unobin's stack binaries (via pkg/runner) and the dev CLI (cmd/unobin/root/print-graph) share these renderers so the two paths produce identical output for the same graph.

Functions

func DOT

func DOT(out io.Writer, dag *runtime.DAG, name string)

DOT writes the DAG to out as a Graphviz directed graph named name. Edges to non-node addresses (like `input.X`) are skipped so the rendered graph contains only nodes the runtime actually executes.

func Text

func Text(out io.Writer, dag *runtime.DAG)

Text writes the DAG to out as an indented listing: one node per stanza, with each outgoing edge prefixed by "->". Addresses are sorted lexicographically so the output is stable across runs.

Types

type Binding

type Binding struct {
    LibraryPath *string `json:"library-path" ub:"library-path"`
    Alias       string  `json:"alias"        ub:"alias"`
    Export      string  `json:"export"       ub:"export"`
}

type Document

type Document struct {
    Kind          string                  `json:"kind"           ub:"kind"`
    FormatVersion int                     `json:"format-version" ub:"format-version"`
    Name          string                  `json:"name"           ub:"name"`
    Nodes         []Node                  `json:"nodes"          ub:"nodes"`
    Edges         []Edge                  `json:"edges"          ub:"edges"`
    Diagnostics   []diagnostic.Diagnostic `json:"diagnostics"    ub:"diagnostics"`
}

func BuildDocument

func BuildDocument(
    dag *runtime.DAG,
    name string,
    diagnostics []diagnostic.Diagnostic,
) Document

type Edge

type Edge struct {
    From string `json:"from" ub:"from"`
    To   string `json:"to"   ub:"to"`
}

type Format

type Format string

func ParseFormat

func ParseFormat(value string) (Format, error)

func (Format) Machine

func (f Format) Machine() bool

type Node

type Node struct {
    Address   string   `json:"address"   ub:"address"`
    Category  string   `json:"category"  ub:"category"`
    Binding   *Binding `json:"binding"   ub:"binding"`
    Composite bool     `json:"composite" ub:"composite"`
}