-
Notifications
You must be signed in to change notification settings - Fork 1
/
template.cue
174 lines (152 loc) · 6.19 KB
/
template.cue
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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
package c4
plantumlTemplate: """
@startuml {{if .title}}{{.title}}{{else}}MyDiagram{{end}}
!include https://raw.githubusercontent.com/plantuml-stdlib/C4-PlantUML/master/C4_Container.puml
!include https://raw.githubusercontent.com/owulveryck/PlantUML-icons-GCP/master/official/GCPCommon.puml
!include https://raw.githubusercontent.com/awslabs/aws-icons-for-plantuml/v14.0/dist/AWSCommon.puml
{{- range .Technologies.tech}}
{{- if .sprite }}
!include {{ .sprite.url }}
{{- end }}
{{- end }}
{{- if eq .layout "top-down"}}
LAYOUT_TOP_DOWN()
{{ else if eq .layout "left-right"}}
LAYOUT_LEFT_RIGHT()
{{ else if eq .layout "landscape"}}
LAYOUT_LANDSCAPE()
{{- end}}
{{- if .hideStereotype }}
HIDE_STEREOTYPE()
{{- end}}
/'Relation Tags'/
{{- if .relationTags}}{{template "RelationTags" .relationTags}}{{- end}}
/'Element Tags'/
{{- if .elementTags}}{{template "ElementTags" .elementTags}}{{- end}}
/'People'/
{{- if .Persons}}{{- template "Persons" .Persons -}} {{- end}}
/'Systems'/
{{- if .Systems}} {{template "Systems" .Systems}} {{end}}
/'SystemsExt'/
{{- if .SystemsExt}}{{template "SystemsExt" .SystemsExt}} {{end}}
/'Relations'/
{{- if .relations}}
{{- range .relations}}
{{template "Rel" . -}}
{{- end}}
{{- end}}
SHOW_LEGEND()
@enduml
""" + containerTemplatePuml + relTemplatePuml + personsTemplatePuml + systemsTemplatePuml + tagsTemplatePuml + systemsExtTemplatePuml + relationTagsTemplatePuml + elementTagsTemplatePuml
mermaidTemplate: """
C4Container
title {{if .title}}{{.title}}{{else}}MyDiagram{{end}}
{{- if .Persons}}{{- template "Persons" .Persons -}} {{- end}}
{{- if .Systems}} {{template "Systems" .Systems}} {{end}}
{{- if .SystemsExt}}{{template "SystemsExt" .SystemsExt}} {{end}}
""" + containerTemplatePuml + relTemplatePuml + personsTemplatePuml + systemsTemplateMermaid + tagsTemplatePuml + systemsExtTemplatePuml
systemsExtTemplatePuml: """
{{- define "SystemsExt"}}
{{- range .}}
System_Ext({{.id}},"{{.label}}"{{if .technology}},"{{.technology.name}}","{{.technology.sprite.id}}"{{end}}{{if .link}},$link="{{.link}}"{{end}}{{if .tags}},$tags="{{template "tags".tags}}"{{end}}){{if or .containers .systems}}{
{{- range .containers }}
{{template "Container" . -}}
{{- end }}
{{- if .systems}}
{{template "Systems" .systems -}}
{{- end }}
{{if .SystemsExt}}
{{template "SystemsExt" .SystemsExt}}
{{end}}
{{- range .relations}}
{{template "Rel" . -}}
{{- end}}
}
{{end -}}
{{end -}}
{{end -}}
"""
tagsTemplatePuml: """
{{define "tags"}}{{range .}}{{.id}}+{{end}} {{end}}
"""
systemsTemplatePuml: """
{{- define "Systems" }}
{{- range . }}
System{{if .isBoundary}}_Boundary{{end}}({{.id}},"{{.label}}"{{if .description}},"{{.desc}}"{{end}}{{if .technology}},{{if not .description}}"{{.technology.name}}",{{end}}"{{.technology.sprite.id}}"{{end}}{{if .link}},$link="{{.link}}"{{end}}{{if .tags}},$tags="{{template "tags".tags}}"{{end}}){{ if or .containers .systems}} {
{{- range .containers }}
{{ template "Container" . -}}
{{- end }}
{{- if .systems }}
{{- template "Systems" .systems -}}
{{- end }}
{{- range .relations }}
{{template "Rel" . -}}
{{- end }}
}
{{- end}}
{{- end}}
{{- end}}
"""
systemsTemplateMermaid: """
{{- define "Systems" }}
{{- range . }}
System{{if or .containers .systems }}_Boundary{{end}}({{.id}},"{{.label}}"{{if .description}},"{{.desc}}"{{end}}{{if .technology}},{{if not .description}}"{{.technology.name}}",{{end}}"{{.technology.sprite.id}}"{{end}}{{if .link}},$link="{{.link}}"{{end}}{{if .tags}},$tags="{{template "tags".tags}}"{{end}}){{ if or .containers .systems}} {
{{- range .containers }}
{{ template "Container" . -}}
{{- end }}
{{- if .systems }}
{{- template "Systems" .systems -}}
{{- end }}
{{- range .relations }}
{{template "Rel" . -}}
{{- end }}
}
{{- end}}
{{- end}}
{{- end}}
"""
personsTemplatePuml: """
{{ define "Persons"}}{{- range .}}
Person({{.id}},"{{.label}}")
{{- end }}{{ end }}
"""
relTemplatePuml: """
{{ define "Rel"}}Rel("{{.source.id}}","{{.dest.id}}","{{.desc}}"{{if .protocol}},"{{.protocol}}"{{end}}{{if .link}},$link="{{.link}}"{{end}}{{if .tags}},$tags="{{template "tags".tags}}"{{end}}){{ end}}
"""
containerTemplatePuml: """
{{ define "Container" }}Container{{.technology.type}}({{.id}},"{{.label}}","{{.technology.name}}","{{if .description}}{{.desc}}{{end}}"{{if .technology.sprite}},"{{.technology.sprite.id}}"{{end}}{{if .link}},$link="{{.link}}"{{end}}{{if .tags}},$tags="{{template "tags".tags}}"{{end}}) {{ end }}
"""
relationTagsTemplatePuml: """
{{- define "RelationTags"}}
{{- range .a.tags}}
AddRelTag("{{.id}}"
{{- if .textColor}},$textColor="{{.textColor}}"{{end -}}
{{- if .lineColor}},$lineColor="{{.lineColor}}"{{ end -}}
{{- if .lineStyle}},$lineStyle={{if eq .lineStyle "dot"}}DottedLine(){{end}}{{if eq .lineStyle "dash"}}DashedLine(){{end}}{{if eq .lineStyle "bold"}}BoldLine(){{end}}{{ end -}}
{{- if .legendText}},$legendText="{{.legendText}}"{{ end -}}
{{- if .technology}},$techn="{{.technology.name}}",$sprite="{{.technology.sprite.id}}"{{ end -}})
{{- end}}
{{- range .b.tags}}
AddRelTag("{{.id}}"
{{- if .textColor}},$textColor="{{.textColor}}"{{end -}}
{{- if .lineColor}},$lineColor="{{.lineColor}}"{{ end -}}
{{- if .lineStyle}},$lineStyle={{if eq .lineStyle "dot"}}DottedLine(){{end}}{{if eq .lineStyle "dash"}}DashedLine(){{end}}{{if eq .lineStyle "bold"}}BoldLine(){{end}}{{ end -}}
{{- if .legendText}},$legendText="{{.legendText}}"{{ end -}}
{{- if .technology}},$techn="{{.technology.name}}",$sprite="{{.technology.sprite.id}}"{{ end -}})
{{- end}}
{{- end}}
"""
elementTagsTemplatePuml: """
{{- define "ElementTags"}}
{{- range .tags}}
AddElementTag("{{.id}}"
{{- if .bgColor}},$bgColor="{{.bgColor}}"{{end -}}
{{- if .borderColor}},$borderColor="{{.borderColor}}"{{ end -}}
{{- if .shadowing}},$shadowing="{{.shadowing}}"{{ end -}}
{{- if .shape}},$shape="{{if eq .shape "rounded"}}RoundedBoxShape(){{end}}{{if eq .shape "eightsided"}}EightSidedShape(){{end}}"{{ end -}}
{{- if .fontColor}},$fontColor="{{.fontColor}}"{{ end -}}
{{- if .legendText}},$legendText="{{.legendText}}"{{ end -}}
{{- if .technology}},$techn="{{.technology.name}}",$sprite="{{.technology.sprite.id}}"{{ end -}})
{{- end}}
{{- end}}
"""