| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,69 @@ | ||
| """Support for referencing issues in the tracker.""" | ||
|
|
||
| from __future__ import annotations | ||
|
|
||
| from typing import TYPE_CHECKING | ||
|
|
||
| from docutils import nodes | ||
| from sphinx.util.docutils import SphinxRole | ||
|
|
||
| if TYPE_CHECKING: | ||
| from docutils.nodes import Element | ||
| from sphinx.application import Sphinx | ||
| from sphinx.util.typing import ExtensionMetadata | ||
|
|
||
|
|
||
| class BPOIssue(SphinxRole): | ||
| ISSUE_URI = "https://bugs.python.org/issue?@action=redirect&bpo={0}" | ||
|
|
||
| def run(self) -> tuple[list[Element], list[nodes.system_message]]: | ||
| issue = self.text | ||
|
|
||
| # sanity check: there are no bpo issues within these two values | ||
| if 47_261 < int(issue) < 400_000: | ||
| msg = self.inliner.reporter.error( | ||
| f"The BPO ID {issue!r} seems too high. " | ||
| "Use :gh:`...` for GitHub IDs.", | ||
| line=self.lineno, | ||
| ) | ||
| prb = self.inliner.problematic(self.rawtext, self.rawtext, msg) | ||
| return [prb], [msg] | ||
|
|
||
| issue_url = self.ISSUE_URI.format(issue) | ||
| refnode = nodes.reference(issue, f"bpo-{issue}", refuri=issue_url) | ||
|
Comment thread
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityHere we're passing something like 12345 and bpo-12345 as the first two arguments. Before we were passing something like bpo-12345 and bpo-12345 for both. I see the second one is used in the refnode: <reference refuri="https://bugs.python.org/issue?@action=redirect&bpo=13936">bpo-13936</reference> How is the first one used?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityIt's the docutils rawsource, it should reflect what was actually written in the document. Sphinx uses this for translation, I don't think these nodes are translatable but I'll double check. A
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySee e.g. https://github.com/python/python-docs-fr/blob/3.13/whatsnew/3.13.po#L394-L399, the whole role is included in the translation string.
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualitySo should it match 12345 or bpo-12345?
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality(Unresolving so the question isn't hidden :)
Sorry, something went wrong.
All reactions
Copy link
Copy Markdown
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low QualityThe text of what is actually written in the document, so "14159".
Sorry, something went wrong.
All reactions
|
||
| self.set_source_info(refnode) | ||
| return [refnode], [] | ||
|
|
||
|
|
||
| class GitHubIssue(SphinxRole): | ||
| ISSUE_URI = "https://github.com/python/cpython/issues/{0}" | ||
|
|
||
| def run(self) -> tuple[list[Element], list[nodes.system_message]]: | ||
| issue = self.text | ||
|
|
||
| # sanity check: all GitHub issues have ID >= 32426 | ||
| # even though some of them are also valid BPO IDs | ||
| if int(issue) < 32_426: | ||
| msg = self.inliner.reporter.error( | ||
| f"The GitHub ID {issue!r} seems too low. " | ||
| "Use :issue:`...` for BPO IDs.", | ||
| line=self.lineno, | ||
| ) | ||
| prb = self.inliner.problematic(self.rawtext, self.rawtext, msg) | ||
| return [prb], [msg] | ||
|
|
||
| issue_url = self.ISSUE_URI.format(issue) | ||
| refnode = nodes.reference(issue, f"gh-{issue}", refuri=issue_url) | ||
| self.set_source_info(refnode) | ||
| return [refnode], [] | ||
|
|
||
|
|
||
| def setup(app: Sphinx) -> ExtensionMetadata: | ||
| app.add_role("issue", BPOIssue()) | ||
| app.add_role("gh", GitHubIssue()) | ||
|
|
||
| return { | ||
| "version": "1.0", | ||
| "parallel_read_safe": True, | ||
| "parallel_write_safe": True, | ||
| } | ||
| Back | FazBrowse Home | New Git URL |
Uh oh!
There was an error while loading. Please reload this page.