diff options
Diffstat (limited to 'docs')
-rw-r--r-- | docs/content.template | 2 | ||||
-rwxr-xr-x | docs/gensamples.sh | 15 | ||||
-rwxr-xr-x | docs/genstd.sh | 2 |
3 files changed, 16 insertions, 3 deletions
diff --git a/docs/content.template b/docs/content.template index 470acb4..57cbd47 100644 --- a/docs/content.template +++ b/docs/content.template @@ -8,7 +8,7 @@ <title>bruijn std/NAME</title> </head> <body> - <h1>NAME</h1> + <h1>NAME</h1> INFO <pre> <code class="language-bruijn"> CONTENT diff --git a/docs/gensamples.sh b/docs/gensamples.sh index 1734e0a..174d28d 100755 --- a/docs/gensamples.sh +++ b/docs/gensamples.sh @@ -17,8 +17,21 @@ for file in $files; do fi filename=$(sed s@/@_@g <<<"$name") links="$links\n<li><a href="$filename.html">$name</a></li>" + + if [ "$prefix" = "euler" ]; then + info="<a href='https://projecteuler.net/problem=$(basename "$name" .bruijn)'>Problem description</a>" + elif [ "$prefix" = "aoc" ]; then + year=$(cut -c5-8 <<<"$name") + day=$(cut -c10-11 <<<"$name" | sed 's/^0*//') + info="<a href='https://adventofcode.com/$year/day/$day'>Problem description</a>" + elif [ "$prefix" = "rosetta" ]; then + info="<a href='https://rosettacode.org/wiki/$(basename "$name" .bruijn)'>Problem description</a>" + else + info="" + fi + 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 >"samples/$filename.html" - sed -i -e "s@NAME@$name@g" "samples/$filename.html" + sed -i -e "s@NAME@$name@g" -e "s@INFO@$info@g" "samples/$filename.html" done sed -e "s@LINKS@$links@g" samples.template >samples/index.html diff --git a/docs/genstd.sh b/docs/genstd.sh index e290063..f2c0dd4 100755 --- a/docs/genstd.sh +++ b/docs/genstd.sh @@ -22,7 +22,7 @@ for file in $files; do 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("<", "\\<", $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" "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)) |