#!/bin/sh
# nornir docs auto-trigger — re-render managed markdown (README.md / CHANGELOG.md)
# before each commit and stage the result, so published docs never drift.
#
# GENERATED by `nornir docs install-hooks skade` — safe to re-generate.
#
# HARD RULES:
# * markdown only — never regenerates the depgraph SVG or the rendered book.
# * never blocks a commit — any failure prints a warning and exits 0.
set -u
REPO='skade'
# Degrade gracefully if nornir isn't installed.
if ! command -v nornir >/dev/null 2>&1; then
echo "nornir: docs pre-commit skipped (nornir not on PATH)" >&2
exit 0
fi
# Re-render managed markdown only (no assets). Capture output; on ANY failure
# (warehouse unreachable, render error, …) warn and exit 0 — never block.
if ! out=$(nornir docs render "$REPO" --markdown-only 2>&1); then
echo "nornir: docs render failed — committing without doc refresh" >&2
echo "$out" | sed 's/^/nornir: /' >&2
exit 0
fi
# Stage only the managed docs nornir owns, and only if they exist + changed.
for f in README.md CHANGELOG.md; do
if [ -f "$f" ]; then
git add -- "$f" 2>/dev/null || true
fi
done
exit 0