-
Notifications
You must be signed in to change notification settings - Fork 11
/
render-doc
executable file
·59 lines (46 loc) · 1.89 KB
/
render-doc
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
#! /usr/bin/env bash
for file in docs/doc_test/*.md
do
gotemplate -dP $file > ${file%.*}.razor
gotemplate -P $file > ${file%.*}.rendered --accept-no-value
done
DOC_FOLDER="docs"
export COLUMNS=1024
mkdir -p $DOC_FOLDER
# Generate function info
gotemplate '```text@<exec("gotemplate list --no-extension -c")```' > $DOC_FOLDER/_functions.md
# Generate usage info
COLUMNS=150 gotemplate '```text@<trim(exec("gotemplate -h"))@<;```' --nv > $DOC_FOLDER/_usage.md
# Generate methods on String objects
gotemplate '```go@<getMethods(String(""))@<;```' > $DOC_FOLDER/_string_methods.md
# Generate methods on StringArray objects
gotemplate '```go@<getMethods(String("").Split(""))@<;```' > $DOC_FOLDER/_string_array_methods.md
# Generate methods on List objects
gotemplate '```go@<@getMethods(list())@<;```' > $DOC_FOLDER/_list_methods.md
# Generate methods on Dictionary objects
gotemplate '```go@<@getMethods(dict())@<;```' > $DOC_FOLDER/_dict_methods.md
# Generate detailed function info
gotemplate --no-extension '{% include navigation.html %}
## Functions@<;
| @foreach ($category := categories())
@<;[@(String($category.Name).Split(",")[0])](#@(String($category.Name).Replace(" ", "-").ToLower());) |
@-end foreach
@foreach ($category := categories())
@-// We have to make a trick here by adding {{ "" }} otherwise, the entire line will be considered as a comment
### {{ "" }}@($category.Name)
@-foreach ($func := $category.Functions())
@{func} := function($func)
@-if (!$func.IsAlias)
@<;@<;```go
@-if ($func.Description)
@<;// @(String($func.Description).Lines.Join("\n// "))
@-endif
@-if ($func.Aliases)
@<;// Aliases: @join(", ", $func.Aliases)
@-endif
@<;func @($func.Signature)
@<;```
@-endif
@-end foreach
@-end foreach
' > $DOC_FOLDER/functions_long.md