Skip to content

Commit

Permalink
Fix "Edit on GitHub" button to always point to develop branch
Browse files Browse the repository at this point in the history
  • Loading branch information
r0qs committed Oct 7, 2024
1 parent 293bd7f commit f847758
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 1 deletion.
7 changes: 6 additions & 1 deletion docs/_static/js/initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,12 @@ const updateActiveNavLink = () => {
document.addEventListener("locationchange", updateActiveNavLink);

function updateGitHubEditPath() {
// Replaces the version number in the GitHub edit path with "develop"
// Replaces the version number in the GitHub edit path with "develop" if it exists.
// This is to ensure that the edit path always points to the `develop` branch instead of the specific version branch.
// Note that it will fail silently if the anchor element is not found, i.e. the page is not editable or
// if the sphinx_rtd_theme is updated to a version that changes the anchor element.
// See: https://github.com/readthedocs/sphinx_rtd_theme/blob/a1c2147b17cbf0e57b7d7a6450ad4d9a5ff362cf/sphinx_rtd_theme/breadcrumbs.html#L35
// TODO: We should consider a more robust way to handle this in the future.
const gitHubEditAnchor = document.querySelector(".wy-breadcrumbs-aside > a");
if (!gitHubEditAnchor) return;

Expand Down
7 changes: 7 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ def setup(sphinx):

# -- General configuration ------------------------------------------------

html_context = {
"display_github": True,
"github_user": "ethereum",
"github_repo": "solidity",
"github_version": os.getenv("READTHEDOCS_VERSION", "develop"),
"conf_py_path": "/docs/",
}
# If your documentation needs a minimal Sphinx version, state it here.
#needs_sphinx = '1.0'

Expand Down

0 comments on commit f847758

Please sign in to comment.