updated make docs

This commit is contained in:
2026-09-30 09:53:32 -03:00
parent f00055033e
commit 85276d34c3
5 changed files with 61 additions and 7 deletions

View File

@@ -1,6 +1,8 @@
#!/usr/bin/env bash
# Documentation: render the diagrams, and serve the pages from a throwaway nginx container.
# Usage: docs.sh serve | graphs
# Whose: DOCS_DIR, the docs/ of the folder `make docs` runs from (a project's launcher sets
# it); unset, rig's own.
# Notes: docs/notes/docs.md
set -euo pipefail
cd "$(dirname "$0")"
@@ -9,11 +11,13 @@ source ./lib/config.sh
load_config
REPO="$(cd .. && pwd)"
DOCS="${DOCS_DIR:-$REPO/docs}"
[ -d "$DOCS" ] && DOCS="$(cd "$DOCS" && pwd)"
DOCS_PORT="${DOCS_PORT:-$((HTTP_PORT + 4))}" # +4 sits inside this env's block
serve() {
if [ ! -f "$REPO/docs/index.html" ]; then
echo "no docs/index.html" >&2
if [ ! -f "$DOCS/index.html" ]; then
echo "no index.html in $DOCS" >&2
exit 1
fi
# One worker and no access log: a few static pages need no more, and the
@@ -32,13 +36,14 @@ http {
}
NGINX
chmod 644 "$DOCS_CONF"
echo "docs for '$CLUSTER' on http://localhost:${DOCS_PORT}"
echo "docs of $DOCS"
echo " for '$CLUSTER' on http://localhost:${DOCS_PORT}"
echo " (ctrl-c to stop; nothing is installed and nothing persists)"
docker run --rm \
--name "${CLUSTER}-docs" \
-e NGINX_ENTRYPOINT_QUIET_LOGS=1 \
-p "${DOCS_PORT}:80" \
-v "$REPO/docs:/usr/share/nginx/html:ro" \
-v "$DOCS:/usr/share/nginx/html:ro" \
-v "$DOCS_CONF:/etc/nginx/nginx.conf:ro" \
nginx:alpine
}
@@ -51,13 +56,13 @@ graphs() {
fi
shopt -s nullglob
local found=0 f out
for f in "$REPO"/docs/graphs/*.dot; do
for f in "$DOCS"/graphs/*.dot; do
out="${f%.dot}.svg"
echo " graphviz $(basename "$f") → $(basename "$out")"
dot -Tsvg "$f" -o "$out"
found=1
done
[ "$found" -eq 1 ] || echo " no .dot files in docs/graphs/"
[ "$found" -eq 1 ] || echo " no .dot files in $DOCS/graphs/"
}
case "${1:-serve}" in

View File

@@ -193,6 +193,13 @@ check "the caller beats rig.env" "from-caller" \
# Identity follows the overlay's folder, so one rig serves several without collisions.
check "identity follows the overlay's folder" "my-env kind-my-env" \
"$(in_ov env OVERLAY=local/My_Env bash ports.sh active | awk '{print $1, $2}')"
mkdir -p "$OVR/local/renamed"; printf 'CLUSTER=pinned\n' > "$OVR/local/renamed/rig.env"
check "rig.env's CLUSTER names it, whatever the folder" "pinned kind-pinned $(derive_port_base pinned)" \
"$(in_ov env OVERLAY=local/renamed bash ports.sh active | awk '{print $1, $2, $3}')"
check "the caller's CLUSTER beats rig.env's" "second kind-second" \
"$(in_ov env OVERLAY=local/renamed CLUSTER=second bash ports.sh active | awk '{print $1, $2}')"
check "make docs serves DOCS_DIR, the folder it runs from" "no index.html in $OVR/local/renamed" \
"$(in_ov env DOCS_DIR="$OVR/local/renamed" bash docs.sh serve 2>&1 >/dev/null | head -1)"
check "paths in rig.env are relative to the overlay" "$OVR/local/My_Env/k8s/prod" \
"$(in_ov env OVERLAY=local/My_Env bash ports.sh active | awk '{print $7}')"
check "a named overlay that does not exist is an error" "yes" \