Make versions menu work on any web host, not just GitHub Pages - #37
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates the Sphinx-injected versions-menu JavaScript to no longer assume a GitHub Pages URL structure. Instead, it discovers the documentation “root” at runtime by walking up the current URL until it finds versions.json, enabling the menu to work on non-github.io hosts, and updates tests/docs accordingly.
Changes:
- Replaced GH-Pages-specific URL logic with an async runtime discovery (
versions.jsonsearch upwards from current URL). - Removed
json_fileandcurrent_foldertemplate variables and adjusted tests/custom templates. - Updated README/docs and added migration notes in
HISTORY.rst.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
src/docs_versions_menu/_template/docs-versions-menu.js_t |
Implements runtime root discovery and preserves GitHub URL auto-detection as a fallback. |
src/docs_versions_menu/ext.py |
Removes hardcoded template variables and changes default github_project_url behavior. |
tests/test_extension.py |
Updates expectations for the new template outputs. |
tests/test_extension/roots/test-custom/_templates/doctr-versions-menu.js_t |
Updates legacy custom template used in tests to remove deleted template variables. |
README.rst |
Documents the new auto-discovery behavior. |
docs/sphinx_extension.rst |
Updates extension docs to match the new hosting assumptions. |
HISTORY.rst |
Adds migration notes for removed template variables and new behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Replace the hardcoded GitHub Pages URL assumptions with an async discovery approach: walk up the current URL until versions.json is found (urlExists HEAD check). This removes the json_file and current_folder template variables from ext.py; github_project_url now defaults to None instead of auto-detecting from github.io URLs. Keep getGithubProjectUrl(rootUrl) as a runtime JS function and use nullish coalescing so the conf.py setting takes precedence but github.io URLs still get auto-detected when the setting is null. Add migration notes to HISTORY.rst. Closes #25. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
goerz
force-pushed
the
work-outside-github
branch
from
June 30, 2026 02:25
50afb38 to
a976ef7
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Replace the hardcoded GitHub Pages URL assumptions with an async discovery approach: walk up the current URL until versions.json is found (urlExists HEAD check). This removes the json_file and current_folder template variables from ext.py; github_project_url now defaults to None instead of auto-detecting from github.io URLs.
Keep getGithubProjectUrl(rootUrl) as a runtime JS function and use nullish coalescing so the conf.py setting takes precedence but github.io URLs still get auto-detected when the setting is null.
Add migration notes to HISTORY.rst.
Closes #25.