Add multi-version documentation build support#234
Conversation
There was a problem hiding this comment.
Pull request overview
Adds infrastructure for building and serving Sphinx documentation across multiple Git refs (tags/branches), including a root redirect to the latest version and CI adjustments in preparation for multi-version builds.
Changes:
- Introduces scripts to generate
versions.jsonand to filter a set of versions to keep. - Adds a root
index.htmlredirect template and a redirect JS asset for multi-version docs. - Extends docs Makefile and updates CI workflow setup (full git history + caching), with a commented “Phase 2” multi-version job.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/source/conf.py | Adds sphinx-multiversion config and adjusts HTML output settings. |
| docs/source/_templates/index.html | Adds root redirect page template to send users to latest docs version. |
| docs/source/_static/version-redirect.js | Adds redirect JS (currently not wired into build). |
| docs/scripts/generate_versions_json.py | Generates versions metadata from built output directories. |
| docs/scripts/build_versions.py | Provides helper logic to filter versions by a buffer size. |
| docs/Makefile | Adds multiversion, clean-multiversion, and preview targets. |
| .github/workflows/main.yml | Adds full-history checkout + caches; leaves multi-version build job commented. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| """Helper script for filtering versions to maintain buffer size.""" | ||
|
|
||
| import re | ||
| from pathlib import Path |
| releases.sort(key=parse_version, reverse=True) | ||
|
|
||
| # Keep latest (buffer_size - 1) releases | ||
| releases_to_keep = releases[: (buffer_size - 1)] | ||
|
|
| # -- sphinx-multiversion configuration ------------------------------------------------- | ||
| # Enable multi-version builds (set to True in v0.2.0+) | ||
| ENABLE_MULTI_VERSION = True | ||
|
|
||
| html_theme = "sphinx_book_theme" | ||
| html_static_path = ["_static"] | ||
| # html_logo = "_static/logo_e.png" | ||
| # Version buffer size: number of releases to keep + main branch | ||
| VERSION_BUFFER_SIZE = 5 |
| .PHONY: preview | ||
| preview: | ||
| @echo "Starting documentation preview server at http://localhost:8000" | ||
| @python3 preview.py --directory "$(BUILDDIR)/html" --port 8000 --open |
| @@ -56,14 +77,73 @@ jobs: | |||
| echo "Start Building docs..." | |||
| pip uninstall pymeshlab -y | |||
| pip install pymeshlab==2023.12.post3 | |||
| # Build main branch only (Phase 1) | |||
| make html | |||
|
|
|||
| # Don't include version-redirect.js automatically - we add it manually to root | ||
| html_js_files = [] |
| """Generate versions.json for multi-version documentation.""" | ||
|
|
||
| import json | ||
| import os |
| # Sort versions (main last, releases in descending order - newest first) | ||
| def version_key(v): | ||
| name = v["name"] | ||
| if name == "main": | ||
| return (2, "") # Put main last | ||
| else: | ||
| # Extract version number for sorting (v0.1.3 -> (0, 1, 3)) | ||
| parts = name.lstrip("v").split(".") | ||
| try: | ||
| major, minor, patch = map(int, parts[:3]) | ||
| # Use negative for descending sort (newest first) | ||
| return (1, (-major, -minor, -patch)) | ||
| except (ValueError, IndexError): | ||
| return (1, (0, 0, 0)) | ||
|
|
||
| versions.sort(key=version_key) | ||
|
|
||
| return { | ||
| "versions": versions, | ||
| "latest": versions[0]["name"] if versions else "main", |
There was a problem hiding this comment.
Pull request overview
Adds infrastructure for building and serving Sphinx documentation across multiple git refs (tags/branches), including a root-level redirect to the “latest” docs and supporting build scripts/CI plumbing.
Changes:
- Added scripts to build/version docs outputs and generate a
versions.jsonmanifest. - Updated Sphinx config + added a root
index.htmlredirect template/static assets for version-aware navigation. - Extended docs Makefile and CI workflow to support (or prepare for) multi-version builds.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 7 comments.
Show a summary per file
| File | Description |
|---|---|
embodichain/lab/sim/robots/cobotmagic.py |
Formatting-only change in default cfg construction. |
docs/source/conf.py |
Adds/updates sphinx-multiversion + HTML context/theme options relevant to versioned docs. |
docs/source/_templates/index.html |
New root HTML redirect page that reads versions.json to send users to the latest docs. |
docs/source/_static/version-redirect.js |
New redirect helper JS (currently appears unused/duplicated). |
docs/scripts/generate_versions_json.py |
New script to generate versions.json from built output directories. |
docs/scripts/build_versions.py |
New helper for filtering versions to a fixed buffer size. |
docs/Makefile |
Adds multiversion, clean-multiversion, and preview targets. |
.github/workflows/main.yml |
Updates docs build job (full checkout + caching) and scaffolds a commented multi-version job. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| versions.sort(key=version_key) | ||
|
|
||
| return { | ||
| "versions": versions, | ||
| "latest": versions[0]["name"] if versions else "main", |
| """Generate versions.json for multi-version documentation.""" | ||
|
|
||
| import json | ||
| import os |
| """Helper script for filtering versions to maintain buffer size.""" | ||
|
|
||
| import re | ||
| from pathlib import Path |
| # -- sphinx-multiversion configuration ------------------------------------------------- | ||
| # Enable multi-version builds (set to True in v0.2.0+) | ||
| ENABLE_MULTI_VERSION = True | ||
|
|
||
| html_theme = "sphinx_book_theme" | ||
| html_static_path = ["_static"] | ||
| # html_logo = "_static/logo_e.png" | ||
| # Version buffer size: number of releases to keep + main branch | ||
| VERSION_BUFFER_SIZE = 5 |
| # HTML context for better path handling | ||
| html_context = { | ||
| "github_user": "dexforce", | ||
| "github_repo": "EmbodiChain", | ||
| "github_version": "main", |
| /** | ||
| * Version redirect script for multi-version documentation. | ||
| * Redirects to the latest stable release version, or falls back to 'main'. | ||
| */ | ||
|
|
||
| (function() { | ||
| 'use strict'; | ||
|
|
||
| // Try to fetch versions.json (generated by generate_versions_json.py) | ||
| fetch('versions.json') | ||
| .then(response => { | ||
| if (!response.ok) { | ||
| throw new Error('versions.json not found'); | ||
| } |
| @@ -56,14 +77,73 @@ jobs: | |||
| echo "Start Building docs..." | |||
| pip uninstall pymeshlab -y | |||
| pip install pymeshlab==2023.12.post3 | |||
| # Build main branch only (Phase 1) | |||
| make html | |||
|
|
|||
There was a problem hiding this comment.
Pull request overview
Adds Sphinx multi-version documentation build support (sphinx-multiversion) including version-selection UI, redirect behavior, build scripts/targets, and CI updates to build/deploy docs with version awareness.
Changes:
- Configure Sphinx for sphinx-multiversion and add a sidebar version selector template.
- Add tooling for version metadata/redirects plus Makefile targets for multi-version and single-version builds.
- Update CI workflow to fetch full git history, build docs (conditionally), and deploy GitHub Pages artifacts.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/source/conf.py | Adds sphinx-multiversion config and sidebar/template integration. |
| docs/source/_templates/versioning.html | Introduces a dropdown UI for switching between built versions. |
| docs/source/_templates/index.html | Adds a root index redirect page for the built docs site. |
| docs/source/_static/version-redirect.js | Adds a JS-based redirect mechanism intended to use versions metadata. |
| docs/scripts/generate_versions_json.py | Adds a script to generate a versions.json metadata file from build output. |
| docs/scripts/build_versions.py | Adds a helper script intended to filter versions to keep. |
| docs/requirements.txt | Pins sphinx-multiversion dependency version. |
| docs/Makefile | Adds multiversion and current-docs targets for new workflows. |
| .github/workflows/main.yml | Updates docs build/deploy logic and adds caching + full checkout history for multiversion builds. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| # Sort versions (main last, releases in descending order - newest first) | ||
| def version_key(v): | ||
| name = v["name"] | ||
| if name == "main": | ||
| return (2, "") # Put main last | ||
| else: | ||
| # Extract version number for sorting (v0.1.3 -> (0, 1, 3)) | ||
| parts = name.lstrip("v").split(".") | ||
| try: | ||
| major, minor, patch = map(int, parts[:3]) | ||
| # Use negative for descending sort (newest first) | ||
| return (1, (-major, -minor, -patch)) | ||
| except (ValueError, IndexError): | ||
| return (1, (0, 0, 0)) | ||
|
|
||
| versions.sort(key=version_key) | ||
|
|
||
| return { | ||
| "versions": versions, | ||
| "latest": versions[0]["name"] if versions else "main", | ||
| } |
| <title>Redirecting to the latest EmbodiChain documentation</title> | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="refresh" content="0; url=./main/index.html"> | ||
| </head> |
| # Whitelist pattern for remotes | ||
| smv_remote_whitelist = r"^origin$" | ||
| # Whitelist pattern for branches (set to None to ignore all branches) | ||
| smv_branch_whitelist = os.getenv("SMV_BRANCH_WHITELIST", r"^main$") | ||
| # Whitelist pattern for tags (set to None to ignore all tags) | ||
| smv_tag_whitelist = os.getenv("SMV_TAG_WHITELIST", r"^v\d+\.\d+\.\d+$") |
| const currentPath = window.location.pathname; | ||
|
|
||
| // If we're at root, redirect to latest version | ||
| if (currentPath === '/' || currentPath.endsWith('/index.html') || currentPath.endsWith('/')) { | ||
| window.location.href = latestVersion + '/'; | ||
| } |
| """Generate versions.json for multi-version documentation.""" | ||
|
|
||
| import json | ||
| import os |
| """Helper script for filtering versions to maintain buffer size.""" | ||
|
|
||
| import re | ||
| from pathlib import Path |
|
|
||
| - name: Upload docs artifact | ||
| if: github.event_name == 'push' && github.ref == 'refs/heads/main' | ||
| if: github.event_name == 'push' |
| NVIDIA_DRIVER_CAPABILITIES: all | ||
| NVIDIA_VISIBLE_DEVICES: all | ||
| NVIDIA_DISABLE_REQUIRE: 1 | ||
| DOCS_VERSIONS: "main,v0.2.0" # Versions to include in multi-version build |
| @rm -rf "$(BUILDDIR)/html" | ||
| @echo "Building multi-version documentation..." | ||
| @sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS) $(O) | ||
| @cp "$(SOURCEDIR)/_templates/index.html" "$(BUILDDIR)/html/index.html" |
There was a problem hiding this comment.
Pull request overview
This PR introduces a manual multi-version documentation build/publish approach (replacing sphinx-multiversion) by building each version into its own subdirectory and generating a shared versions.json plus a root redirect to the “latest” docs.
Changes:
- Adds scripts to generate a versions manifest and root redirect, plus helpers for version retention.
- Updates Sphinx configuration/templates to display a version selector in the sidebar.
- Extends the GitHub Actions workflow and docs Makefile/docs instructions for multi-version builds.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| docs/source/quick_start/docs.md | Updates docs build instructions for local and multi-version workflows. |
| docs/source/conf.py | Adjusts Sphinx HTML config and sidebar composition to include a version selector. |
| docs/source/_templates/versioning.html | Adds a custom sidebar template implementing the version dropdown populated from versions.json. |
| docs/source/_templates/index.html | Adds a redirect HTML template (currently hard-coded to main). |
| docs/source/_static/version-redirect.js | Adds a JS-based redirect helper (currently not referenced/loaded). |
| docs/scripts/generate_versions_json.py | Generates versions.json and a root index.html redirect based on built version directories. |
| docs/scripts/build_versions.py | Adds a helper to filter/prune versions to keep a bounded set. |
| docs/requirements.txt | Removes sphinx-multiversion from the docs dependency set. |
| docs/Makefile | Adds a current-docs target for local/PR documentation builds. |
| .github/workflows/main.yml | Updates CI to build and publish versioned docs and to retain/prune older releases. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| .PHONY: current-docs | ||
| current-docs: | ||
| @rm -rf "$(BUILDDIR)/html" | ||
| @$(SPHINXBUILD) -W --keep-going "$(SOURCEDIR)" "$(BUILDDIR)/html" $(SPHINXOPTS) $(O) |
| # Write root index.html redirect | ||
| index_path = html_dir / "index.html" | ||
| index_content = ( | ||
| "<!DOCTYPE html>\n" | ||
| "<html><head>\n" | ||
| f" <title>EmbodiChain Docs</title>\n" | ||
| f' <meta http-equiv="refresh" content="0; url=./{latest}/index.html">\n' | ||
| "</head></html>\n" | ||
| ) | ||
| index_path.write_text(index_content) | ||
| print(f"Generated {index_path} (redirects to ./{latest}/index.html)") |
| Then you can preview the documentation in your browser at `docs/build/html/index.html`. | ||
|
|
| html_context = { | ||
| "github_user": "dexforce", | ||
| "github_repo": "EmbodiChain", | ||
| "github_version": "main", |
| data.versions.forEach(function(v) { | ||
| var opt = document.createElement("option"); | ||
| opt.value = base + "/" + v.name + "/index.html"; | ||
| opt.textContent = v.name + (v.name === data.latest ? " (latest)" : ""); | ||
| if (path.indexOf("/" + v.name + "/") !== -1) { | ||
| opt.selected = true; | ||
| } | ||
| sel.appendChild(opt); |
| <title>Redirecting to the latest EmbodiChain documentation</title> | ||
| <meta charset="utf-8"> | ||
| <meta http-equiv="refresh" content="0; url=./main/index.html"> | ||
| </head> |
| /** | ||
| * Version redirect script for multi-version documentation. | ||
| * Redirects to the latest stable release version, or falls back to 'main'. | ||
| */ | ||
|
|
||
| (function() { | ||
| 'use strict'; | ||
|
|
||
| // Try to fetch versions.json (generated by generate_versions_json.py) | ||
| fetch('versions.json') | ||
| .then(response => { | ||
| if (!response.ok) { | ||
| throw new Error('versions.json not found'); | ||
| } | ||
| return response.json(); | ||
| }) | ||
| .then(data => { | ||
| // Get the latest version from the JSON | ||
| const latestVersion = data.latest || data.versions?.[0]?.name || 'main'; | ||
|
|
||
| const currentPath = window.location.pathname; | ||
|
|
||
| // If we're at root, redirect to latest version | ||
| if (currentPath === '/' || currentPath.endsWith('/index.html') || currentPath.endsWith('/')) { | ||
| window.location.href = latestVersion + '/'; | ||
| } |
| """Helper script for filtering versions to maintain buffer size.""" | ||
|
|
||
| import re | ||
| from pathlib import Path |
| key: docs-output-${{ github.run_id }} | ||
| restore-keys: | | ||
| docs-output- |
Description
This PR adds multi-version documentation support so docs can be built and served across versions with version-aware redirects and metadata.
Summary of changes:
Motivation and context:
Dependencies:
Fixes # (issue)
Type of change
Screenshots
N/A (build/tooling/docs infra changes only)
Checklist
black .command to format the code base. (blackexecutable is not available in the current environment)