Documentation
¶
Overview ¶
Package dot2svg renders a practical subset of the Graphviz DOT language to SVG — in pure Go, via go-mermaid — for tools that emit DOT but don't want to depend on the native Graphviz binary: `terraform graph`, `go tool pprof -dot`, `make2graph`, and similar.
svg, err := dot2svg.Render(dotSource)
DOT is parsed into a graph model, translated into Mermaid flowchart source, and handed to mermaid.Render. Supported DOT: digraph/graph, node and edge statements (including A -> B -> C chains), default `node [...]`/`edge [...]` attributes, `rankdir`, and subgraphs/clusters (rendered as Mermaid subgraphs). This is deliberately not full Graphviz fidelity — record shapes, HTML-like labels, and Graphviz's own layout algorithm are out of scope; go-mermaid's Sugiyama layout lays the graph out instead, so the result won't be pixel-identical to `dot`.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Render ¶
Render parses a DOT source document and renders it straight to SVG via go-mermaid. opts are passed through to mermaid.Render (theme, padding, spacing, ...).
Types ¶
type Cluster ¶
type Cluster struct {
// ID is the subgraph's name as written (e.g. "cluster_0"), or a
// generated "cluster1", "cluster2", ... for anonymous subgraphs.
ID string
// Title is the subgraph's `label` attribute if set, otherwise ID.
Title string
}
Cluster is a subgraph that contains at least one node.
type Graph ¶
type Graph struct {
// Directed is true for `digraph`, false for `graph`.
Directed bool
// RankDir is the graph's `rankdir` attribute (TB, LR, RL, BT),
// defaulting to TB as Graphviz does.
RankDir string
Nodes []Node
Edges []Edge
Clusters []Cluster
}
Graph is the graph extracted from a DOT source. Nodes, Edges, and Clusters are in first-seen order.
type Node ¶
type Node struct {
// Key is the node's identifier as written (unescaped, but otherwise
// verbatim — may contain spaces or punctuation if it was quoted).
Key string
// Label is the display text: the node's `label` attribute if set,
// otherwise Key.
Label string
// Shape is the Graphviz `shape` attribute, lowercased; empty if unset.
Shape string
// Cluster is the ID of the subgraph this node was declared in; empty
// if the node is at the top level.
Cluster string
}
Node is one node declared in the DOT source.
Directories
¶
| Path | Synopsis |
|---|---|
|
cmd
|
|
|
dot2svg
command
Command dot2svg renders a Graphviz DOT graph to SVG (or Mermaid source, or PNG) without depending on the native Graphviz binary.
|
Command dot2svg renders a Graphviz DOT graph to SVG (or Mermaid source, or PNG) without depending on the native Graphviz binary. |