updated make docs
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user