From 6ff75104e28d00535392ebeaf66e2e50c57d0d64 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Sun, 10 Mar 2024 16:27:07 +0100 Subject: Added sample page to website --- docs/.gitignore | 1 + docs/code.js | 15 +- docs/gen.sh | 23 +- docs/gensamples.sh | 26 ++ docs/genstd.sh | 20 ++ docs/index.html | 27 +- docs/index.template | 16 -- docs/samples.template | 16 ++ docs/std.template | 16 ++ docs/wiki_src/coding/examples.md | 3 +- docs/wiki_src/introduction/philosophy.md | 3 + samples/license.md | 414 +++++++++++++++++++++++++++++++ samples/readme.md | 14 +- 13 files changed, 531 insertions(+), 63 deletions(-) create mode 100755 docs/gensamples.sh create mode 100755 docs/genstd.sh delete mode 100644 docs/index.template create mode 100644 docs/samples.template create mode 100644 docs/std.template create mode 100644 samples/license.md diff --git a/docs/.gitignore b/docs/.gitignore index 7595ce4..3f8d565 100644 --- a/docs/.gitignore +++ b/docs/.gitignore @@ -1,2 +1,3 @@ std/ wiki/ +samples/ diff --git a/docs/code.js b/docs/code.js index 3364f6c..bfeaeb1 100644 --- a/docs/code.js +++ b/docs/code.js @@ -1,16 +1,19 @@ // high-quality syntax highlighter -// TODO: Implement actual highlighter (or fix many regex bugs) +// TODO: Implement actual parser (or fix MANY regex bugs) const term = (t) => t + .replaceAll( + /(?$1", + ) .replaceAll(/'(.)'/g, "'$1'") .replaceAll(/"([^\"]*)"/g, "\"$1\"") - .replaceAll(/(\([+-][0-9]+[ubt]?\))/g, "$1") + .replaceAll(/(\([+-][0-9]+[ubtd]?\))/g, "$1") .replaceAll(/(?)(\()/g, "(") .replaceAll(/(\))(?!\<)/g, ")") .replaceAll("[", "[") - .replaceAll("]", "]") - .replaceAll(/(?$1"); + .replaceAll("]", "]"); const highlightTerm = (elem) => { elem.innerHTML = term(elem.innerHTML); @@ -34,6 +37,10 @@ const highlight = (elem) => { p, )}.bruijn.html'>std/${p}`, ) + .replaceAll( + /^:import (.*) (.*)$/gm, + (_, p, s) => `:import ${p} ${s}`, + ) .replaceAll( /^:test (\(.*\)) (\(.*\))$/gm, (_, t1, t2) => `:test ${term(t1)} ${term(t2)}`, diff --git a/docs/gen.sh b/docs/gen.sh index 7b5eb72..eebfb20 100755 --- a/docs/gen.sh +++ b/docs/gen.sh @@ -1,25 +1,10 @@ #!/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
  • :import $name
  • " - awk 'NR==FNR { gsub("<", "\\<", $0); gsub(">", "\\>", $0); a[n++]=$0; next } /CONTENT/ { for (i=0;istd/$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/* code.js content.css index.css code.css std/ - +./genstd.sh echo "std done" +./gensamples.sh +echo "samples done" + mkdocs build echo "wiki done" diff --git a/docs/gensamples.sh b/docs/gensamples.sh new file mode 100755 index 0000000..704aea5 --- /dev/null +++ b/docs/gensamples.sh @@ -0,0 +1,26 @@ +#!/bin/env bash + +set -e + +rm -rf samples/ && mkdir -p samples/ + +files=$(find ../samples/ -type f -name "*.bruijn" -printf '%h\0%d\0%p\n' | sort -t '\0' -n | awk -F '\0' '{print $3}') +links="" + +prefix="" +for file in $files; do + name=$(echo "$file" | cut -c12-) + _prefix=$(cut -d/ -f1 <<<"$name") + if ! [ "$prefix" = "$_prefix" ]; then + prefix=$_prefix + links="$links\n

    $prefix