-
Notifications
You must be signed in to change notification settings - Fork 3.4k
Replace sphinx-multiversion with per-branch docs builds #5227
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
a8d3abe
Replace sphinx-multiversion with per-branch docs builds
AntoineRichard 0454178
Address review feedback on docs workflow
AntoineRichard dcaef8b
Harden workflows and JS per code review findings
AntoineRichard 9a948b6
Fix remaining review findings
AntoineRichard f7f0eb7
Replace docs.yaml with docs-release.yml
AntoineRichard cb13815
Fix dead sparse-checkout entry and lexicographic version sorting
AntoineRichard e864af5
Add stable alias and semver-aware sorting to docs migration
AntoineRichard File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,194 @@ | ||
| # Copyright (c) 2022-2026, The Isaac Lab Project Developers (https://github.com/isaac-sim/IsaacLab/blob/main/CONTRIBUTORS.md). | ||
| # All rights reserved. | ||
| # | ||
| # SPDX-License-Identifier: BSD-3-Clause | ||
|
|
||
| name: Docs Migration | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| dry_run: | ||
| description: "Dry run (build but don't deploy)" | ||
| required: false | ||
| default: "false" | ||
| type: choice | ||
| options: | ||
| - "false" | ||
| - "true" | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| jobs: | ||
| build-version: | ||
| name: Build ${{ matrix.ref }} | ||
| runs-on: ubuntu-latest | ||
| strategy: | ||
| matrix: | ||
| ref: | ||
| - main | ||
| - develop | ||
| - release/2.1.0 | ||
| - release/2.2.0 | ||
| - release/2.3.0 | ||
| - v1.0.0 | ||
| - v1.1.0 | ||
| - v1.2.0 | ||
| - v1.3.0 | ||
| - v1.4.0 | ||
| - v1.4.1 | ||
| - v2.0.0 | ||
| - v2.0.1 | ||
| - v2.0.2 | ||
| - v2.1.0 | ||
| - v2.1.1 | ||
| - v2.2.0 | ||
| - v2.2.1 | ||
| - v2.3.0 | ||
| - v2.3.1 | ||
| - v2.3.2 | ||
| - v3.0.0-beta | ||
| fail-fast: false | ||
|
|
||
| steps: | ||
| - name: Checkout ref | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| ref: ${{ matrix.ref }} | ||
|
|
||
| - name: Setup python | ||
| uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 | ||
| with: | ||
| python-version: "3.12" | ||
| architecture: x64 | ||
|
|
||
| - name: Install dev requirements | ||
| working-directory: ./docs | ||
| run: pip install -r requirements.txt | ||
|
|
||
| - name: Determine slug | ||
| id: slug | ||
| env: | ||
| REF: ${{ matrix.ref }} | ||
| run: | | ||
| # For branches with slashes, replace / with - | ||
| SLUG="${REF//\//-}" | ||
| echo "slug=$SLUG" >> "$GITHUB_OUTPUT" | ||
| echo "Slug: $SLUG" | ||
|
|
||
| - name: Build docs | ||
| working-directory: ./docs | ||
| env: | ||
| # Set the version slug so conf.py (on branches that have it) can | ||
| # configure the theme switcher's version_match correctly. | ||
| DOCS_VERSION_SLUG: ${{ steps.slug.outputs.slug }} | ||
| # No -W flag: old versions may have warnings that are acceptable. | ||
| run: | | ||
| rm -rf "_build" | ||
| sphinx-build -b html . "_build" | ||
|
|
||
| - name: Upload artifact | ||
| uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 | ||
| with: | ||
| name: docs-${{ steps.slug.outputs.slug }} | ||
| path: ./docs/_build | ||
|
|
||
| deploy-all: | ||
| name: Deploy All Versions | ||
| runs-on: ubuntu-latest | ||
| needs: [build-version] | ||
| if: ${{ inputs.dry_run == 'false' }} | ||
| permissions: | ||
| contents: write | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||
| with: | ||
| sparse-checkout: | | ||
| docs/_static/version-switcher.js | ||
| docs/_redirect/index.html | ||
|
|
||
| - name: Download all artifacts | ||
| uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | ||
| with: | ||
| path: ./artifacts | ||
|
|
||
| - name: Assemble site | ||
| run: | | ||
| mkdir -p site | ||
|
|
||
| # Move each artifact into its versioned directory | ||
| for dir in artifacts/docs-*; do | ||
| SLUG="${dir#artifacts/docs-}" | ||
| echo "Assembling: $SLUG" | ||
| cp -r "$dir" "site/${SLUG}" | ||
| done | ||
|
|
||
| # Inject version-switcher.js into every HTML file across all versions | ||
| find site/ -name "*.html" -exec sed -i \ | ||
| 's|</body>|<script src="/IsaacLab/version-switcher.js"></script></body>|' {} + | ||
|
|
||
| # Verify injection | ||
| TOTAL=$(find site/ -name "*.html" | wc -l) | ||
| INJECTED=$(grep -rl 'version-switcher.js' site/ --include="*.html" | wc -l) | ||
| echo "Injected version-switcher.js into ${INJECTED}/${TOTAL} HTML files" | ||
| if [ "$TOTAL" -gt 0 ] && [ "$INJECTED" -eq 0 ]; then | ||
| echo "::error::version-switcher.js injection found zero matches in ${TOTAL} HTML files" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Copy static assets to root | ||
| cp docs/_static/version-switcher.js site/version-switcher.js | ||
| cp docs/_redirect/index.html site/index.html | ||
|
|
||
| - name: Generate versions.json | ||
| run: | | ||
| python3 << 'PYEOF' | ||
| import json, os, sys | ||
|
|
||
| versions = [] | ||
| for name in sorted(os.listdir('site')): | ||
| path = os.path.join('site', name) | ||
| if not os.path.isdir(path): | ||
| continue | ||
| versions.append({ | ||
| 'name': name, | ||
| 'version': name, | ||
| 'url': '/IsaacLab/' + name + '/', | ||
| }) | ||
|
|
||
| if not versions: | ||
| print('::error::No version directories found in site/') | ||
| sys.exit(1) | ||
|
|
||
| # Sort: branches first, then releases, then tags | ||
| def sort_key(v): | ||
| s = v['version'] | ||
| if s == 'main': | ||
| return (0, s) | ||
| elif s == 'develop': | ||
| return (1, s) | ||
| elif s.startswith('release-'): | ||
| return (2, s) | ||
| else: | ||
| return (3, s) | ||
|
|
||
| versions.sort(key=sort_key) | ||
|
|
||
| with open('site/versions.json', 'w') as f: | ||
| json.dump(versions, f, indent=2) | ||
| f.write('\n') | ||
|
|
||
| print(f'Generated versions.json with {len(versions)} entries:') | ||
| for v in versions: | ||
| print(f' {v["version"]}') | ||
| PYEOF | ||
|
|
||
| - name: Deploy to gh-pages | ||
| uses: peaceiris/actions-gh-pages@4f9cc6602d3f66b9c108549d475ec49e8ef4d45e # v4.0.0 | ||
| with: | ||
| github_token: ${{ secrets.GITHUB_TOKEN }} | ||
| publish_dir: ./site | ||
| keep_files: false | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DOCS_VERSION_SLUGnot passed to migration buildsFor branches that already carry the updated
conf.py(main,develop,release/2.1.0,release/2.2.0,release/2.3.0),_version_slugwill fall back to the semver from theVERSIONfile (e.g."3.0.0") instead of the directory slug (e.g."main"). The pydata-sphinx-theme built-in switcher usesversion_matchto highlight the current version; a mismatch means no version is highlighted and users lose orientation. The regulardocs.yamlsets this variable correctly: