#!/usr/bin/env bash # Part of JoeyLib, Copyright (c) 2026 Scott Duensing, under the MIT License. # See LICENSE.md for license information. # SPDX-License-Identifier: MIT # # build-docs.sh - render the JoeyLib manual to HTML and PDF. # # Sources are docs/Manual.adoc plus the chapter files it includes, all in # docs/. Output goes to build/docs/, which is gitignored along with the rest # of build/ -- the .adoc sources are the tracked deliverable, the rendered # books are regenerated on demand. # # The HTML is built with -a data-uri so pictures are embedded and the page is # a single self-contained file that can be copied anywhere without an images # folder beside it. # # Usage: scripts/build-docs.sh [html|pdf] # with no argument, both. # Requires: asciidoctor and asciidoctor-pdf # gem install asciidoctor asciidoctor-pdf rouge set -euo pipefail repo=$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd) src=$repo/docs/Manual.adoc out=$repo/build/docs what=${1:-both} case "$what" in html|pdf|both) ;; *) echo "usage: $0 [html|pdf]" >&2; exit 2 ;; esac [ -f "$src" ] || { echo "build-docs: missing $src" >&2; exit 2; } need=(asciidoctor) [ "$what" = "html" ] || need+=(asciidoctor-pdf) for tool in "${need[@]}"; do command -v "$tool" >/dev/null || { echo "build-docs: $tool not found (gem install asciidoctor asciidoctor-pdf rouge)" >&2 exit 2 } done mkdir -p "$out" # -a allow-uri-read lets the SVG cover image be read from assets/. common=(-a "revdate=$(date +%Y-%m-%d)" -a allow-uri-read) if [ "$what" = "html" ] || [ "$what" = "both" ]; then asciidoctor "${common[@]}" -a data-uri \ "$src" -o "$out/JoeyLib-Manual.html" echo "build-docs: $out/JoeyLib-Manual.html" fi if [ "$what" = "pdf" ] || [ "$what" = "both" ]; then asciidoctor-pdf "${common[@]}" \ "$src" -o "$out/JoeyLib-Manual.pdf" echo "build-docs: $out/JoeyLib-Manual.pdf" fi ls -la "$out"