summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLars Wirzenius <liw@liw.fi>2024-01-13 14:40:53 +0200
committerLars Wirzenius <liw@liw.fi>2024-01-13 14:54:44 +0200
commitca9adea36bcf4b284e8d957dab0914d4237b0276 (patch)
tree46c2fb810d877bc6464790eb5f36755e5b3baefa
parent92547fe7e290314d2d6f38d9046704d15f9ed1ae (diff)
downloadsubplot-ca9adea36bcf4b284e8d957dab0914d4237b0276.tar.gz
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 <liw@liw.fi> Sponsored-by: author
-rwxr-xr-xbuild-docs48
1 files changed, 48 insertions, 0 deletions
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