-
Notifications
You must be signed in to change notification settings - Fork 7
/
template_plantuml.go
224 lines (159 loc) · 6.89 KB
/
template_plantuml.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
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
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
// markdown-template.go: the markdown template used to template the sysl module
package catalog
const ProjectTemplate = `
{{/* Automatically generated by https://github.com/anz-bank/sysl-catalog it is strongly recommended not to edit this file */}}
{{range $name, $link := .Links}} [{{$name}}]({{$link}}) | {{end}}
# {{Base .Title}}
| Package |
----|{{range $val := Packages .Module}}
[{{$val}}]({{$val}}/README.md)|{{end}}
## Integration Diagram
<img src="{{IntegrationPlantuml .Module .Title false}}">
## End Point Analysis Integration Diagram
<img src="{{IntegrationPlantuml .Module .Title true}}">
`
const MacroPackageProject = `
{{/* Automatically generated by https://github.com/anz-bank/sysl-catalog it is strongly recommended not to edit this file */}}
# {{Base .Title}}
| Package |
----|{{if .Module}}{{range $val := MacroPackages .Module}}
[{{$val}}]({{$val}}/README.md)|{{end}}{{end}}
## Integration Diagram
<img src="{{if .Module}}{{IntegrationPlantuml .Module .Title false}}{{end}}">
## End Point Analysis Integration Diagram
<img src="{{if .Module}}{{IntegrationPlantuml .Module .Title true}}{{end}}">
`
const NewPackageTemplate = `
{{/* Automatically generated by https://github.com/anz-bank/sysl-catalog it is strongly recommended not to edit this file */}}
[Back](../README.md)
{{$packageName := ModulePackageName .}}
# {{$packageName}}
## Integration Diagram
![]({{IntegrationPlantuml . $packageName false}})
{{$Apps := .Apps}}
{{$databases := false}}
{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}{{if and (eq (hasPattern $app.Attrs "ignore") false) (eq (hasPattern $app.Attrs "db") true)}}
{{$databases = true}}
{{end}}{{end}}
{{if $databases}}
## Database Index
| Database Application Name | Source Location |
----|----{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}{{if and (eq (hasPattern $app.Attrs "ignore") false) (eq (hasPattern $app.Attrs "db") true)}}
[{{SanitiseOutputName $appName}}](#Database-{{$appName}}) | [{{SourcePath $app}}]({{SourcePath $app}})| {{end}}{{end}}
{{end}}
## Application Index
{{$anyApps := false}}
{{$Apps := .Apps}}{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}{{if eq (hasPattern $app.Attrs "ignore") false}}{{$Endpoints := $app.Endpoints}}{{range $endpointName := SortedKeys $Endpoints}}{{$endpoint := index $Endpoints $endpointName}}{{if eq (hasPattern $endpoint.Attrs "ignore") false}}{{if not $anyApps}}| Application Name | Method | Source Location |
|----|----|----|{{$anyApps = true}}{{end}}
| {{$appName}} | [{{$endpoint.Name}}](#{{SanitiseOutputName $appName}}-{{SanitiseOutputName $endpoint.Name}}) | [{{SourcePath $app}}]({{SourcePath $app}})| {{end}}{{end}}{{end}}{{end}}
{{if not $anyApps}}
<span style="color:grey">No Applications Defined</span>
{{end}}
## Type Index
{{$anyTypes := false}}
{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}{{$types := $app.Types}}{{if ne (hasPattern $app.Attrs "db") true}}{{range $typeName := SortedKeys $types}}{{$type := index $types $typeName}}{{if not $anyTypes}}| Application Name | Type Name | Source Location |
|----|----|----|{{$anyTypes = true}}{{end}}
| {{$appName}} | [{{$typeName}}](#{{SanitiseOutputName $appName}}.{{SanitiseOutputName $typeName}}) | [{{SourcePath $type}}]({{SourcePath $type}})|{{end}}{{end}}{{end}}
{{if not $anyTypes}}
<span style="color:grey">No Types Defined</span>
{{end}}
{{if $databases}}
# Databases
{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}
{{if hasPattern $app.GetAttrs "db"}}
<a name=Database-{{SanitiseOutputName $appName}}></a><details>
<summary>Database {{$appName}}</summary>
{{Attribute $app "description"}}
![]({{DataModelAppPlantuml $app}})
</details>
{{end}}{{end}}
{{end}}
{{if $anyApps}}
# Applications
{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}
{{if eq (hasPattern $app.Attrs "ignore") false}}
{{if eq (hasPattern $app.Attrs "db") false}}
{{if ne (len $app.Endpoints) 0}}
## Application {{$appName}}
{{$desc := Attribute $app "description"}}
{{if $desc}}
- {{$desc}}
{{end}}
{{ServiceMetadata $app}}
{{with CreateRedoc $app $appName}}
[View OpenAPI Specs in Redoc]({{CreateRedoc $app $appName}})
{{end}}
{{range $e := $app.Endpoints}}
{{if eq (hasPattern $e.Attrs "ignore") false}}
### <a name={{SanitiseOutputName $appName}}-{{SanitiseOutputName $e.Name}}></a>{{$appName}} {{$e.Name}}
{{Attribute $e "description"}}
<details>
<summary>Sequence Diagram</summary>
![]({{SequencePlantuml $appName $e}})
</details>
<details>
<summary>Request types</summary>
{{if and (not $e.Param) (not $e.RestParams) }}
<span style="color:grey">No Request types</span>
{{end}}
{{if not $e.Param}}{{if $e.RestParams }}{{if not $e.RestParams.UrlParam}}
<span style="color:grey">No Request types</span>
{{end}}{{end}}{{end}}
{{range $param := $e.Param}}
{{Attribute $param.Type "description"}}
![]({{DataModelParamPlantuml $app $param}})
{{end}}
{{if $e.RestParams}}{{if $e.RestParams.UrlParam}}
{{range $param := $e.RestParams.UrlParam}}
{{$pathDataModel := (DataModelParamPlantuml $app $param)}}
{{if ne $pathDataModel ""}}
#### Path Parameter
![]({{$pathDataModel}})
{{end}}{{end}}{{end}}
{{if $e.RestParams.QueryParam}}
{{range $param := $e.RestParams.QueryParam}}
{{$queryDataModel := (DataModelParamPlantuml $app $param)}}
{{if ne $queryDataModel ""}}
#### Query Parameter
![]({{$queryDataModel}})
{{end}}{{end}}{{end}}{{end}}
</details>
<details>
<summary>Response types</summary>
{{$responses := false}}
{{range $s := $e.Stmt}}{{$diagram := DataModelReturnPlantuml $appName $s $e}}{{if ne $diagram ""}}
{{$responses = true}}
{{$ret := (GetReturnType $e $s)}}{{if $ret }}
{{Attribute $ret "description"}}{{end}}
![]({{$diagram}})
{{end}}{{end}}
{{if not $responses}}
<span style="color:grey">No Response Types</span>
{{end}}
</details>
{{end}}
---
{{end}}{{end}}{{end}}{{end}}{{end}}{{end}}
{{if $anyTypes}}
# Types
{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}{{$types := $app.Types}}
{{if ne (hasPattern $app.Attrs "db") true}}
{{range $typeName := SortedKeys $types}}{{$type := index $types $typeName}}
<a name={{SanitiseOutputName $appName}}.{{SanitiseOutputName $typeName}}></a><details>
<summary>{{$appName}}.{{$typeName}}</summary>
### {{$appName}}.{{$typeName}}
{{$typedesc := (Attribute $type "description")}}
{{if ne $typedesc ""}}- {{$typedesc}}{{end}}
![]({{DataModelPlantuml $appName $typeName $type false}})
[Full Diagram]({{DataModelPlantuml $appName $typeName $type true}})
{{if Fields $type}}
#### Fields
{{$fieldHeader := false}}
{{$fieldMap := Fields $type}}{{range $fieldName := SortedKeys $fieldMap}}{{$field := index $fieldMap $fieldName}}{{if not $fieldHeader}}| Field name | Type | Description |
|----|----|----|{{$fieldHeader = true}}{{end}}
| {{$fieldName}} | {{FieldType $field}} | {{$desc := Attribute $field "description"}}{{if ne $desc $typedesc}}{{$desc}}{{end}}|{{end}}
{{end}}
</details>{{end}}{{end}}{{end}}
{{end}}
<div class="footer">
`