Files
openmlsys-zh/build_html.sh
cydia2001 c52a509882 build: add mdbook support for zh chapters
Add mdBook configuration rooted at zh_chapters, generate and commit SUMMARY.md, rewrite d2l-specific directives through a Python preprocessor, refresh chapter resource symlinks from the build scripts, and ignore local build-only links and helper directories.
2026-03-10 21:50:08 +00:00

32 lines
1.2 KiB
Bash

#!/bin/bash
# Build the English (en) version of the book from en_chapters/.
# Output: en_chapters/_build/html/
#
# Resources (img/, references/, static/, mlsys.bib) live at the repo root and
# are symlinked into en_chapters/ so d2lbook can find them at relative paths.
set -e
ROOT="$(cd "$(dirname "$0")" && pwd)"
# ── Create resource symlinks ──────────────────────────────────────────────────
for target in img references static mlsys.bib; do
link="$ROOT/en_chapters/$target"
rel_target="../$target"
if [ -e "$link" ] && [ ! -L "$link" ]; then
echo "Refusing to replace non-symlink path: $link" >&2
exit 1
fi
ln -sfn "$rel_target" "$link"
done
# ── Build ─────────────────────────────────────────────────────────────────────
cd "$ROOT/en_chapters"
rm -rf _build/rst _build/html
d2lbook build rst
cp static/frontpage.html _build/rst/
d2lbook build html
cp -r static/image/* _build/html/_images/ 2>/dev/null || true
python3 "$ROOT/tools/format_tables.py"