From ca9adea36bcf4b284e8d957dab0914d4237b0276 Mon Sep 17 00:00:00 2001 From: Lars Wirzenius Date: Sat, 13 Jan 2024 14:40:53 +0200 Subject: build: script to build all document output Add a script to build all subplots into HTML, and to generate HTML versions of all Subplot library bindings. This is useful for two reasons: * When iterating over documentation, just building it is fast. * CI needs to build all the documentation, but does not necessarily need to generate test code to run the scenarios in subplots. I plan on using this in Ambient CI to update doc.subplot.tech. Signed-off-by: Lars Wirzenius Sponsored-by: author --- build-docs | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100755 build-docs diff --git a/build-docs b/build-docs new file mode 100755 index 0000000..a3a1dc9 --- /dev/null +++ b/build-docs @@ -0,0 +1,48 @@ +#!/bin/bash + +set -euo pipefail + +# Get output directory. +if [ "$#" != 1 ]; then + echo "Usage: $0 OUTPUT-DIR" 1>&2 + exit 1 +fi +output="$1" + +# Build Subplot so that we can use it to generate +# documentation. + +cargo build +PATH="${CARGO_TARGET_DIR:-target}:$PATH" +type -all subplot + +# Build subplots that come with Subplot + +opts="--resources $(pwd)/src/share" +find . -name "*.subplot" | + grep -Fv .gitlab/ | + while read -r file; do + base="$(basename "$file" .subplot)" + ( + cd "$(dirname "$file")" + # shellcheck disable=SC2154 disable=SC2086 + if subplot $opts metadata --merciful "$base.subplot" | awk '/^title:/ && NF > 1' | grep .; then + subplot $opts docgen --merciful "$base.subplot" -o "$output/$base.html" + fi + ) + done + +# Build Subplot library documentation. + +libdocs="$output/libdocs" +mkdir -p "$libdocs" + +find share -name '*.yaml' ! -name template.yaml | + while read -r yaml; do + dir="$(dirname "$yaml")" + md="$dir/$(basename "$yaml" .yaml).md" + subplot "--resources=$(pwd)" libdocgen --output "$md" "$yaml" + pandoc --standalone --self-contained \ + --metadata title="$(basename "$yaml" .yaml)" \ + -o "$libdocs/$(basename "$md" .md)".html "$md" + done -- cgit v1.2.1