-
Notifications
You must be signed in to change notification settings - Fork 7
/
markdown-template.go
131 lines (100 loc) · 3.48 KB
/
markdown-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
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
// markdown-template.go: the markdown template used to template the sysl module
package catalog
const NewProjectTemplate = `
{{range $name, $link := .Links}}
[{{$name}}]({{$link}})
{{end}}
# {{Base .Title}}
| Package |
----|{{range $key, $val := GetRows .Module}}
[{{$val}}]({{$val}}/README.md)|{{end}}
## Integration Diagram
<img src="{{CreateIntegrationDiagram .Module .Title false}}">
## End Point Analysis Integration Diagram
<img src="{{CreateIntegrationDiagram .Module .Title true}}">
`
const NewPackageTemplate = `
[Back](../README.md)
{{$packageName := ModulePackageName .}}
# {{$packageName}}
## Service Index
| Service Name | Method |
----|----{{$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}}
{{$appName}} | [{{$endpoint.Name}}](#{{$appName}}-{{SanitiseOutputName $endpoint.Name}}){{end}}{{end}}{{end}}{{end}}
![]({{CreateIntegrationDiagram . $packageName false}})
{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}
{{if eq (hasPattern $app.Attrs "ignore") false}}
{{if ne $appName $packageName}}
# {{$appName}}{{end}}
{{Attribute $app "description"}}
{{range $e := $app.Endpoints}}
{{if eq (hasPattern $e.Attrs "ignore") false}}
## {{$appName}} {{SanitiseOutputName $e.Name}}
{{Attribute $e "description"}}
![]({{CreateSequenceDiagram $appName $e}})
### Request types
{{if eq (len $e.Param) 0}}
No Request types
{{end}}
{{range $param := $e.Param}}
{{Attribute $param.Type "description"}}
![]({{CreateParamDataModel $app $param}})
{{end}}
{{if $e.RestParams}}{{if $e.RestParams.UrlParam}}
{{range $param := $e.RestParams.UrlParam}}
{{$PathDataModel := (CreatePathParamDataModel $appName $param)}}
{{if ne $PathDataModel ""}}
### Path Parameter
![]({{CreatePathParamDataModel $appName $param}})
{{end}}{{end}}{{end}}
{{if $e.RestParams.QueryParam}}
{{range $param := $e.RestParams.QueryParam}}
{{$queryDataModel := (CreateQueryParamDataModel $appName $param)}}
{{if ne $queryDataModel ""}}
### Query Parameter
![]({{$queryDataModel}})
{{end}}{{end}}{{end}}{{end}}
### Response types
{{$responses := false}}
{{range $s := $e.Stmt}}{{$diagram := CreateReturnDataModel $s $e}}{{if ne $diagram ""}}
{{$responses = true}}
{{$ret := (GetReturnType $e $s)}}{{if $ret }}
{{Attribute $ret "description"}}{{end}}
![]({{$diagram}})
{{end}}{{end}}
{{if eq $responses false}}
No Response Types
{{end}}{{end}}{{end}}{{end}}{{end}}
{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}
{{if hasPattern $app.GetAttrs "db"}}
## Database
{{Attribute $app "description"}}
![]({{GenerateDataModel $app}})
{{end}}{{end}}
### Types
<table>
<tr>
<th>App Name</th>
<th>Diagram</th>
<th>Description</th>
<th>Full Diagram</th>
{{range $appName := SortedKeys .Apps}}{{$app := index $Apps $appName}}{{$types := $app.Types}}
{{if ne (hasPattern $app.Attrs "db") true}}
</tr>
{{range $typeName := SortedKeys $types}}{{$type := index $types $typeName}}
<tr>
<td>
{{$appName}}.<br>{{$typeName}}
</td>
<td>
<img src="{{CreateTypeDiagram $app $typeName $type false}}">
</td>
<td>
{{if ne (Attribute $type "description") ""}}<details closed><summary>Attribute</summary><br>{{Attribute $type "description"}}</details>{{end}}
</td>
<td>
<a href="{{CreateTypeDiagram $app $typeName $type true}}">Link</a>
</td>
</tr>{{end}}{{end}}{{end}}
</table>
`