Add build script
This commit is contained in:
parent
19113626fb
commit
74762dc43d
3
.gitignore
vendored
3
.gitignore
vendored
@ -1,4 +1,5 @@
|
||||
_build
|
||||
.venv
|
||||
.ipynb_checkpoints
|
||||
|
||||
__pycache__
|
||||
out
|
||||
|
||||
31
build.py
Executable file
31
build.py
Executable 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])
|
||||
Loading…
Reference in New Issue
Block a user