-
Notifications
You must be signed in to change notification settings - Fork 1.1k
[DOC] Fix Edit on Github
sidebar link always points to latest commit
#2460
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This pull request fixes the "Edit on GitHub" link in the stable documentation sidebar so that it correctly points to the repository version corresponding to the build, rather than always defaulting to the main branch.
- Update the whatsnew documentation to describe the link fix.
- Introduce a new helper function get_source_files_base_url() in conf.py to dynamically determine the correct GitHub URL based on RTD environment variables.
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
File | Description |
---|---|
docs/sphinx/source/whatsnew/v0.12.1.rst | Updates documentation to include the fix for sidebar link accuracy. |
docs/sphinx/source/conf.py | Adds a helper function to dynamically generate GitHub URLs for source links. |
Comments suppressed due to low confidence (1)
docs/sphinx/source/conf.py:429
- [nitpick] Consider defining the default GitHub repository URL as a constant and factoring out common URL suffixes (such as "/blob/main/") to improve maintainability and ease potential future changes to the URL structure.
repo_url = os.environ.get("READTHEDOCS_GIT_CLONE_URL", default="https://github.com/pvlib/pvlib-python")
kevin dont get me wrong, i'm not an ai fanboy
@echedey-ls Do you have an example file/function where this currently is an issue? That seems to be the easiest way to verify that it works, by comparing it to the readthedocs compilation in this PR. |
@AdamRJensen you've got a point. Currently PRs are made to point to I can't make up the PR correct url (username + branch name) cause RTD is unaware of that info of PRs (GitHub permissions thing). That's what they call external. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree testing this is not straightforward. It looks right to me, and it sounds like @echedey-ls has done about as much local testing as is possible here, so I'm inclined to merge it and come back to verify that it worked after the next release.
Nice job @echedey-ls!
[ ] Tests added[ ] Updates entries indocs/sphinx/source/reference
for API changes.docs/sphinx/source/whatsnew
for all changes. Includes link to the GitHub Issue with:issue:`num`
or this Pull Request with:pull:`num`
. Includes contributor name and/or GitHub username (link with:ghuser:`user`
).remote-data
) and Milestone are assigned to the Pull Request and linked Issue.Fix
Edit on GitHub
links on the right sidebar in stable docs point to latest commit in main, so there is a mismatch if code lines were added/deleted since the last stable release (or a 404 if file got deleted).The fix consists in switching the base repo url from
https://github.com/pvlib/pvlib-python/blob/main
to e.g.https://github.com/pvlib/pvlib-python/blob/v0.11.1
depending on the environment variables set by ReadTheDocs at build time. RTD docs on that: https://docs.readthedocs.com/platform/stable/reference/environment-variables.htmlAnother possibility for "latest" builds is to point to the specific commit, but I doubt that is any useful.
Sidenote for pull requests: it's impossible to link to their repo since user + branch name are unknown by RTD.
Local builds will default to main branch files.
Edit:
Here is my testing strategy, in Python interpreter: