DM-55634: Backport the Edit on GitHub source-directory fix to 2.4 - #355
Merged
Conversation
Cherry-picks PR #352 onto the 2.4 release branch. The button now resolves its in-repository path from the Sphinx source directory rather than the directory holding conf.py, so projects building with 'sphinx-build -c . docs ...' no longer emit 404 links, and a source directory at the repository root no longer yields a stray './'. Adapted for 2.4, which predates several things the original touched: - _toml.py drops the ._utils import entirely rather than narrowing it; normalize_origin_base_url and the storage clients don't exist here. - The test-guide and test-linkcheck-service* roots don't exist yet, so only test-redoc is relaxed. - test_conf_toml.py takes only the three set_edit_on_github guard tests; the link-check service cases belong to a later feature. - tests/ext/conftest.py comes along because tests/roots/test-redoc also builds the guide preset, and without the module-eviction fixture the two guide-stack builds would share cached settings. Verified on this branch with tox: py-test-sphinx8 (84 passed), typing-sphinx8, lint, and docs all pass.
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.
Summary
Backport of #352 onto the new
2.4release branch, for a 2.4.x patch release.conf.py. Projects that build withsphinx-build -c . docs _build/html(where those differ) no longer emit links that 404 — this is what https://dp2.lsst.io/ hits today. A source directory at the repository root also no longer produces a stray./.documenteer.ext.githubeditlinkextension atconfig-inited, the earliest event wheresrcdiris known. An explicitly configuredhtml_context["doc_path"]is honored and short-circuits auto-detection.InvalidGitRepositoryErrorat configuration time; the button is omitted instead.Backport adaptations
The
2.4branch predates several things the original PR touched, so this is not a clean replay:_toml.pydrops its._utilsimport entirely rather than narrowing it —normalize_origin_base_urland the storage clients don't exist on 2.4.test-guideandtest-linkcheck-service*roots don't exist yet, so onlytest-redocis relaxed (and gains agithub_url, sinceshow_github_edit_linknow defaults on).tests/test_conf_toml.pytakes only the threeset_edit_on_githubguard tests; the link-check service cases belong to a later feature.tests/ext/conftest.pyis brought along, becausetests/roots/test-redocalso builds the guide preset — without the module-eviction fixture, the two guide-stack builds in one pytest process would share cached settings.Validation steps
Run against this branch's own tooling (2.4 uses tox, not nox):
All four pass locally. The suite includes the wiring test that drives the real guide preset in the
-c ./docslayout, which was confirmed onmainto fail if the extension is unregistered.References