Skip to content

Commit f90d3c5

Browse files
committed
MAINT: ensure towncrier can be run >1x, and is included in spin docs
This allows accumulating snippets into the main release notes file and committing the result during a release cycle. It will also make Sphinx formatting errors, cross-link issues, etc. visible when docs get built locally. This will allow fixing them as we go, rather than leaving it broken in devdocs and then having to fix it in one go once `towncrier` is run once right before or after creating a release branch. xref numpygh-25921 and numpygh-25827 for recent issues with this. [skip azp] [skip actions] [skip cirrus]
1 parent 15691c3 commit f90d3c5

File tree

8 files changed

+38
-49
lines changed

8 files changed

+38
-49
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ Thumbs.db
120120
#############################
121121
doc/source/savefig/
122122
doc/source/**/generated/
123+
doc/source/release/notes-towncrier.rst
123124

124125
# Things specific to this project #
125126
###################################

.spin/cmds.py

+9
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ def docs(ctx, sphinx_target, clean, first_build, jobs):
162162
163163
"""
164164
meson.docs.ignore_unknown_options = True
165+
166+
# Run towncrier without staging anything for commit. This is the way to get
167+
# release notes snippets included in a local doc build.
168+
cmd = ['towncrier', 'build', '--version', '2.x.y', '--keep', '--draft']
169+
p = subprocess.run(cmd, check=True, capture_output=True, text=True)
170+
outfile = curdir.parent / 'doc' / 'source' / 'release' / 'notes-towncrier.rst'
171+
with open(outfile, 'w') as f:
172+
f.write(p.stdout)
173+
165174
ctx.forward(meson.docs)
166175

167176

doc/RELEASE_WALKTHROUGH.rst

+6-4
Original file line numberDiff line numberDiff line change
@@ -94,10 +94,12 @@ needed information.
9494
Finish the release notes
9595
------------------------
9696

97-
If this is the first release in a series the release note is generated, see
98-
the release note in ``doc/release/upcoming_changes/README.rst`` to see how to
99-
do this. Generating the release notes will also delete all the news
100-
fragment files in ``doc/release/upcoming_changes/``.
97+
If there are any release notes snippets in ``doc/release/upcoming_changes/``,
98+
run ``spin docs`` to build the docs, incorporate the contents of the generated
99+
``doc/source/release/notes-towncrier.rst`` file into the release notes file
100+
(e.g., ``doc/source/release/2.3.4-notes.rst``), and delete the now-processed
101+
snippets in ``doc/release/upcoming_changes/``. This is safe to do multiple
102+
times during a release cycle.
101103

102104
The generated release note will always need some fixups, the introduction will
103105
need to be written, and significant changes should be called out. For patch

doc/release/upcoming_changes/README.rst

+4-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,10 @@ and double-backticks for code.
5050
If you are unsure what pull request type to use, don't hesitate to ask in your
5151
PR.
5252

53-
You can install ``towncrier`` and run ``towncrier build --draft --version 1.18``
54-
if you want to get a preview of how your change will look in the final release
55-
notes.
53+
``towncrier`` is required to build the docs; it will be automatically run when
54+
you build the docs locally with ``spin docs``. You can also run ``towncrier
55+
build --draft --version 1.18`` if you want to get a preview of how your change
56+
will look in the final release notes.
5657

5758
.. note::
5859

doc/release/upcoming_changes/template.rst

+1-7
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,3 @@
1-
{% set title = "NumPy {} Release Notes".format(versiondata.version) %}
2-
{{ "=" * title|length }}
3-
{{ title }}
4-
{{ "=" * title|length }}
5-
61
{% for section, _ in sections.items() %}
72
{% set underline = underlines[0] %}{% if section %}{{ section }}
83
{{ underline * section|length }}{% set underline = underlines[1] %}
@@ -32,8 +27,7 @@ No significant changes.
3227
{% endif %}
3328
{% endfor %}
3429
{% else %}
35-
No significant changes.
36-
30+
(no release note snippets found)
3731

3832
{% endif %}
3933
{% endfor %}

doc/source/release/2.0.0-notes.rst

+8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
.. currentmodule:: numpy
2+
13
=========================
24
NumPy 2.0.0 Release Notes
35
=========================
@@ -1304,3 +1306,9 @@ You can use ``np.logical_or.reduce`` and ``np.logical_and.reduce``
13041306
to achieve the previous behavior.
13051307

13061308
(`gh-25712 <https://github.com/numpy/numpy/pull/25712>`__)
1309+
1310+
1311+
1312+
**Content from release note snippets in doc/release/upcoming_changes:**
1313+
1314+
.. include:: notes-towncrier.rst

doc/source/release/template.rst

+8-32
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,21 @@
11
:orphan:
22

3+
.. currentmodule:: numpy
4+
35
==========================
4-
NumPy 1.xx.x Release Notes
6+
NumPy 2.xx.x Release Notes
57
==========================
68

79

810
Highlights
911
==========
1012

11-
12-
New functions
13-
=============
14-
15-
16-
Deprecations
17-
============
18-
19-
20-
Future Changes
21-
==============
22-
23-
24-
Expired deprecations
25-
====================
26-
27-
28-
Compatibility notes
29-
===================
30-
31-
32-
C API changes
33-
=============
34-
35-
36-
New Features
37-
============
13+
*We'll choose highlights for this release near the end of the release cycle.*
3814

3915

40-
Improvements
41-
============
16+
.. if release snippets have been incorporated already, uncomment the follow
17+
line (leave the `.. include:: directive)
4218
19+
.. **Content from release note snippets in doc/release/upcoming_changes:**
4320
44-
Changes
45-
=======
21+
.. include:: notes-towncrier.rst

pyproject.toml

+1-3
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,8 @@ tracker = "https://github.com/numpy/numpy/issues"
6060
"release notes" = "https://numpy.org/doc/stable/release"
6161

6262
[tool.towncrier]
63-
# Do no set this since it is hard to import numpy inside the source directory
64-
# the name is hardcoded. Use "--version 1.18.0" to set the version
6563
single_file = false
66-
filename = "doc/source/release/{version}-notes.rst"
64+
filename = "doc/source/release/notes-towncrier.rst"
6765
directory = "doc/release/upcoming_changes/"
6866
issue_format = "`gh-{issue} <https://github.com/numpy/numpy/pull/{issue}>`__"
6967
template = "doc/release/upcoming_changes/template.rst"

0 commit comments

Comments
 (0)