#!/usr/bin/env python3 """Generate viz/manual.html — the polished standalone user manual — from the in-app grimoire in viz/index.html (the single source of truth per CLAUDE.md). Re-run whenever the grimoire changes: python3 build_manual.py ponytail: string-slice extraction, no HTML parser dep. The grimoire is a flat, well-formed block; if its shape ever changes, this fails loudly (asserts) rather than emitting a broken page. """ import re import sys import pathlib HERE = pathlib.Path(__file__).parent SRC = HERE / "viz" / "index.html" OUT = HERE / "viz" / "manual.html" html = SRC.read_text(encoding="utf-8") # --- 1. the whole ", html, re.S) assert m, "no
✦ GODSTRUMENT — the manual▶ play the instrument →
{grim.replace('
', '
' + toc_html, 1)} """ OUT.write_text(page, encoding="utf-8") print(f"wrote {OUT} ({len(page):,} bytes, {len(toc)} sections)") # self-check: the page must be self-contained and carry the real feature sections assert "OMNI" in page and "Building from zero" in page and "dimensions" in page.lower(), "manual missing key feature sections" assert "id=\"grimoire\"" in page and page.count("= 8, "manual structure looks wrong" print("ok: self-contained, has OMNI / zero / dimensions sections")