Repository Public License Research preview
1#!/usr/bin/env python32"""Generate the course catalog, dependency graph and status reports from course.yaml + session metadata.34 docs/curriculum.md full curriculum, outcomes, dependency table5 assets/shared-diagrams/ATLAS-F26-carte-du-cours.tex course-wide knowledge map (TikZ, hero diagram 26)6 reports/status.json, reports/STATUS.md per-session readiness with evidence7 site/catalog.json machine-readable catalog for a future static site89--check exits 1 if a generated file is out of date.10"""11from __future__ import annotations1213import argparse14import json15import sys16from pathlib import Path1718from atlaslib import (REPORTS_DIR, REQUIRED_SESSION_FILES, ROOT, frame_ids, load_course, load_yaml,19 session_dir, session_status)2021LEVEL_DOTS = {"débutant": 1, "intermédiaire": 2, "avancé": 3}22STATUS_FR = {"planned": "planifiée", "draft": "ébauche", "implemented": "réalisée", "validated": "validée"}232425def course_map_tex(course: dict) -> str:26 """Six columns (parts) of four session tiles. Level = number of dots. Arrows chain the parts."""27 col_w, gap, tile_h, tile_gap = 22.4, 1.5, 10.4, 1.228 out = [29 "% ATLAS-F26 — Carte du cours : les 24 séances, leurs six parties et leur niveau.",30 "% GÉNÉRÉ par tools/generate_catalog.py à partir de course.yaml — modifier le générateur, pas ce fichier.",31 "% Avant \\AtlasFigure, définir \\AtlasMapCurrent (p. ex. S01) pour mettre une séance en évidence.",32 "\\providecommand{\\AtlasMapCurrent}{}",33 "\\begin{tikzpicture}[x=1mm, y=1mm]",34 " \\newcommand{\\atlasmaptile}[5]{% x, y, id, short title, level dots",35 " \\edef\\atlasmapid{#3}%",36 " \\ifx\\atlasmapid\\AtlasMapCurrent",37 f" \\draw[atlas block strong, fill=atlasPanel] (#1,#2) rectangle ++({col_w},{tile_h});",38 " \\else",39 f" \\draw[atlas region, rounded corners=1.6pt, fill=atlasPanel, fill opacity=.55] (#1,#2) rectangle ++({col_w},{tile_h});",40 " \\fi",41 f" \\node[anchor=north west, inner sep=0pt, font=\\AtlasSizeTiny\\bfseries, text=atlasFlow] at ($(#1,#2)+(1.3,{tile_h - 1.2})$) {{#3}};",42 f" \\foreach \\d in {{1,...,#5}} {{\\fill[atlasMuted] ($(#1,#2)+({col_w}-1.1-\\d*1.5,{tile_h - 2.1})$) circle[radius=.42mm];}}",43 f" \\node[anchor=south west, inner sep=0pt, text width={col_w - 2.4}mm, align=left, font=\\fontsize{{6.6}}{{7.4}}\\selectfont, text=atlasFg, atlas nohyphen] at ($(#1,#2)+(1.3,1)$) {{#4}};",44 " }",45 ]46 top = 4 * tile_h + 3 * tile_gap + 1.847 for ci, part in enumerate(course["parts"]):48 x = ci * (col_w + gap)49 out.append(f" \\node[anchor=south west, inner sep=0pt, text width={col_w}mm, align=left] at ({x:.1f},{top:.1f}) "50 f"{{{{\\AtlasSizeTiny\\bfseries\\color{{atlasMuted}}\\strut PARTIE {part['id']}}}\\\\[-.3mm]"51 f"{{\\fontsize{{7.6}}{{8.6}}\\selectfont\\bfseries\\color{{atlasFg}}\\strut {part['short']}}}}};")52 if ci:53 out.append(f" \\draw[atlas arrow, line width=.8pt] ({x - gap - 6.5:.1f},{top + 5.1:.1f}) -- ({x - gap - .4:.1f},{top + 5.1:.1f});")54 sessions = [s for s in course["sessions"] if s["part"] == part["id"]]55 for ri, s in enumerate(sessions):56 y = (3 - ri) * (tile_h + tile_gap)57 out.append(f" \\atlasmaptile{{{x:.1f}}}{{{y:.1f}}}{{{s['id']}}}{{{s['short']}}}{{{LEVEL_DOTS[s['level']]}}}")58 out.append("\\end{tikzpicture}")59 return "\n".join(out) + "\n"606162def curriculum_md(course: dict) -> str:63 c, a = course["course"], course["author"]64 L = [f"# Curriculum — {c['title']}", "",65 "<!-- GENERATED by tools/generate_catalog.py from course.yaml. Edit course.yaml, then run `make catalog`. -->", "",66 f"**Instructor and author:** {a['name']} — {a['title_line']}, {a['department']}. ",67 f"**Teaching language:** {c['language']} (all learner-facing content). ",68 f"**Subtitle:** *{c['subtitle']}*", "",69 f"> {c['endorsement_notice']}", "",70 "24 sessions in 6 parts. Each session is usable on its own and as part of the full course. "71 "Target effort per session: 90–150 minutes. Levels: débutant → intermédiaire → avancé.", "",72 "## Overview", "", "| ID | Part | Level | Title | Prerequisites | Status |", "|---|---|---|---|---|---|"]73 for s in course["sessions"]:74 deps = ", ".join(s["depends_on"]) or "—"75 L.append(f"| {s['id']} | {s['part']} | {s['level']} | {s['title']} | {deps} | {session_status(s)} |")76 L += ["", "## Learning paths", "",77 "- **Core path (non-coders welcome):** S01 → S02 → S04 → S05 → S06 → S07 → S09 → S20 → S21.",78 "- **Builder path:** core path + S10 → S11 → S12 → S17 → S18 → S19 → S23 → S24.",79 "- **Coding-agent track (optional, advanced):** S11 → S13 → S14 → S15 → S16.",80 "- **Mathematical deep dive (optional):** S03.", "",81 "Paths are derived from the dependency table below; a session never requires one outside its listed prerequisites.", ""]82 for part in course["parts"]:83 L += [f"## Partie {part['id']} — {part['title']}", ""]84 for s in (x for x in course["sessions"] if x["part"] == part["id"]):85 unlocks = [t["id"] for t in course["sessions"] if s["id"] in t["depends_on"]]86 L += [f"### {s['id']} — {s['title']}", "",87 f"- **Directory:** `sessions/{s['id']}-{s['slug']}/` · **Level:** {s['level']} · **Status:** {session_status(s)}",88 f"- **Prerequisites:** {', '.join(s['depends_on']) or 'none'} · **Unlocks:** {', '.join(unlocks) or 'none'}",89 f"- **Tags:** {', '.join(s['tags'])}", "", "Résultats d'apprentissage :", ""]90 L += [f"{i}. {o}" for i, o in enumerate(s["outcomes"], 1)]91 L.append("")92 L += ["## Dependency graph (edges)", "", "```text"]93 L += [f"{d} -> {s['id']}" for s in course["sessions"] for d in s["depends_on"]]94 L += ["```", ""]95 return "\n".join(L)969798def session_evidence(s: dict) -> dict:99 d = session_dir(s)100 status = session_status(s)101 present = [f for f in REQUIRED_SESSION_FILES if (d / f).exists()]102 qa = {}103 if (d / "qa" / "results.json").exists():104 qa = json.loads((d / "qa" / "results.json").read_text(encoding="utf-8"))105 build = REPORTS_DIR / f"build-{s['id']}.json"106 build_info = json.loads(build.read_text(encoding="utf-8")) if build.exists() else {}107 figs = sorted(p.stem for p in (d / "figures" / "src").glob("*.tex") if not p.stem.endswith("-donnees")) \108 if (d / "figures" / "src").exists() else []109 quiz = load_yaml(d / "quizzes" / "questions.yaml") if (d / "quizzes" / "questions.yaml").exists() else {}110 return {111 "id": s["id"], "title": s["title"], "part": s["part"], "level": s["level"], "status": status,112 "required_files_present": len(present), "required_files_total": len(REQUIRED_SESSION_FILES),113 "slides": len(frame_ids(d)), "deck_pages": build_info.get("pages"),114 "deck_compiled": build_info.get("returncode") == 0 if build_info else False,115 "figures": len(figs), "quiz_questions": len((quiz or {}).get("questions", [])),116 "visual_review": qa.get("visual_review", {}).get("status", "none"),117 "open_issues": qa.get("open_issues", []),118 }119120121def status_md(course: dict, rows: list[dict]) -> str:122 counts = {k: sum(r["status"] == k for r in rows) for k in STATUS_FR}123 L = ["# STATUS — ATLAS IA", "",124 "<!-- GENERATED by tools/generate_catalog.py (`make catalog`). Do not edit by hand. -->", "",125 f"Course version {course['course']['version']}. "126 "Status labels follow CLAUDE.md §3 and §16: `planned` (objectives only) · `draft` (work in progress) · "127 "`implemented` (all deliverables present, automated checks pass) · `validated` (all acceptance criteria, "128 "including a recorded visual review and CI).", "",129 "**The course is not complete.** " + ", ".join(f"{v} {k}" for k, v in counts.items()) + " (of 24 sessions).", "",130 "| ID | Title | Status | Files | Slides | Deck compiled | Figures | Quiz | Visual review |", "|---|---|---|---|---|---|---|---|---|"]131 for r in rows:132 L.append(f"| {r['id']} | {r['title']} | **{r['status']}** | {r['required_files_present']}/{r['required_files_total']} "133 f"| {r['slides'] or '—'} | {'yes (' + str(r['deck_pages']) + ' p.)' if r['deck_compiled'] else '—'} "134 f"| {r['figures'] or '—'} | {r['quiz_questions'] or '—'} | {r['visual_review']} |")135 L += ["", "## Open issues per session", ""]136 for r in rows:137 for issue in r["open_issues"]:138 L.append(f"- **{r['id']}** — {issue}")139 if not any(r["open_issues"] for r in rows):140 L.append("- none recorded")141 L += ["", "Evidence: `reports/*.json` (validators and build logs), `sessions/SXX/qa/results.json` (per-session QA), "142 "`dist/preview/` (rendered slides and contact sheets, regenerate with `make preview`).", ""]143 return "\n".join(L)144145146def main() -> int:147 ap = argparse.ArgumentParser(description=__doc__)148 ap.add_argument("--check", action="store_true")149 args = ap.parse_args()150 course = load_course()151 rows = [session_evidence(s) for s in course["sessions"]]152 catalog = {"course": course["course"], "author": course["author"], "parts": course["parts"],153 "sessions": [{**{k: s[k] for k in ("id", "slug", "part", "level", "title", "short", "depends_on",154 "tags", "outcomes")}, "status": session_status(s)}155 for s in course["sessions"]]}156 outputs = {157 ROOT / "docs" / "curriculum.md": curriculum_md(course),158 ROOT / "assets" / "shared-diagrams" / "ATLAS-F26-carte-du-cours.tex": course_map_tex(course),159 ROOT / "site" / "catalog.json": json.dumps(catalog, ensure_ascii=False, indent=2) + "\n",160 }161 if not args.check: # status reports depend on build artifacts; never part of --check162 outputs[REPORTS_DIR / "status.json"] = json.dumps({"sessions": rows}, ensure_ascii=False, indent=2) + "\n"163 outputs[REPORTS_DIR / "STATUS.md"] = status_md(course, rows)164 stale = []165 for path, content in outputs.items():166 if path.exists() and path.read_text(encoding="utf-8") == content:167 continue168 if args.check:169 stale.append(str(path.relative_to(ROOT)))170 else:171 path.parent.mkdir(parents=True, exist_ok=True)172 path.write_text(content, encoding="utf-8")173 print(f"wrote {path.relative_to(ROOT)}")174 if stale:175 print("Out of date (run `make catalog`): " + ", ".join(stale), file=sys.stderr)176 return 1177 return 0178179180if __name__ == "__main__":181 sys.exit(main())182