Skip to content

Commit 73fe37e

Browse files
committed
Automatically add new branch 'What's New' to toctree
1 parent d892bf9 commit 73fe37e

File tree

3 files changed

+85
-0
lines changed

3 files changed

+85
-0
lines changed

run_release.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,12 +1169,34 @@ def maybe_prepare_new_main_branch(db: ReleaseShelf) -> None:
11691169
cwd=db["git_repo"],
11701170
)
11711171

1172+
whatsnew_toctree_file = "Doc/whatsnew/index.rst"
1173+
with cd(db["git_repo"]):
1174+
update_whatsnew_toctree(db, whatsnew_toctree_file)
1175+
1176+
subprocess.check_call(
1177+
["git", "add", whatsnew_toctree_file],
1178+
cwd=db["git_repo"],
1179+
)
1180+
11721181
subprocess.check_call(
11731182
["git", "commit", "-a", "-m", f"Python {new_release}"],
11741183
cwd=db["git_repo"],
11751184
)
11761185

11771186

1187+
def update_whatsnew_toctree(db: ReleaseShelf, filename: str) -> None:
1188+
release_tag: release_mod.Tag = db["release"]
1189+
this_rst = f" {release_tag.major}.{release_tag.minor}.rst"
1190+
next_rst = f" {release_tag.major}.{release_tag.minor+1}.rst"
1191+
new = next_rst + "\n" + this_rst
1192+
1193+
with open(filename) as f:
1194+
contents = f.read()
1195+
contents = contents.replace(this_rst, new)
1196+
with open(filename, "w") as f:
1197+
f.write(contents)
1198+
1199+
11781200
def branch_new_versions(db: ReleaseShelf) -> None:
11791201
release_tag: release_mod.Tag = db["release"]
11801202

tests/test_run_release.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,3 +208,20 @@ def test_modify_the_docs_by_version_page_final_yes(capsys, monkeypatch) -> None:
208208
"* `Python 3.13.3 <https://docs.python.org/release/3.13.3/>`_, documentation released on"
209209
in capsys.readouterr().out
210210
)
211+
212+
213+
def test_update_whatsnew_toctree(tmp_path: Path) -> None:
214+
# Arrange
215+
# Only first beta triggers update
216+
db = {"release": Tag("3.14.0b1")}
217+
218+
original_toctree_file = Path(__file__).parent / "whatsnew_index.rst"
219+
toctree__file = tmp_path / "patchlevel.h"
220+
toctree__file.write_text(original_toctree_file.read_text())
221+
222+
# Act
223+
run_release.update_whatsnew_toctree(cast(ReleaseShelf, db), str(toctree__file))
224+
225+
# Assert
226+
new_contents = toctree__file.read_text()
227+
assert " 3.15.rst\n 3.14.rst\n" in new_contents

tests/whatsnew_index.rst

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
.. _whatsnew-index:
2+
3+
######################
4+
What's New in Python
5+
######################
6+
7+
The "What's New in Python" series of essays takes tours through the most
8+
important changes between major Python versions. They are a "must read" for
9+
anyone wishing to stay up-to-date after a new release.
10+
11+
.. toctree::
12+
:maxdepth: 2
13+
14+
3.14.rst
15+
3.13.rst
16+
3.12.rst
17+
3.11.rst
18+
3.10.rst
19+
3.9.rst
20+
3.8.rst
21+
3.7.rst
22+
3.6.rst
23+
3.5.rst
24+
3.4.rst
25+
3.3.rst
26+
3.2.rst
27+
3.1.rst
28+
3.0.rst
29+
2.7.rst
30+
2.6.rst
31+
2.5.rst
32+
2.4.rst
33+
2.3.rst
34+
2.2.rst
35+
2.1.rst
36+
2.0.rst
37+
38+
The "Changelog" is an HTML version of the :pypi:`file built<blurb>`
39+
from the contents of the
40+
:source:`Misc/NEWS.d` directory tree, which contains *all* nontrivial changes
41+
to Python for the current version.
42+
43+
.. toctree::
44+
:maxdepth: 2
45+
46+
changelog.rst

0 commit comments

Comments
 (0)