dot

package module
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2019 License: MIT Imports: 4 Imported by: 0

README

dot

Golang package for formatting graphs as dot-code. The package uses an external dot executable to generate SVG or PNG images.

You can set a custom dot exectuable during compilation using go build -ldflags "-X dot.Exe=/path/to/dot/exe".

Documentation

Overview

Package dot implements a simple interface to encode graphs/digraphs as dot files.

Index

Constants

View Source
const (
	RankDir     = "rankdir"
	LR          = "LR"
	RL          = "RL"
	TB          = "TB"
	BT          = "BT"
	Label       = "label"
	Peripheries = "peripheries"
)

Often used Configuration options.

View Source
const Exe = "/usr/bin/dot"

Exe defines the full path of the dot executable that will be used. Change this at compile time using `go build -ldflags "-X dot.Exe=/path/to/dot/exe"`.

Variables

This section is empty.

Functions

func Execute added in v0.2.0

func Execute(in io.Reader, out io.Writer, args ...string) error

Execute executes a dot command with the given arguments.

func ToPNG

func ToPNG(in io.Reader, out io.Writer) error

ToPNG formats the given dot input as PNG encoded image into the output. It is equivalent to `Execute(in, out, "-Tpng"`.

func ToSVG

func ToSVG(in io.Reader, out io.Writer) error

ToSVG formats the given dot input as SVG encoded image into the given output. It is equivalent to `Execute(in, out, "-Tsvg")`.

Types

type Encoder added in v0.1.4

type Encoder struct {
	Digraph bool // weather to use a graph or a digraph for the output
	// contains filtered or unexported fields
}

Encoder writes dot code into a writer.

func NewEncoder added in v0.1.4

func NewEncoder(out io.Writer) *Encoder

NewEncoder creates a new encoder that writes in the given writer.

func (*Encoder) Done added in v0.1.4

func (e *Encoder) Done() error

Done writes the last closing bracet into the writer.

func (*Encoder) EncodeEdge added in v0.2.0

func (e *Encoder) EncodeEdge(src, dest string, args ...interface{}) error

EncodeEdge encodes an edge from src id to dest id.

func (*Encoder) EncodeKeyVal added in v0.1.4

func (e *Encoder) EncodeKeyVal(key, val string) error

EncodeKeyVal encodes key = val.

func (*Encoder) EncodeNode added in v0.1.4

func (e *Encoder) EncodeNode(id string, args ...interface{}) error

EncodeNode encodes node id.

type HTML added in v0.2.1

type HTML string

HTML can be used to inject html encoded strings. E.g. EncodeEdge("edge", "label", HTML("<b>foo</b>").

Jump to

Keyboard shortcuts

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