aboutsummaryrefslogtreecommitdiffstats
path: root/api/mkapihtml
blob: c9da31dbc25c7c9ddcb0cc067db10f862b63899d (plain)
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
#/bin/sh
set -e

f="$1"
test -f "$f"

t="$(mktemp)"

y2j() {
 python -c 'import sys, yaml, json; y=yaml.load(sys.stdin.read()); print(json.dumps(y))'
}

sed 's%[$]\(/[^ \t]*\)%{ $ref: "#\1" }%' "$f" | \
 y2j | \
 afb-exprefs |
 jq . > "$t"

h="$(mktemp)"
cat << EOC > "$h"
<html>
<body>
<h1>Documentation of {{api.name}}</h1>

<h2>{{info.title}}</h2>

{{info.description}}

{{#info}}
<table>
<tr><td>Version:</td><td>{{version}}</td></tr>
<tr><td>Author:</td><td>{{author}}</td></tr>
<tr><td>Maintainer:</td><td>{{maintainer}}</td></tr>
<tr><td>Site:</td><td>{{homepage}}</td></tr>
</table>
{{/info}}

<h2>Verbs</h2>

<ul>
{{#api.verbs.*}} <li><a href="#verb-{{*}}">{{*}}</a></li>
{{/api.verbs.*}}
</ul>

{{#api.events}}
<h2>Events</h2>
<ul>
{{#*}} <li><a href="#event-{{*}}">{{*}}</a></li>
{{/*}}
</ul>
{{/api.events}}

{{#api.state-machines}}
<h2>Events</h2>
<ul>
{{#*}} <li><a href="#SM-{{*}}">{{*}}</a></li>
{{/*}}
</ul>
{{/api.state-machines}}

{{#api.verbs.*}}
<a id="verb-{{*}}"></a><h2>Verb {{*}}</h2>

<p>{{description}}</p>

<p><b>request:</b> {{request}}</p>

{{#reply.*}}
<p><b>reply {{*}}:</b> {{.}}</p>
{{/reply.*}}

{{/api.verbs.*}}

{{#api.events.*}}
<a id="event-{{*}}"></a><h2>Event {{*}}</h2>
{{/api.events.*}}

{{#api.state-machines.*}}
<a id="SM-{{*}}"></a><h2>State Machine {{*}}</h2>
{{/api.state-machines.*}}


EOC

mustach "$t" "$h"
rm "$t" "$h"