#!/usr/bin/env python3 """Assemble all module courses from _base + modules/*.html → index.html""" from pathlib import Path ROOT = Path(__file__).parent def build(course_dir: Path) -> None: parts = [course_dir / "_base.html"] parts.extend(sorted((course_dir / "modules").glob("*.html"))) parts.append(course_dir / "_footer.html") out = "".join(p.read_text(encoding="utf-8") for p in parts) (course_dir / "index.html").write_text(out, encoding="utf-8") print(f"Built {course_dir.name}/index.html") if __name__ == "__main__": for d in sorted(ROOT.glob("jinrong-*")): if d.is_dir() and (d / "_base.html").exists(): build(d) print("Done.")