AtlatestRepositorysigil-doc

sigil-doc / tree / testgate-d0.sh

1#!/usr/bin/env bash
2set -euo pipefail
3repo_dir="$(cd "$(dirname "$0")/.." && pwd)"
4cd "$repo_dir"
5mkdir -p "$repo_dir/build"
6cache_dir=$(mktemp -d "$repo_dir/build/xdg-cache.XXXXXX")
7sigil="${SIGIL_D1_COMPILER:-$repo_dir/../task-sigil-language-readers/build/dev/bin/sigil}"
8redirects="${SIGIL_D1_REDIRECTS:-$repo_dir/dev-redirects.sgl}"
9XDG_CACHE_HOME="$cache_dir" SIGIL_REDIRECTS="$redirects" "$sigil" -L src -L test test test/test-model.sgl --report
10# Assert the swept subjects EXIST before sweeping them: `if rg` cannot tell a
11# missing file (exit 2) from a clean one (exit 1), so a rename of the semantic
12# core would silently disarm this ban (found 2026-08-24).
13test -f src/sigil/doc/model.sgl
14test -f src/sigil/doc/traversal.sgl
15if rg -n -i '(html|sxml|css|typst|latex|slate|class=|tag:)' src/sigil/doc/model.sgl src/sigil/doc/traversal.sgl; then
16 echo "backend vocabulary leaked into semantic core" >&2
17 exit 1
18fi
19# D1 legitimately adds the reader, D4 adds HTML fragments, and D6 adds the
20# reviewed Typst source adapter. Unimplemented Slate/direct-PDF surfaces remain
21# forbidden; the semantic core above must remain backend-neutral.
22future="$(find src -type f | rg '/(slate|pdf)\.sgl$' || true)"
23test -z "$future"
24test "$(find src -type f | rg '/html\.sgl$' | wc -l)" -eq 1
25test -f src/sigil/doc/render/html.sgl
26test "$(find src -type f | rg '/typst\.sgl$' | wc -l)" -eq 1
27test -f src/sigil/doc/render/typst.sgl
28test "$(wc -w < test/fixtures/practical-sigil-chapter.txt)" -ge 500
29echo "D0_GATE_GREEN"