blob: 6a59426534c870631d04592c476d86c5686300f0 (
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
27
28
29
30
31
32
33
34
35
36
37
38
|
#!/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=""
tot_ntests=0
tot_ndefs=0
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")
ndefs=$(grep -cP "^[^:# \t]" "$file" || true)
ntests=$(grep -cP "^:test" "$file" || true)
if [ "$ndefs" = 0 ]; then
stats="<span class='stats'>(alias)</span>"
else
stats="<span class='stats'>($ndefs definitions, $ntests tests)</span>"
fi
links="$links\n<li><span class='com'>:import</span> <a href=$filename.html>$(basename "$name" .bruijn)</a> $stats</li>"
awk 'NR==FNR { gsub("<", "\\<", $0); gsub(">", "\\>", $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" -e "s@INFO@@g" "std/$filename.html"
tot_ndefs=$((tot_ndefs + ndefs))
tot_ntests=$((tot_ntests + ntests))
done
sed -e "s@STATS@Total: $tot_ndefs definitions, $tot_ntests tests@g" -e "s@LINKS@$links@g" std.template >std/index.html
cp res/* code.js content.css index.css code.css std/
|