aboutsummaryrefslogtreecommitdiffhomepage
path: root/docs/genstd.sh
blob: df585ea95e61f740cc08de066fa3a7f77b4df866 (plain) (blame)
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
#!/bin/env bash

set -e

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

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

prefix="seeelefant"
for file in $files; do
	name=$(cut -c8- <<<"$file")
	_prefix=$(cut -c8- <<<"$file" | sed -rn 's@^(.*)/.*$@\1@p')
	if ! [ "$prefix" = "$_prefix" ]; then
		prefix=$_prefix
		links="$links\n</ol><h2>std/$prefix</h2><ol>"
	fi
	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" std.template >std/index.html

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