(self)
| 43 | option_spec = {} |
| 44 | |
| 45 | def run(self) -> list[Node]: |
| 46 | # Get content of NEWS file |
| 47 | source, _ = self.get_source_info() |
| 48 | news_file = Path(source).resolve().parent / self.arguments[0] |
| 49 | self.env.note_dependency(news_file) |
| 50 | try: |
| 51 | news_text = news_file.read_text(encoding="utf-8") |
| 52 | except (OSError, UnicodeError): |
| 53 | text = sphinx_gettext("The NEWS file is not available.") |
| 54 | return [nodes.strong(text, text)] |
| 55 | |
| 56 | # remove first 3 lines as they are the main heading |
| 57 | news_text = news_text.removeprefix(BLURB_HEADER) |
| 58 | |
| 59 | news_text = bpo_issue_re.sub(r":issue:`\1`", news_text) |
| 60 | # Fallback handling for GitHub issues |
| 61 | news_text = gh_issue_re.sub(r":gh:`\1`", news_text) |
| 62 | news_text = whatsnew_re.sub(r"\1", news_text) |
| 63 | |
| 64 | self.state_machine.insert_input(news_text.splitlines(), str(news_file)) |
| 65 | return [] |
| 66 | |
| 67 | |
| 68 | def setup(app: Sphinx) -> ExtensionMetadata: |
no test coverage detected