/
template.go
62 lines (54 loc) · 1.55 KB
/
template.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
package pkg
const tmplLegend = `{{define "legend" -}}
subgraph cluster_legend {
label = "Legend";
graph [shape=box, fontsize=25]
node [shape="box"]
process:8080->socket [color=darkgreen, label="socket connection", dir="both"]
process:8080->ip_port [color=blue, label="connection to ip", dir="both"]
process:p ->child_pid [color=red, label="process hierarchy"]
process [label="executable | <p> pid, e.g. 23333 | <8080> colon port, e.g. :8080", shape=record]
}
{{- end}}`
const tmplCluster = `{{define "cluster" -}}
{{printf "subgraph %q {" .}}
{{printf "%s" .Attrs.Lines}}
{{range .Nodes}}
{{template "node" .}}
{{- end}}
{{range .Clusters}}
{{template "cluster" .}}
{{- end}}
{{println "}" }}
{{- end}}`
const tmplEdge = `{{define "edge" -}}
{{printf "%s" .}}
{{- end}}`
const tmplNode = `{{define "node" -}}
{{printf "%s" .}}
{{- end}}`
const tmplGraph = `digraph pstopo {
graph [
label="{{.Title}}";
labeljust="t";
labelloc=t;
fontname="Arial";
fontsize="25";
// rankdir="{{.Options.rankdir}}";
rankdir="LR";
bgcolor="lightgray";
style="solid";
penwidth="0.5";
pad="0.0";
]
// nodesep="{{.Options.nodesep}}";
// node [shape="{{.Options.nodeshape}}" style="{{.Options.nodestyle}}" fillcolor="honeydew" fontname="Verdana" penwidth="1.0" margin="0.05,0.0"];
// edge [minlen="{{.Options.minlen}}"]
{{template "legend" .}}
{{range .Nodes}}
{{template "node" .}}
{{- end}}
{{- range .Edges}}
{{template "edge" .}}
{{- end}}
}`