Skip to content

Commit c28d38e

Browse files
authored
First beta: update generation of next "What's New" (#245)
1 parent a738d97 commit c28d38e

File tree

3 files changed

+86
-0
lines changed

3 files changed

+86
-0
lines changed

run_release.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,6 +188,7 @@
188188
------------
189189
190190
* TODO
191+
191192
Porting to Python {version}
192193
----------------------
193194
@@ -1180,12 +1181,34 @@ def maybe_prepare_new_main_branch(db: ReleaseShelf) -> None:
11801181
cwd=db["git_repo"],
11811182
)
11821183

1184+
whatsnew_toctree_file = "Doc/whatsnew/index.rst"
1185+
with cd(db["git_repo"]):
1186+
update_whatsnew_toctree(db, whatsnew_toctree_file)
1187+
1188+
subprocess.check_call(
1189+
["git", "add", whatsnew_toctree_file],
1190+
cwd=db["git_repo"],
1191+
)
1192+
11831193
subprocess.check_call(
11841194
["git", "commit", "-a", "-m", f"Python {new_release}"],
11851195
cwd=db["git_repo"],
11861196
)
11871197

11881198

1199+
def update_whatsnew_toctree(db: ReleaseShelf, filename: str) -> None:
1200+
release_tag: release_mod.Tag = db["release"]
1201+
this_rst = f" {release_tag.major}.{release_tag.minor}.rst"
1202+
next_rst = f" {release_tag.major}.{release_tag.minor+1}.rst"
1203+
new = next_rst + "\n" + this_rst
1204+
1205+
with open(filename) as f:
1206+
contents = f.read()
1207+
contents = contents.replace(this_rst, new)
1208+
with open(filename, "w") as f:
1209+
f.write(contents)
1210+
1211+
11891212
def branch_new_versions(db: ReleaseShelf) -> None:
11901213
release_tag: release_mod.Tag = db["release"]
11911214

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)