diff options
Diffstat (limited to 'docs/2026_REBASE/tools/snapshot-library.py')
| -rw-r--r-- | docs/2026_REBASE/tools/snapshot-library.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/2026_REBASE/tools/snapshot-library.py b/docs/2026_REBASE/tools/snapshot-library.py new file mode 100644 index 00000000..dee09d2f --- /dev/null +++ b/docs/2026_REBASE/tools/snapshot-library.py @@ -0,0 +1,16 @@ +"""Bundle the current Chapter 25 stdlib and methods example for offline browsing.""" +from pathlib import Path +import json + +deck = Path(__file__).resolve().parents[1] +repo = deck.parents[1] +source = repo / "chapter25/src/main/smp" +paths = [source / "sys.smp", *sorted((source / "sys").rglob("*.smp"))] +files = {path.relative_to(source).as_posix(): path.read_text(encoding="utf-8") for path in paths} +bundle = {"origin": "chapter25/src/main/smp", "files": files, + "methods": (deck / "demos/methods.smp").read_text(encoding="utf-8")} +(deck / "stdlib.js").write_text( + "/* Generated by tools/snapshot-library.py; local source snapshot. */\n" + "window.REBASE.library = " + json.dumps(bundle, ensure_ascii=False, indent=2) + ";\n", + encoding="utf-8", newline="\n") +print(f"Bundled {len(files)} standard-library files and the methods example.") |
