aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/gen.sh
blob: 5d295e7f9c47eebb17535f12b52c1211fe10abe8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/env bash

set -e

rm -rf std/ && mkdir -p std/

files=$(find ../std/ -type f -printf '%h\0%d\0%p\n' | sort -t '\0' -n | awk -F '\0' '{print $3}')
links=""

for file in $files; do
	name=$(echo $file | cut -c8-)
	filename=$(sed s@/@_@g <<<"$name")
	links="$links\n<li><span class='com'>:import</span> <a href="$filename.html">$name</a></li>"
	awk 'NR==FNR { gsub("<", "\\&lt;", $0); gsub(">", "\\&gt;", $0); a[n++]=$0; next } /CONTENT/ { for (i=0;i<n;++i) print a[i]; next } 1' "$file" content.template >std/$filename.html
	sed -i -e "s@NAME@$name@g" std/$filename.html
done

sed -e "s@LINKS@$links@g" index.template >std/index.html

cp res/* content.js content.css index.css std/