Skip to content

Make versions menu work on any web host, not just GitHub Pages - #37

Merged
goerz merged 1 commit into
masterfrom
work-outside-github
Jun 30, 2026
Merged

Make versions menu work on any web host, not just GitHub Pages#37
goerz merged 1 commit into
masterfrom
work-outside-github

Conversation

@goerz

@goerz goerz commented Jun 29, 2026

Copy link
Copy Markdown
Owner

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.json search upwards from current URL).
  • Removed json_file and current_folder template 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.

Comment thread src/docs_versions_menu/_template/docs-versions-menu.js_t Outdated
Comment thread src/docs_versions_menu/_template/docs-versions-menu.js_t
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
goerz force-pushed the work-outside-github branch from 50afb38 to a976ef7 Compare June 30, 2026 02:25
@goerz
goerz merged commit 4b5dc9d into master Jun 30, 2026
6 checks passed
@goerz
goerz deleted the work-outside-github branch June 30, 2026 02:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Doesn't work outside github pages

2 participants