ci: separate docs into scripts
CI / check (push) Successful in 8m52s
Deploy docs / deploy (push) Failing after 1m50s
Nightly / nightly (push) Successful in 10m54s

This commit is contained in:
2026-08-07 16:54:59 -04:00
parent abc0bdf621
commit 717c4b412a
4 changed files with 67 additions and 34 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/usr/bin/env bash
# Flatten rustdoc output so the crate serves at the doc root rather than under
# <crate>/. Moves the crate's pages up to the doc root and drops one ../ from
# each page's references to the shared assets (CSS/JS, search index, source),
# scaled to the page's depth.
# Env: DOCROOT (default target/doc), CRATE (default coursebank).
set -euo pipefail
docroot="${DOCROOT:-target/doc}"
crate="${CRATE:-coursebank}"
[ -d "$docroot/$crate" ] || { echo "no $docroot/$crate; did you build the docs?" >&2; exit 1; }
cp -a "$docroot/$crate/." "$docroot/"
rm -rf "${docroot:?}/${crate:?}"
resources='static\.files/\|crates\.js\|search-index\|search\.desc/\|src/\|settings\.html\|help\.html\|trait\.impl/\|type\.impl/'
while IFS= read -r -d '' f; do
rel="${f#"$docroot"/}"
depth=$(printf '%s' "$rel" | tr -cd '/' | wc -c)
pat=''; for ((i=0; i<=depth; i++)); do pat="\\.\\./$pat"; done
rep=''; for ((i=0; i<depth; i++)); do rep="../$rep"; done
sed -i "s#${pat}\(${resources}\)#${rep}\1#g" "$f"
done < <(find "$docroot" -name '*.html' -print0)
echo "flattened $crate into $docroot"