aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorMarvin Borner2024-03-23 13:51:57 +0100
committerMarvin Borner2024-03-23 14:04:21 +0100
commitfc9980e5e19602748b8cc596cdd07c02ac2889f1 (patch)
tree2ad9d2c0b912fb6429f18161af1bff19b9e72edf
parentfd75e9dd97c8fb8672ba609fe4003a3865391c09 (diff)
Added very scientific std stats
-rwxr-xr-xdocs/genstd.sh11
-rw-r--r--docs/index.css14
-rw-r--r--docs/std.template2
3 files changed, 25 insertions, 2 deletions
diff --git a/docs/genstd.sh b/docs/genstd.sh
index df585ea..e290063 100755
--- a/docs/genstd.sh
+++ b/docs/genstd.sh
@@ -7,6 +7,8 @@ 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")
@@ -16,11 +18,16 @@ for file in $files; do
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>"
+ ndefs=$(grep -cP "^[^:# \t]" "$file" || true)
+ ntests=$(grep -cP "^:test" "$file" || true)
+ links="$links\n<li><span class='com'>:import</span> <a href=$filename.html>$(basename "$name" .bruijn)</a> <span class='stats'>($ndefs definitions, $ntests tests)</span></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"
+
+ tot_ndefs=$((tot_ndefs + ndefs))
+ tot_ntests=$((tot_ntests + ntests))
done
-sed -e "s@LINKS@$links@g" std.template >std/index.html
+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/
diff --git a/docs/index.css b/docs/index.css
index e28f004..adfd509 100644
--- a/docs/index.css
+++ b/docs/index.css
@@ -14,6 +14,20 @@ a {
color: #cccccc;
}
+ol {
+ max-width: 500px;
+}
+
+.stats {
+ float: right;
+}
+
.com {
color: #ff64bd;
}
+
+@media (max-width: 800px) {
+ .stats {
+ display: none;
+ }
+}
diff --git a/docs/std.template b/docs/std.template
index c33f5db..3a4bbcf 100644
--- a/docs/std.template
+++ b/docs/std.template
@@ -12,5 +12,7 @@ This is the browsable standard library of the bruijn programming language. Follo
<ol>
LINKS
</ol>
+ <hr>
+ <h2>STATS</h2>
</body>
</html>