| 39 | ISSUE_URI = "https://github.com/python/cpython/issues/{0}" |
| 40 | |
| 41 | def run(self) -> tuple[list[Element], list[nodes.system_message]]: |
| 42 | issue = self.text |
| 43 | |
| 44 | # sanity check: all GitHub issues have ID >= 32426 |
| 45 | # even though some of them are also valid BPO IDs |
| 46 | if int(issue) < 32_426: |
| 47 | msg = self.inliner.reporter.error( |
| 48 | f"The GitHub ID {issue!r} seems too low. " |
| 49 | "Use :issue:`...` for BPO IDs.", |
| 50 | line=self.lineno, |
| 51 | ) |
| 52 | prb = self.inliner.problematic(self.rawtext, self.rawtext, msg) |
| 53 | return [prb], [msg] |
| 54 | |
| 55 | issue_url = self.ISSUE_URI.format(issue) |
| 56 | refnode = nodes.reference(issue, f"gh-{issue}", refuri=issue_url) |
| 57 | self.set_source_info(refnode) |
| 58 | return [refnode], [] |
| 59 | |
| 60 | |
| 61 | def setup(app: Sphinx) -> ExtensionMetadata: |