From 74762dc43d96673bfee7687ac13e0609b07f28d3 Mon Sep 17 00:00:00 2001 From: Kai Vogelgesang Date: Sat, 20 Sep 2025 01:36:38 +0200 Subject: [PATCH] Add build script --- .gitignore | 3 ++- build.py | 31 +++++++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100755 build.py diff --git a/.gitignore b/.gitignore index a2ce3f4..3309542 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ _build .venv .ipynb_checkpoints - +__pycache__ +out diff --git a/build.py b/build.py new file mode 100755 index 0000000..51f6af5 --- /dev/null +++ b/build.py @@ -0,0 +1,31 @@ +#!/usr/bin/env python +from pathlib import Path +import os +import subprocess +from typing import Literal + +BASE_DIR = Path(__file__).parent + +BUILD_DIR = BASE_DIR / "_build" +OUT_DIR = BASE_DIR / "out" + + +def run_build(language: Literal["de", "en"]): + toc_file = BASE_DIR / "_toc.yml" + if toc_file.exists(): + assert toc_file.is_file() + toc_file.unlink() + + os.symlink(BASE_DIR / f"_toc.{language}.yml", toc_file) + _ = subprocess.run(["jupyter-book", "build", "."]) + + toc_file.unlink() + + +if __name__ == "__main__": + _ = subprocess.run(["rm", "-r", BUILD_DIR]) + run_build("de") + _ = subprocess.run(["mv", BUILD_DIR, OUT_DIR]) + run_build("en") + _ = subprocess.run(f"cp -r {BUILD_DIR}/* {OUT_DIR}/", shell=True) + _ = subprocess.run(["rm", "-r", BUILD_DIR])