singe/build-docs.sh
2026-09-14 14:20:17 -05:00

36 lines
1.3 KiB
Bash
Executable file

#!/usr/bin/env bash
# Build the Singe manual from docs/Manual.adoc and the Forge manual from docs/Forge.adoc.
# Produces .builddir/Manual.html, Manual.pdf, Forge.html and Forge.pdf. The version comes from
# CMakeLists.txt.
set -euo pipefail
here=$(cd "$(dirname "$0")" && pwd)
src=$here/docs/Manual.adoc
forge=$here/docs/Forge.adoc
for doc in "$src" "$forge"; do
if [[ ! -f $doc ]]; then
echo "error: $doc not found" >&2
exit 1
fi
done
for tool in asciidoctor asciidoctor-pdf lua5.4; do
if ! command -v "$tool" > /dev/null; then
echo "error: $tool not found (gem install asciidoctor asciidoctor-pdf rouge)" >&2
exit 1
fi
done
version=$(sed -n 's/^project(singe2 VERSION \([0-9.]*\).*/\1/p' "$here/CMakeLists.txt")
out=$here/.builddir
mkdir -p "$out"
# The Forge vocabulary tables come from the manifest itself, so the manual cannot drift from it.
lua5.4 "$here/util/forgeVocabulary.lua" > "$here/docs/ForgeVocabulary.adoc"
asciidoctor -a revnumber="$version" "$src" -o "$out/Manual.html"
asciidoctor-pdf -a revnumber="$version" "$src" -o "$out/Manual.pdf"
asciidoctor -a revnumber="$version" "$forge" -o "$out/Forge.html"
asciidoctor-pdf -a revnumber="$version" "$forge" -o "$out/Forge.pdf"
echo "built:"
ls -la "$out/Manual.html" "$out/Manual.pdf" "$out/Forge.html" "$out/Forge.pdf"