-
Notifications
You must be signed in to change notification settings - Fork 80
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
Fix accidental deletion of GitHub source links for methods #940
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.
Thank you!
scripts/lib/api/processHtml.test.ts
Outdated
expect(result).toEqual( | ||
`<a href="https://github.com/Qiskit/qiskit/blob/stable/1.0/qiskit/utils/deprecation.py#L24-L101" title="view source code">GitHub</a>`, | ||
` <a href="https://github.com/Qiskit/qiskit/blob/stable/1.0/qiskit/utils/deprecation.py#L24-L101" title="view source code">GitHub</a>`, |
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.
Is the extra space important? If so maybe a quick comment so we don't delete it at some point in the future
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.
Part of Qiskit#517. Turns out that we would accidentally delete all the GitHub links for methods because we were using `closest().remove()` rather than `.closest().first().remove()`. That means that we'd only have the link for the class definition and not individual methods, which defeats the point of precise source code links from Qiskit#517. ## Historical API docs However, the behavior to not show methods is actually quite sensible for our API docs, where we were using `sphinx.ext.viewcode` rather than `sphinx.ext.linkcode`. That meant that we could only link to the overall file, rather than specific line numbers. So, it's not very useful to keep linking to the overall file for every method since they will each have the same value and the class definition already has the value. So, we check if the link is for a method and proactively remove it if so. This change to proactively remove method links changes some historical API doc versions, but not others. Why? It only removes the links if we were doing method inlining, where the method had a dedicated HTML page originally. That's because the `.remove()` line wouldn't impat the distinct HTML pages.
Part of #517.
Turns out that we would accidentally delete all the GitHub links for methods because we were using
closest().remove()
rather than.closest().first().remove()
. That means that we'd only have the link for the class definition and not individual methods, which defeats the point of precise source code links from #517.Historical API docs
However, the behavior to not show methods is actually quite sensible for our API docs, where we were using
sphinx.ext.viewcode
rather thansphinx.ext.linkcode
. That meant that we could only link to the overall file, rather than specific line numbers. So, it's not very useful to keep linking to the overall file for every method since they will each have the same value and the class definition already has the value. So, we check if the link is for a method and proactively remove it if so.This change to proactively remove method links changes some historical API doc versions, but not others. Why? It only removes the links if we were doing method inlining, where the method had a dedicated HTML page originally. That's because the
.remove()
line wouldn't impat the distinct HTML pages.