Skip to content

Commit 7b4aa2a

Browse files
committed
Strip blurb "Python News" header
1 parent 6f3cb21 commit 7b4aa2a

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

Doc/tools/extensions/misc_news.py

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@
1818
from sphinx.util.typing import ExtensionMetadata
1919

2020

21+
BLURB_HEADER = """\
22+
+++++++++++
23+
Python News
24+
+++++++++++
25+
"""
26+
2127
bpo_issue_re: Final[re.Pattern[str]] = re.compile(
2228
"(?:issue #|bpo-)([0-9]+)", re.ASCII
2329
)
@@ -47,14 +53,15 @@ def run(self) -> list[Node]:
4753
text = sphinx_gettext("The NEWS file is not available.")
4854
return [nodes.strong(text, text)]
4955

56+
# remove first 3 lines as they are the main heading
57+
news_text = news_text.removeprefix(BLURB_HEADER)
58+
5059
news_text = bpo_issue_re.sub(r":issue:`\1`", news_text)
5160
# Fallback handling for GitHub issues
5261
news_text = gh_issue_re.sub(r":gh:`\1`", news_text)
5362
news_text = whatsnew_re.sub(r"\1", news_text)
5463

55-
# remove first 3 lines as they are the main heading
56-
lines = [".. default-role:: py:obj", ""] + news_text.splitlines()[3:]
57-
self.state_machine.insert_input(lines, str(news_file))
64+
self.state_machine.insert_input(news_text.splitlines(), str(news_file))
5865
return []
5966

6067

Doc/whatsnew/changelog.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. _changelog:
22

3+
.. default-role:: py:obj
4+
35
+++++++++
46
Changelog
57
+++++++++

0 commit comments

Comments
 (0)