singe/build-docs.sh
2026-09-13 23:48:15 -05:00

34 lines
1.1 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; 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"
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"