32 lines
792 B
Python
Executable File
32 lines
792 B
Python
Executable File
#!/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])
|