fix: add resource symlinks and repo root static fallback to mdbook build

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
cydia2001
2026-03-10 22:31:16 +00:00
parent 55bb87884a
commit b64b394bb6
3 changed files with 19 additions and 1307 deletions

View File

@@ -14,6 +14,20 @@ if ! command -v mdbook >/dev/null 2>&1; then
exit 1
fi
# ── Create resource symlinks ──────────────────────────────────────────────────
# Resources (img/, references/, static/, mlsys.bib) live at the repo root and
# are symlinked into zh_chapters/ so mdbook can find them at relative paths.
for target in img references static mlsys.bib; do
link="${ROOT}/zh_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 ─────────────────────────────────────────────────────────────────────
"${PYTHON_BIN}" "${ROOT}/tools/prepare_mdbook_zh.py" \
--source "${ROOT}/zh_chapters" \
--summary-output "${ROOT}/zh_chapters/SUMMARY.md"

View File

@@ -161,6 +161,10 @@ def resolve_raw_html_file(current_file: Path, filename: str) -> Path:
if static_fallback.exists():
return static_fallback
repo_static = (Path(__file__).resolve().parent.parent / "static" / filename)
if repo_static.exists():
return repo_static
raise FileNotFoundError(f"Raw HTML include '{filename}' from '{current_file}' does not exist")

File diff suppressed because it is too large Load Diff

1
zh_chapters/mlsys.bib Symbolic link
View File

@@ -0,0 +1 @@
../mlsys.bib