Skip to content

Commit 6aee778

Browse files
Integrate Towncrier configuration (#823)
* Move changelog out of README into a separate file * Expose the changelog to Sphinx * Integrate Towncrier configuration into the repo * Include the change fragment docs in Sphinx * Add a config for the Chronographer GitHub App * Add a change note for PR #823 * Update CHANGELOG.md Co-authored-by: Abhinav Singh <[email protected]>
1 parent af31564 commit 6aee778

File tree

13 files changed

+282
-31
lines changed

13 files changed

+282
-31
lines changed

.github/chronographer.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
enforce_name:
3+
suffix: .md
4+
exclude:
5+
bots:
6+
- dependabot-preview
7+
- dependabot
8+
- patchback
9+
humans:
10+
- pyup-bot
11+
...

CHANGELOG.md

+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<!-- markdownlint-disable no-duplicate-heading -->
2+
# Changelog
3+
4+
All notable changes to this project will be documented in this file.
5+
6+
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
7+
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
8+
9+
<!-- towncrier release notes start -->
10+
11+
12+
## v2.x
13+
14+
- No longer ~~a single file module~~.
15+
- Added support for threadless execution.
16+
- Added dashboard app.
17+
- Added support for unit testing.
18+
19+
## v1.x
20+
21+
- `Python3` only.
22+
- Deprecated support for ~~Python 2.x~~.
23+
- Added support multi core accept.
24+
- Added plugin support.
25+
26+
## v0.x
27+
28+
- Single file.
29+
- Single threaded server.
30+
31+
For detailed changelog refer to release PRs or commit history.

README.md

+4-31
Original file line numberDiff line numberDiff line change
@@ -111,10 +111,10 @@
111111
- [Sending a Pull Request](#sending-a-pull-request)
112112
- [Benchmarks](#benchmarks)
113113
- [Flags](#flags)
114-
- [Changelog](#changelog)
115-
- [v2.x](#v2x)
116-
- [v1.x](#v1x)
117-
- [v0.x](#v0x)
114+
- [Changelog](https://proxypy.rtfd.io/en/latest/changelog)
115+
- [v2.x](https://proxypy.rtfd.io/en/latest/changelog#v2x)
116+
- [v1.x](https://proxypy.rtfd.io/en/latest/changelog#v1x)
117+
- [v0.x](https://proxypy.rtfd.io/en/latest/changelog#v0x)
118118

119119
[//]: # (DO-NOT-REMOVE-docs-badges-END)
120120

@@ -2216,30 +2216,3 @@ options:
22162216
Proxy.py not working? Report at:
22172217
https://github.com/abhinavsingh/proxy.py/issues/new
22182218
```
2219-
2220-
# Changelog
2221-
2222-
## v2.4.0
2223-
2224-
- No longer support `Python 3.6` due to `asyncio.run` usage in the core.
2225-
2226-
## v2.x
2227-
2228-
- No longer ~~a single file module~~.
2229-
- Added support for threadless execution.
2230-
- Added dashboard app.
2231-
- Added support for unit testing.
2232-
2233-
## v1.x
2234-
2235-
- `Python3` only.
2236-
- Deprecated support for ~~Python 2.x~~.
2237-
- Added support multi core accept.
2238-
- Added plugin support.
2239-
2240-
## v0.x
2241-
2242-
- Single file.
2243-
- Single threaded server.
2244-
2245-
For detailed changelog refer to release PRs or commit history.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
{% for section, _ in sections.items() %}
3+
{% set title_prefix = underlines[0] %}
4+
{% if section %}
5+
{{ title_prefix }} {{ section }}
6+
{% set title_prefix = underlines[1] %}
7+
{% endif %}
8+
9+
{% if sections[section] %}
10+
{% for category, val in definitions.items() if category in sections[section] %}
11+
{{ title_prefix }} {{ definitions[category]['name'] }}
12+
{% if definitions[category]['showcontent'] %}
13+
14+
{% for text, values in sections[section][category].items() %}
15+
* {{ text }}
16+
({{ values|join(',\n ') }})
17+
{% endfor -%}
18+
19+
{% else %}
20+
* {{ sections[section][category]['']|join(', ') }}
21+
{% endif %}
22+
23+
{% if sections[section][category]|length == 0 %}
24+
No significant changes.
25+
{% endif %}
26+
{% endfor %}
27+
28+
{% else %}
29+
No significant changes.
30+
{% endif %}
31+
{% endfor %}

docs/changelog-fragments.d/.gitignore

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
*
2+
!.CHANGELOG-TEMPLATE.md.j2
3+
!.gitignore
4+
!README.md
5+
!*.bugfix
6+
!*.bugfix.md
7+
!*.bugfix.*.md
8+
!*.breaking
9+
!*.breaking.md
10+
!*.breaking.*.md
11+
!*.deprecation
12+
!*.deprecation.md
13+
!*.deprecation.*.md
14+
!*.doc
15+
!*.doc.md
16+
!*.doc.*.md
17+
!*.feature
18+
!*.feature.md
19+
!*.feature.*.md
20+
!*.internal
21+
!*.internal.md
22+
!*.internal.*.md
23+
!*.misc
24+
!*.misc.md
25+
!*.misc.*.md
+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Added changelog fragment management infrastructure using [Towncrier]
2+
-- by {user}`webknjaz`
3+
4+
[Towncrier]: https://github.com/twisted/towncrier

docs/changelog-fragments.d/README.md

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
# Adding change notes with your PRs
2+
3+
It is very important to maintain a log for news of how
4+
updating to the new version of the software will affect
5+
end-users. This is why we enforce collection of the change
6+
fragment files in pull requests as per [Towncrier philosophy].
7+
8+
The idea is that when somebody makes a change, they must record
9+
the bits that would affect end-users only including information
10+
that would be useful to them. Then, when the maintainers publish
11+
a new release, they'll automatically use these records to compose
12+
a change log for the respective version. It is important to
13+
understand that including unnecessary low-level implementation
14+
related details generates noise that is not particularly useful
15+
to the end-users most of the time. And so such details should be
16+
recorded in the Git history rather than a changelog.
17+
18+
# Alright! So how do I add a news fragment?
19+
20+
To submit a change note about your PR, add a text file into the
21+
`docs/changelog-fragments.d/` folder. It should contain an
22+
explanation of what applying this PR will change in the way
23+
end-users interact with the project. One sentence is usually
24+
enough but feel free to add as many details as you feel necessary
25+
for the users to understand what it means.
26+
27+
**Use the past tense** for the text in your fragment because,
28+
combined with others, it will be a part of the "news digest"
29+
telling the readers **what changed** in a specific version of
30+
the library *since the previous version*. You should also use
31+
[MyST Markdown] syntax for highlighting code (inline or block),
32+
linking parts of the docs or external sites.
33+
At the end, sign your change note by adding ```-- by
34+
{user}`github-username``` (replace `github-username` with
35+
your own!).
36+
37+
Finally, name your file following the convention that Towncrier
38+
understands: it should start with the number of an issue or a
39+
PR followed by a dot, then add a patch type, like `feature`,
40+
`bugfix`, `doc`, `misc` etc., and add `.md` as a suffix. If you
41+
need to add more than one fragment, you may add an optional
42+
sequence number (delimited with another period) between the type
43+
and the suffix.
44+
45+
# Examples for changelog entries adding to your Pull Requests
46+
47+
File `docs/changelog-fragments.d/112.doc.md`:
48+
49+
```md
50+
Added a `{user}` role to Sphinx config -- by {user}`webknjaz`
51+
```
52+
53+
File `docs/changelog-fragments.d/105.feature.md`:
54+
55+
```md
56+
Added the support for keyboard-authentication method
57+
-- by {user}`Qalthos`
58+
```
59+
60+
File `docs/changelog-fragments.d/57.bugfix.md`:
61+
62+
```md
63+
Fixed flaky SEGFAULTs in `pylibsshext.channel.Channel.exec_command()`
64+
calls -- by {user}`ganeshrn`
65+
```
66+
67+
```{tip}
68+
See `pyproject.toml` for all available categories
69+
(`tool.towncrier.type`).
70+
```
71+
72+
73+
[MyST Markdown]:
74+
https://myst-parser.rtfd.io/en/latest/syntax/syntax.html
75+
[Towncrier philosophy]:
76+
https://towncrier.rtfd.io/en/actual-freaking-docs/#philosophy

docs/changelog.md

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
```{spelling}
2+
Changelog
3+
```
4+
5+
```{include} ../CHANGELOG.md
6+
```

docs/conf.py

+7
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,13 @@
118118
# Usually you set "language" from the command line for these cases.
119119
language = 'en'
120120

121+
# List of patterns, relative to source directory, that match files and
122+
# directories to ignore when looking for source files.
123+
# This pattern also affects html_static_path and html_extra_path.
124+
exclude_patterns = [
125+
'changelog-fragments.d/**', # Towncrier-managed change notes
126+
]
127+
121128

122129
# -- Options for HTML output -------------------------------------------------
123130

docs/contributing/guidelines.md

+4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ de
33
facto
44
Pre
55
reStructuredText
6+
Towncrier
67
```
78

89
```{include} ../../CONTRIBUTING.md
@@ -32,3 +33,6 @@ the docs <myst:intro/writing>` to learn more on how to use it.
3233
[MyST parser]: https://pypi.org/project/myst-parser/
3334
[Read The Docs]: https://readthedocs.org
3435
[Sphinx]: https://www.sphinx-doc.org
36+
37+
```{include} ../changelog-fragments.d/README.md
38+
```

docs/index.md

+1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ Scalable
2828
```{toctree}
2929
:hidden:
3030
31+
changelog
3132
Glossary <glossary>
3233
```
3334

pyproject.toml

+47
Original file line numberDiff line numberDiff line change
@@ -11,3 +11,50 @@ build-backend = "setuptools.build_meta"
1111

1212
[tool.setuptools_scm]
1313
write_to = "proxy/common/_scm_version.py"
14+
15+
[tool.towncrier]
16+
directory = "docs/changelog-fragments.d/"
17+
filename = "CHANGELOG.md"
18+
issue_format = "{{issue}}`{issue}`"
19+
start_string = "<!-- towncrier release notes start -->\n\n"
20+
template = "docs/changelog-fragments.d/.CHANGELOG-TEMPLATE.md.j2"
21+
title_format = "## [{version}] - {project_date}"
22+
underlines = ["##", "###", "####", "#####"]
23+
24+
[[tool.towncrier.section]]
25+
path = ""
26+
27+
[[tool.towncrier.type]]
28+
directory = "bugfix"
29+
name = "Bugfixes"
30+
showcontent = true
31+
32+
[[tool.towncrier.type]]
33+
directory = "feature"
34+
name = "Features"
35+
showcontent = true
36+
37+
[[tool.towncrier.type]]
38+
directory = "deprecation"
39+
name = "Deprecations (removal in next major release)"
40+
showcontent = true
41+
42+
[[tool.towncrier.type]]
43+
directory = "breaking"
44+
name = "Backward incompatible changes"
45+
showcontent = true
46+
47+
[[tool.towncrier.type]]
48+
directory = "doc"
49+
name = "Documentation"
50+
showcontent = true
51+
52+
[[tool.towncrier.type]]
53+
directory = "misc"
54+
name = "Miscellaneous"
55+
showcontent = true
56+
57+
[[tool.towncrier.type]]
58+
directory = "internal"
59+
name = "Contributor-facing changes"
60+
showcontent = true

tox.ini

+35
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,41 @@ skip_install = {[testenv:build-docs]skip_install}
153153
usedevelop = {[testenv:build-docs]usedevelop}
154154

155155

156+
[testenv:make-changelog]
157+
basepython = python3
158+
depends =
159+
check-changelog
160+
description =
161+
Generate a changelog from fragments using Towncrier. Getting an
162+
unreleased changelog preview does not require extra arguments.
163+
When invoking to update the changelog, pass the desired version as an
164+
argument after `--`. For example, `tox -e {envname} -- 1.3.2`.
165+
commands =
166+
{envpython} -m \
167+
towncrier.build \
168+
--version \
169+
{posargs:'[UNRELEASED DRAFT]' --draft}
170+
deps =
171+
towncrier == 21.3.0
172+
isolated_build = true
173+
skip_install = true
174+
175+
176+
[testenv:check-changelog]
177+
basepython = {[testenv:make-changelog]basepython}
178+
description =
179+
Check Towncrier change notes
180+
commands =
181+
{envpython} -m \
182+
towncrier.check \
183+
--compare-with origin/main \
184+
{posargs:}
185+
deps =
186+
{[testenv:make-changelog]deps}
187+
isolated_build = {[testenv:make-changelog]isolated_build}
188+
skip_install = {[testenv:make-changelog]skip_install}
189+
190+
156191
[testenv:cleanup-dists]
157192
description =
158193
Wipe the the `{env:PEP517_OUT_DIR}{/}` folder

0 commit comments

Comments
 (0)