diff --git a/.github/workflows/docs-dev.yml b/.github/workflows/docs-dev.yml new file mode 100644 index 000000000000..bc0919d4a099 --- /dev/null +++ b/.github/workflows/docs-dev.yml @@ -0,0 +1,120 @@ +# 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 (dev) + +on: + push: + branches: + - develop + pull_request: + branches: + - develop + types: [opened, synchronize, reopened] + +permissions: + contents: read + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + check-secrets: + name: Check Secrets + runs-on: ubuntu-latest + outputs: + trigger-deploy: ${{ steps.trigger-deploy.outputs.defined }} + + steps: + - id: trigger-deploy + env: + REPO_NAME: ${{ secrets.REPO_NAME }} + if: github.repository == env.REPO_NAME && github.ref == 'refs/heads/develop' + run: echo "defined=true" >> "$GITHUB_OUTPUT" + + build-docs: + name: Build Docs + runs-on: ubuntu-latest + + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + + - 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: Build docs + working-directory: ./docs + env: + DOCS_VERSION_SLUG: develop + run: make current-docs + + - name: Upload docs artifact + uses: actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0 + with: + name: docs-html + path: ./docs/_build + + deploy-docs: + name: Deploy Docs + runs-on: ubuntu-latest + needs: [check-secrets, build-docs] + if: needs.check-secrets.outputs.trigger-deploy == 'true' + permissions: + contents: write + # Serialize deploys to avoid race conditions on versions.json. + concurrency: + group: docs-deploy-gh-pages + cancel-in-progress: false + + steps: + - name: Checkout code + uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 + with: + sparse-checkout: | + docs/_static/version-switcher.js + + - name: Download docs artifact + uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 + with: + name: docs-html + path: ./artifact + + - name: Assemble deploy directory + run: | + mkdir -p site + + # Copy built docs into /develop/ subdirectory + cp -r artifact/current "site/develop" + + # Inject version-switcher.js into every HTML file + find "site/develop" -name "*.html" -exec sed -i \ + 's|||' {} + + + # Verify injection + TOTAL=$(find "site/develop" -name "*.html" | wc -l) + INJECTED=$(grep -rl 'version-switcher.js' "site/develop" --include="*.html" | wc -l) + echo "Injected version-switcher.js into ${INJECTED}/${TOTAL} HTML files" + if [ "$TOTAL" -gt 0 ] && [ "$INJECTED" -ne "$TOTAL" ]; then + echo "::warning::version-switcher.js injection missed $((TOTAL - INJECTED)) of ${TOTAL} HTML files" + fi + + # Copy version-switcher.js to site root + cp docs/_static/version-switcher.js site/version-switcher.js + + - 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: true diff --git a/.github/workflows/docs-migration.yaml b/.github/workflows/docs-migration.yaml new file mode 100644 index 000000000000..4679b7e1f490 --- /dev/null +++ b/.github/workflows/docs-migration.yaml @@ -0,0 +1,236 @@ +# 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|||' {} + + + # 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: Create stable alias + run: | + # Find the latest semver tag directory (highest version number) + LATEST_TAG="" + for dir in site/v*; do + [ -d "$dir" ] || continue + TAG="${dir#site/}" + if [ -z "$LATEST_TAG" ] || python3 -c " + import sys, re + def vt(s): return tuple(int(n) for n in re.findall(r'\d+', s)) + sys.exit(0 if vt(sys.argv[1]) > vt(sys.argv[2]) else 1) + " "$TAG" "$LATEST_TAG" 2>/dev/null; then + LATEST_TAG="$TAG" + fi + done + + if [ -n "$LATEST_TAG" ]; then + echo "Creating /stable/ from ${LATEST_TAG}" + cp -r "site/${LATEST_TAG}" "site/stable" + # Update root redirect to point to /stable/ + cat > site/index.html << 'HTMLEOF' + + + + Redirecting to the latest Isaac Lab documentation + + + + + +

Redirecting to Isaac Lab documentation...

+ + + HTMLEOF + else + echo "No tag directories found, skipping /stable/ creation" + fi + + - name: Generate versions.json + run: | + python3 << 'PYEOF' + import json, os, re, 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 _version_tuple(s): + """Extract numeric parts for semver-aware sorting.""" + return tuple(int(n) for n in re.findall(r'\d+', s)) + + def sort_key(v): + s = v['version'] + if s == 'main': + return (0, ()) + elif s == 'develop': + return (1, ()) + elif s.startswith('release-'): + return (2, _version_tuple(s)) + else: + return (3, _version_tuple(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 diff --git a/.github/workflows/docs.yaml b/.github/workflows/docs.yaml deleted file mode 100644 index 2469a838eea5..000000000000 --- a/.github/workflows/docs.yaml +++ /dev/null @@ -1,129 +0,0 @@ -# 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 - -on: - push: - branches: - - main - - develop - - 'release/**' - - 'feature/isaacsim-6-0' - pull_request: - # we're skipping the branches and paths filter to allow docs to be built on any PR because heredoc is used - # additionally, we have a check that determines what version of docs will be built - types: [opened, synchronize, reopened] - -concurrency: - group: ${{ github.workflow }}-${{ github.ref }} - cancel-in-progress: true - -jobs: - doc-build-type: - name: Detect Doc Build Type - runs-on: ubuntu-latest - outputs: - trigger-deploy: ${{ steps.trigger-deploy.outputs.defined }} - steps: - - id: trigger-deploy - env: - REPO_NAME: ${{ secrets.REPO_NAME }} - if: "${{ github.repository == env.REPO_NAME && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' || startsWith(github.ref, 'refs/heads/release/')) }}" - run: echo "defined=true" >> "$GITHUB_OUTPUT"; echo "Docs will be built multi-version and deployed" - - build-latest-docs: - name: Build Latest Docs - runs-on: ubuntu-latest - needs: [doc-build-type] - # run on non-deploy branches to build current version docs only - if: needs.doc-build-type.outputs.trigger-deploy != 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: "3.12" - architecture: x64 - - - name: Install dev requirements - working-directory: ./docs - run: pip install -r requirements.txt - - - name: Build current version docs - working-directory: ./docs - run: make current-docs - - - name: Upload docs artifact - uses: actions/upload-artifact@v7 - with: - name: docs-html - path: ./docs/_build - - build-multi-docs: - name: Build Multi-Version Docs - runs-on: ubuntu-latest - needs: [doc-build-type] - # run on deploy branches to create multi-version docs - if: needs.doc-build-type.outputs.trigger-deploy == 'true' - - steps: - - name: Checkout code - uses: actions/checkout@v6 - - - name: Setup python - uses: actions/setup-python@v5 - with: - python-version: "3.12" - architecture: x64 - - - name: Install dev requirements - working-directory: ./docs - run: pip install -r requirements.txt - - - name: Generate multi-version docs - working-directory: ./docs - env: - # When triggered from develop, build only the develop branch, no tags or main. - # Branches main and release/* will build main + release/* + tags. - # This way each main branch does not overwrite develop content, - # provided keep_files is true for gh-pages action. - SMV_BRANCH_WHITELIST: ${{ github.ref == 'refs/heads/develop' && '^develop$' || '^(main|release/.*)$' }} - SMV_TAG_WHITELIST: ${{ github.ref == 'refs/heads/develop' && '^$' || '^v[1-9]\d*\.\d+\.\d+$' }} - run: | - git fetch --prune --unshallow --tags - git checkout --detach HEAD - git for-each-ref --format="%(refname:short)" refs/heads/ | xargs -r git branch -D - make multi-docs - - - name: Upload docs artifact - uses: actions/upload-artifact@v7 - with: - name: docs-html - path: ./docs/_build - - deploy-docs: - name: Deploy Docs - runs-on: ubuntu-latest - needs: [doc-build-type, build-multi-docs] - # deploy only on "deploy" branches - if: needs.doc-build-type.outputs.trigger-deploy == 'true' - - steps: - - name: Download docs artifact - uses: actions/download-artifact@v8 - with: - name: docs-html - path: ./docs/_build - - - name: Deploy to gh-pages - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./docs/_build - keep_files: true diff --git a/docs/Makefile b/docs/Makefile index 0bff236671c8..002fdd60070a 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -8,11 +8,6 @@ SPHINXBUILD ?= sphinx-build SOURCEDIR = . BUILDDIR = _build -.PHONY: multi-docs -multi-docs: - @sphinx-multiversion "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) - @cp _redirect/index.html $(BUILDDIR)/index.html - .PHONY: current-docs current-docs: @rm -rf "$(BUILDDIR)/current" diff --git a/docs/_static/version-switcher.js b/docs/_static/version-switcher.js new file mode 100644 index 000000000000..62bf86ed07b2 --- /dev/null +++ b/docs/_static/version-switcher.js @@ -0,0 +1,120 @@ +// 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 + +/** + * Standalone version switcher for Isaac Lab documentation. + * + * Injected into every version's HTML during deploy. Fetches versions.json + * and renders a floating dropdown. Skips rendering if the pydata-sphinx-theme + * built-in switcher is already present on the page. + */ +(function () { + "use strict"; + + // Skip if pydata-sphinx-theme's built-in switcher is present. + if (document.querySelector(".version-switcher__container")) { + return; + } + + // Resolve the base URL for the docs site. + // Works for both /IsaacLab/main/... and custom domain setups. + var pathParts = window.location.pathname.split("/").filter(Boolean); + // Expect at least ///... + var basePath = "/" + pathParts[0] + "/"; + var currentSlug = pathParts[1] || ""; + // The relative page path within the version (e.g. "api/index.html"). + var pagePath = pathParts.slice(2).join("/") || "index.html"; + + var JSON_URL = basePath + "versions.json"; + + function createSwitcher(versions) { + // Container + var container = document.createElement("div"); + container.id = "isaaclab-version-switcher"; + + // Label + var label = document.createElement("label"); + label.textContent = "Version: "; + label.setAttribute("for", "isaaclab-version-select"); + container.appendChild(label); + + // Select + var select = document.createElement("select"); + select.id = "isaaclab-version-select"; + for (var i = 0; i < versions.length; i++) { + var v = versions[i]; + var option = document.createElement("option"); + option.value = v.url; + option.textContent = v.name; + if (v.version === currentSlug) { + option.selected = true; + } + select.appendChild(option); + } + select.addEventListener("change", function () { + var targetBase = select.value; + // Try to navigate to the same page under the new version. + var targetUrl = targetBase + pagePath; + // Use a HEAD request to check if the page exists; fall back to index. + var xhr = new XMLHttpRequest(); + xhr.open("HEAD", targetUrl, true); + xhr.onload = function () { + window.location.href = xhr.status < 400 ? targetUrl : targetBase; + }; + xhr.onerror = function () { + window.location.href = targetBase; + }; + xhr.send(); + }); + container.appendChild(select); + + // Styles + var style = document.createElement("style"); + style.textContent = + "#isaaclab-version-switcher {" + + " position: fixed; top: 10px; right: 10px; z-index: 9999;" + + " background: #2b2b2b; color: #e0e0e0; padding: 6px 12px;" + + " border-radius: 6px; font-family: sans-serif; font-size: 13px;" + + " box-shadow: 0 2px 8px rgba(0,0,0,0.3);" + + "}" + + "#isaaclab-version-switcher label {" + + " margin-right: 4px; font-weight: bold;" + + "}" + + "#isaaclab-version-switcher select {" + + " background: #3c3c3c; color: #e0e0e0; border: 1px solid #555;" + + " border-radius: 4px; padding: 2px 6px; font-size: 13px;" + + "}" + + "@media (prefers-color-scheme: light) {" + + " #isaaclab-version-switcher { background: #f5f5f5; color: #333; }" + + " #isaaclab-version-switcher select { background: #fff; color: #333; border-color: #ccc; }" + + "}"; + document.head.appendChild(style); + document.body.appendChild(container); + } + + // Fetch versions.json and build the switcher. + var xhr = new XMLHttpRequest(); + xhr.open("GET", JSON_URL, true); + xhr.onload = function () { + if (xhr.status === 200) { + try { + var versions = JSON.parse(xhr.responseText); + if (!Array.isArray(versions)) { + console.warn("[version-switcher] versions.json is not an array"); + return; + } + createSwitcher(versions); + } catch (e) { + console.warn("[version-switcher] Failed to parse versions.json:", e.message); + } + } else if (xhr.status !== 0) { + console.warn("[version-switcher] versions.json returned HTTP", xhr.status); + } + }; + xhr.onerror = function () { + console.warn("[version-switcher] Network error fetching", JSON_URL); + }; + xhr.send(); +})(); diff --git a/docs/_templates/versioning.html b/docs/_templates/versioning.html deleted file mode 100644 index eb67be60e1c4..000000000000 --- a/docs/_templates/versioning.html +++ /dev/null @@ -1,21 +0,0 @@ -{% if versions %} - -{% endif %} diff --git a/docs/conf.py b/docs/conf.py index fae8e4937088..631cdbf1d993 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -52,6 +52,10 @@ full_version = f.read().strip() version = ".".join(full_version.split(".")[:3]) +# CI sets DOCS_VERSION_SLUG (e.g. "main", "develop", "v2.3.2") for the +# version switcher. Local builds fall back to the semver from VERSION. +_version_slug = os.getenv("DOCS_VERSION_SLUG") or version + # -- General configuration --------------------------------------------------- # Add any Sphinx extension module names here, as strings. They can be @@ -74,7 +78,6 @@ "sphinx_copybutton", "sphinx_design", "sphinx_tabs.tabs", # backwards compatibility for building docs on v1.0.0 - "sphinx_multiversion", ] # mathjax hacks @@ -149,7 +152,17 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. # This pattern also affects html_static_path and html_extra_path. -exclude_patterns = ["_build", "_redirect", "_templates", "Thumbs.db", ".DS_Store", "README.md", "licenses/*", "plans"] +exclude_patterns = [ + "_build", + "_redirect", + "_templates", + "Thumbs.db", + ".DS_Store", + "README.md", + "licenses/*", + "plans", + "superpowers", +] # Mock out modules that are not available on RTD autodoc_mock_imports = [ @@ -230,6 +243,11 @@ # analysis. Since those hints are actual hints that *CANNOT* by definition # by canonicalized, our only recourse is to squelch warnings altogether. "ref.python", + # The pydata-sphinx-theme version switcher fetches versions.json at build + # time to validate it. Before the first deploy, the file does not exist on + # gh-pages, causing a 404 that becomes a warning. Suppress it so -W builds + # don't fail on PRs. + "config.invalid_switcher_json", ] # -- Internationalization ---------------------------------------------------- @@ -290,21 +308,14 @@ }, ], "icon_links_label": "Quick Links", + "switcher": { + "json_url": "https://isaac-sim.github.io/IsaacLab/versions.json", + "version_match": _version_slug, + }, + "navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"], } -templates_path = [ - "_templates", -] - -# Whitelist pattern for remotes -smv_remote_whitelist = r"^.*$" -# Whitelist pattern for branches (set to None to ignore all branches) -smv_branch_whitelist = os.getenv("SMV_BRANCH_WHITELIST", r"^(main|develop|release/.*)$") -# Whitelist pattern for tags (set to None to ignore all tags) -smv_tag_whitelist = os.getenv("SMV_TAG_WHITELIST", r"^v[1-9]\d*\.\d+\.\d+$") -html_sidebars = { - "**": ["navbar-logo.html", "versioning.html", "icon-links.html", "search-field.html", "sbt-sidebar-nav.html"] -} +html_sidebars = {"**": ["navbar-logo.html", "icon-links.html", "search-field.html", "sbt-sidebar-nav.html"]} # -- Advanced configuration ------------------------------------------------- diff --git a/docs/requirements.txt b/docs/requirements.txt index 392951b0a8ee..6682b350400f 100644 --- a/docs/requirements.txt +++ b/docs/requirements.txt @@ -9,7 +9,6 @@ sphinx-icon sphinx_design sphinxemoji sphinx-tabs # backwards compatibility for building docs on v1.0.0 -sphinx-multiversion==0.2.4 # basic python numpy diff --git a/docs/superpowers/specs/2026-04-10-multi-version-docs-design.md b/docs/superpowers/specs/2026-04-10-multi-version-docs-design.md new file mode 100644 index 000000000000..9b7b02de61de --- /dev/null +++ b/docs/superpowers/specs/2026-04-10-multi-version-docs-design.md @@ -0,0 +1,281 @@ +# Multi-Version Documentation Build Redesign + +**Date:** 2026-04-10 +**Status:** Draft +**Author:** Antoine Richard + +## Problem + +IsaacLab uses `sphinx-multiversion==0.2.4` (unmaintained since 2020) to build +multi-version documentation. This tool installs a single Sphinx version and +builds all branches/tags against it, causing: + +- **No dependency isolation.** All versions share one Sphinx install. When + Sphinx 9.0 changed `Config.read()` to keyword-only parameters, every version + broke simultaneously. +- **Slow CI.** Every push rebuilds every whitelisted branch and tag. +- **Fragile version coupling.** Upgrading Sphinx or the theme on one branch + forces compatibility with every historical branch/tag. + +Large projects (NumPy, CPython) solve this with per-version CI builds and a +JSON-driven version switcher. This spec describes migrating IsaacLab to that +pattern. + +## Goals + +1. Each branch/tag builds with its own `docs/requirements.txt` (full isolation). +2. Only the pushed branch rebuilds on each CI run (fast). +3. Old version HTML stays frozen on gh-pages; no rebuild unless the branch is + updated. +4. A version switcher dropdown works on all versions, including old tags that + predate this migration. +5. Remove the `sphinx-multiversion` dependency entirely. + +## Non-Goals + +- Changing the hosting target (stays on gh-pages). +- Pruning old versions from the published docs (can be done later). +- Changing the Sphinx theme. + +## Architecture + +### Build Model + +Each push to a deploy branch (`main`, `develop`, `release/**`) or creation of a +version tag (`v*.*.*`) triggers a CI job that: + +1. Checks out that single ref. +2. Installs dependencies from that ref's `docs/requirements.txt`. +3. Runs `sphinx-build` to produce HTML. +4. Deploys the output to a versioned subdirectory on gh-pages. + +``` +Push to develop -> build -> deploy to gh-pages/develop/ +Push to main -> build -> deploy to gh-pages/main/ +Push to release/2.3.0 -> build -> deploy to gh-pages/release-2.3.0/ +Tag v3.1.0 created -> build -> deploy to gh-pages/v3.1.0/ +``` + +PRs build docs with `-W` (warnings as errors) for validation but do not deploy. + +### Version Slug Mapping + +| Git Ref | Slug | URL Path | +|-----------------------------|-------------------|---------------------------| +| `refs/heads/main` | `main` | `/IsaacLab/main/` | +| `refs/heads/develop` | `develop` | `/IsaacLab/develop/` | +| `refs/heads/release/2.3.0` | `release-2.3.0` | `/IsaacLab/release-2.3.0/`| +| `refs/tags/v2.3.2` | `v2.3.2` | `/IsaacLab/v2.3.2/` | + +Slugs are derived by stripping `refs/heads/` or `refs/tags/` and replacing `/` +with `-` for release branches. + +### Version Switcher + +New versions (main, develop, future releases) use the `pydata-sphinx-theme` +built-in version switcher, which `sphinx-book-theme` inherits. It is configured +via `html_theme_options` in `conf.py` and driven by a `versions.json` file. + +Old versions (tags/branches that predate this migration) get a standalone +JavaScript-based version switcher injected during the deploy step. + +#### `versions.json` + +Hosted at the root of gh-pages (`/IsaacLab/versions.json`). Updated +automatically by each deploy job (fetch current file, upsert entry, write back). + +```json +[ + {"name": "main", "version": "main", "url": "/IsaacLab/main/"}, + {"name": "develop", "version": "develop", "url": "/IsaacLab/develop/"}, + {"name": "v2.3.2 (stable)", "version": "v2.3.2", "url": "/IsaacLab/v2.3.2/", "preferred": true}, + {"name": "v2.3.1", "version": "v2.3.1", "url": "/IsaacLab/v2.3.1/"} +] +``` + +#### `conf.py` Changes (New Versions) + +```python +# Determine the version slug for the switcher. +# CI sets DOCS_VERSION_SLUG (e.g. "main", "develop", "v2.3.2"). +# Locally, fall back to the semver from the VERSION file. +_version_slug = os.getenv("DOCS_VERSION_SLUG", version) + +html_theme_options = { + # ... existing options ... + "switcher": { + "json_url": "https://isaac-sim.github.io/IsaacLab/versions.json", + "version_match": _version_slug, + }, + "navbar_end": ["version-switcher", "theme-switcher", "navbar-icon-links"], +} +``` + +The CI workflow sets `DOCS_VERSION_SLUG` to the computed slug (e.g. `main`, +`develop`, `release-2.3.0`, `v2.3.2`) so the switcher highlights the correct +entry. Local builds fall back to the semver from the `VERSION` file. + +#### Injected Switcher (Old Versions) + +A standalone `version-switcher.js` file hosted at `/IsaacLab/version-switcher.js`. +Maintained in the repo at `docs/_static/version-switcher.js` and deployed to +the gh-pages root on every deploy. + +**Behavior:** + +- Fetches `/IsaacLab/versions.json` on page load. +- Renders a floating dropdown (fixed position, top-right corner). +- Detects the current version from the URL path. +- Highlights the current version in the dropdown. +- On selection, navigates to the same relative page path under the new version, + with fallback to `index.html` if the page does not exist in that version. +- Detects if the theme's built-in switcher already exists and skips rendering + to avoid duplicates. +- Self-contained styling (injects its own `