| git.druid.rocks | index | druid520 | kaboom | mk/ | dh.sh |
mk/dh.sh
#!/bin/sh
set -e
# renders docs/*.btft (recursively, any subfolder included) into
# docs/html/, mirroring the relative path each source file has under
# docs/ -- run from the repo root, same as every other mk/*.sh (via
# "mk . dh" if the mk tool is installed, or plain "sh mk/dh.sh"/
# "make dh" otherwise).
docsdir="docs"
# resolved through PATH, same as mk.conf's cc="${CC:-cc}" -- never a
# hardcoded install location, so this works wherever btf2html actually
# is (a different PREFIX, a user-local install, anywhere on $PATH).
btf2html="${BTF2HTML:-btf2html}"
[ -f "$docsdir/style.btfs" ] || { echo "err: $docsdir/style.btfs missing." >&2; exit 1; }
command -v "$btf2html" >/dev/null 2>&1 || { echo "err: $btf2html not found on \$PATH (see git://git.druid.rocks/druid520/btf.git)." >&2; exit 1; }
rm -rf "$docsdir/html"
mkdir -p "$docsdir/html"
"$btf2html" -f -o "$docsdir/html" "$docsdir"
# btf2html only ever touches *.btft (and reads style.btfs to compile the
# inline <style> block) -- anything else a page actually references by
# url (keyframes.css, every [img src="...gif"]) has to be copied across
# by hand, or it 404s on the real deployed site even though it renders
# fine in any test that only ever pushes the .btft/.btfs sources
# themselves (exactly what happened here: three real [img] references
# shipped 404ing for a while because only keyframes.css ever got this
# treatment). an explicit positive list of real asset extensions, not
# "everything that isn't .btft" -- covers what's actually referenced
# today (css, gif) without needing a new line here per file, and never
# accidentally publishes a future non-asset file (docs/summary.txt,
# say) just for sitting in the same directory.
find "$docsdir" -maxdepth 1 -type f \( -name '*.css' -o -name '*.gif' \) -exec cp {} "$docsdir/html/" \;