diff options
Diffstat (limited to 'api/mkapihtml')
-rwxr-xr-x | api/mkapihtml | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/api/mkapihtml b/api/mkapihtml new file mode 100755 index 0000000..c9da31d --- /dev/null +++ b/api/mkapihtml @@ -0,0 +1,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" |