Add build script

This commit is contained in:
Kai Vogelgesang 2025-09-20 01:36:38 +02:00
parent 19113626fb
commit 74762dc43d
No known key found for this signature in database
GPG Key ID: B51995F56510D27C
2 changed files with 33 additions and 1 deletions

3
.gitignore vendored
View File

@ -1,4 +1,5 @@
_build
.venv
.ipynb_checkpoints
__pycache__
out

31
build.py Executable file
View File

@ -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])