-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathshow_graph.go
38 lines (32 loc) · 976 Bytes
/
show_graph.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
package main
import (
"fmt"
"strings"
)
func resolveRelativeUrl(maybeRelative string, original string) string {
url := maybeRelative
if strings.Index(url, "#") == 0 {
url = original + url
}
return url
}
func printConnections(s *Stage) {
for _, r := range s.Requires {
url := resolveRelativeUrl(r.CitedInURL, s.DefinitionURL)
fmt.Printf(` "%s"->"%s" [xlabel="requires", URL="%s"]`+"\n", s.id, r.stage.id, url)
}
}
// ShowGraph prints the map as a directed graph in Grapviz DOT format to stdout
func ShowGraph(m *JourneyMap) {
fmt.Println("digraph G {")
fmt.Println(" splines=polyline;")
fmt.Println(` node [shape="box" style="rounded" fontname="Roboto" fontsize="14" margin="0.15,0.10" height="0"];`)
fmt.Println(` edge [fontname="Roboto" fontsize="12"];`)
for _, s := range m.stages {
fmt.Println()
fmt.Printf(` "%s" [label="%s", URL="%s"];`, s.id, s.DisplayName, s.DefinitionURL)
fmt.Println()
printConnections(s)
}
fmt.Println("}")
}