#!/usr/bin/env python3 """ check-shadow-css.py — guardrail 13.9: the shadow root is not invisible. `` renders in a shadow root, so the 700-odd lines of CSS in its `" not in lines[j]: j += 1 out.append((i + 1, j + 1, RE_COMMENT.sub("", "\n".join(lines[i + 1 : j])))) i = j i += 1 return out def token_colours() -> dict[str, str]: """hex -> token, from the design tokens, for the "a token was available" list. Only literal colours count; an alias cannot be compared.""" out: dict[str, str] = {} for path in sorted(CSS_DIR.glob("*.css")): src = RE_COMMENT.sub("", path.read_text(encoding="utf8")) for m in RE_BLOCK.finditer(src): parts = [p.strip().split(";")[-1].strip() for p in m.group(1).split(",")] if not any(p == ":root" or p.startswith(":root ") or p.startswith("body[data-page") for p in parts): continue for token, value in RE_TOKEN_DEF.findall(m.group(2)): if RE_HEX.fullmatch(value.strip()): out.setdefault(value.strip().lower(), token) return out def main() -> int: parser = argparse.ArgumentParser(description=__doc__, formatter_class=argparse.RawDescriptionHelpFormatter) parser.add_argument("--strict", action="store_true", help="fail while any baseline debt stands") args = parser.parse_args() if not HOST.exists(): print(f"host file gone: {HOST} — STY-3.4a may have landed; check BASELINE", file=sys.stderr) return 1 blocks = shadow_blocks() css = "\n".join(css for _, _, css in blocks) if not css.strip(): # STY-3.4a: the blocks live in static/css/chart-card.css now. The # guardrail follows them there instead of stopping, because the debt # they carry is still debt until the repaint (STY-3.4b) pays it. if not EXTRACTED.exists(): print(f"no