build: migrate docs publishing to mdbook

Move the English root site to mdBook, keep the Chinese site as a sub-book, and update CI/deploy to publish .mdbook outputs to docs/ and docs/cn/. Also add regression coverage for placeholder skipping, publish-tree assembly, and shared resource setup.
This commit is contained in:
cydia2001
2026-03-11 00:57:34 +00:00
parent 7143925e01
commit 9d75cdc6c3
22 changed files with 1432 additions and 673 deletions

View File

@@ -16,30 +16,28 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'
- name: Install pandoc
- name: Install Rust toolchain
run: |
wget -q https://github.com/jgm/pandoc/releases/download/2.19.2/pandoc-2.19.2-1-amd64.deb
sudo dpkg -i pandoc-2.19.2-1-amd64.deb
curl -sSf https://sh.rustup.rs | sh -s -- -y --profile minimal
echo "$HOME/.cargo/bin" >> "$GITHUB_PATH"
- name: Install d2lbook
- name: Install mdBook
run: cargo install mdbook --locked
- name: Run mdBook regression tests
run: |
git clone https://github.com/openmlsys/d2l-book.git
cd d2l-book
# Fix Python 3.10+ incompatibility: bibtex<2.0.0 depends on oset which
# uses collections.MutableSet removed in Python 3.10.
sed -i "s/'sphinxcontrib-bibtex<2.0.0'/'sphinxcontrib-bibtex>=2.5.0'/" setup.py
python3 -m pip install .
python3 -m unittest discover -s tests -p 'test_prepare_mdbook.py'
python3 -m unittest discover -s tests -p 'test_prepare_mdbook_zh.py'
python3 -m unittest discover -s tests -p 'test_assemble_docs_publish_tree.py'
python3 -m unittest discover -s tests -p 'test_ensure_book_resources.py'
python3 -m unittest discover -s tests -p 'test_mdbook_mathjax.py'
- name: Install Python dependencies
run: python3 -m pip install -r requirements.txt sphinx-mathjax-offline
- name: Build English HTML with mdBook
run: bash build_mdbook.sh
- name: Build English HTML
run: bash build_html.sh
- name: Build Chinese HTML
run: bash build_html_zh.sh
- name: Build Chinese HTML with mdBook
run: bash build_mdbook_zh.sh
- name: Deploy to GitHub Pages
env:
@@ -47,12 +45,11 @@ jobs:
run: |
git clone https://x-access-token:${DEPLOY_TOKEN}@github.com/openmlsys/openmlsys.github.io.git
# English → root (default language)
cp -r en_chapters/_build/html/* openmlsys.github.io/docs/
# Chinese → /cn/ subdirectory
mkdir -p openmlsys.github.io/docs/cn
cp -r zh_chapters/_build/html/* openmlsys.github.io/docs/cn/
python3 tools/assemble_docs_publish_tree.py \
--destination-root openmlsys.github.io \
--docs-subdir docs \
--en-source .mdbook/book \
--zh-source .mdbook-zh/book
cd openmlsys.github.io
git config user.name "github-actions[bot]"