Skip to content

Commit b522980

Browse files
committed
Update release conversion logic accordingly
1 parent 7644b54 commit b522980

File tree

2 files changed

+29
-27
lines changed

2 files changed

+29
-27
lines changed

extra/release.py

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -105,10 +105,6 @@ def make_ref_link(ref_id: str, name: str | None = None) -> str:
105105
r.split("/")[-1] for r in refs if r.startswith("plugins/")
106106
)
107107
return [
108-
# Fix nested bullet points indent: use 2 spaces consistently
109-
(r"(?<=\n) {3,4}(?=\*)", " "),
110-
# Fix nested text indent: use 4 spaces consistently
111-
(r"(?<=\n) {5,6}(?=[\w:`])", " "),
112108
# Replace Sphinx :ref: and :doc: directives by documentation URLs
113109
# :ref:`/plugins/autobpm` -> [AutoBPM Plugin](DOCS/plugins/autobpm.html)
114110
(
@@ -124,9 +120,6 @@ def make_ref_link(ref_id: str, name: str | None = None) -> str:
124120
# Convert plugin references to documentation URLs
125121
# `fetchart` plugin -> [fetchart](DOCS/plugins/fetchart.html)
126122
(rf"`+({plugins})`+", lambda m: make_ref_link(f"plugins/{m[1]}")),
127-
# Add additional backticks around existing backticked text to ensure it
128-
# is rendered as inline code in Markdown
129-
(r"(?<=[\s])(`[^`]+`)(?!_)", r"`\1`"),
130123
# Convert bug references to GitHub issue links
131124
(r":bug:`(\d+)`", r":bug: (#\1)"),
132125
# Convert user references to GitHub @mentions
@@ -135,13 +128,12 @@ def make_ref_link(ref_id: str, name: str | None = None) -> str:
135128

136129

137130
MD_REPLACEMENTS: list[Replacement] = [
138-
(r"<span[^>]+>([^<]+)</span>", r"_\1"), # remove a couple of wild span refs
139131
(r"^(\w[^\n]{,80}):(?=\n\n[^ ])", r"### \1"), # format section headers
140132
(r"^(\w[^\n]{81,}):(?=\n\n[^ ])", r"**\1**"), # and bolden too long ones
141133
(r"### [^\n]+\n+(?=### )", ""), # remove empty sections
142134
]
143135
order_bullet_points = partial(
144-
re.compile("(\n- .*?(?=\n(?! *- )|$))", flags=re.DOTALL).sub,
136+
re.compile("(\n- .*?(?=\n(?! *(-|\d\.) )|$))", flags=re.DOTALL).sub,
145137
lambda m: "\n- ".join(sorted(m.group().split("\n- "))),
146138
)
147139

@@ -230,6 +222,7 @@ def rst2md(text: str) -> str:
230222

231223

232224
def get_changelog_contents() -> str | None:
225+
return CHANGELOG.read_text()
233226
if m := RST_LATEST_CHANGES.search(CHANGELOG.read_text()):
234227
return m.group(1)
235228

@@ -241,6 +234,8 @@ def changelog_as_markdown(rst: str) -> str:
241234
for pattern, repl in create_rst_replacements():
242235
rst = re.sub(pattern, repl, rst, flags=re.M | re.DOTALL)
243236

237+
Path("new_new_changelog.rst").write_text(rst)
238+
244239
md = rst2md(rst)
245240

246241
for pattern, repl in MD_REPLACEMENTS:

test/test_release.py

Lines changed: 25 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -22,29 +22,36 @@
2222
def rst_changelog():
2323
return """New features:
2424
25-
* :doc:`/plugins/substitute`: Some substitute
25+
- :doc:`/plugins/substitute`: Some substitute
2626
multi-line change.
2727
:bug:`5467`
28-
* :ref:`list-cmd` Update.
28+
- :ref:`list-cmd` Update.
2929
30-
You can do something with this command::
30+
You can do something with this command:
31+
32+
::
3133
3234
$ do-something
3335
3436
Bug fixes:
3537
36-
* Some fix that refers to an issue.
38+
- Some fix that refers to an issue.
3739
:bug:`5467`
38-
* Some fix that mentions user :user:`username`.
39-
* Some fix thanks to
40+
- Some fix that mentions user :user:`username`.
41+
- Some fix thanks to
4042
:user:`username`. :bug:`5467`
41-
* Some fix with its own bullet points using incorrect indentation:
42-
* First nested bullet point
43-
with some text that wraps to the next line
44-
* Second nested bullet point
45-
* Another fix with its own bullet points using correct indentation:
46-
* First
47-
* Second
43+
- Some fix with its own bullet points using incorrect indentation:
44+
45+
- First nested bullet point
46+
with some text that wraps to the next line
47+
- Second nested bullet point
48+
49+
- Another fix with an enumerated list
50+
51+
1. First
52+
and some details
53+
2. Second
54+
and some details
4855
4956
Section naaaaaaaaaaaaaaaaaaaaaaaammmmmmmmmmmmmmmmeeeeeeeeeeeeeee with over 80
5057
characters:
@@ -53,7 +60,7 @@ def rst_changelog():
5360
5461
Other changes:
5562
56-
* Changed `bitesize` label to `good first issue`. Our `contribute`_ page is now
63+
- Changed ``bitesize`` label to ``good first issue``. Our `contribute`_ page is now
5764
automatically populated with these issues. :bug:`4855`
5865
5966
.. _contribute: https://github.com/beetbox/beets/contribute
@@ -63,7 +70,7 @@ def rst_changelog():
6370
6471
Bug fixes:
6572
66-
* Fixed something."""
73+
- Fixed something."""
6774

6875

6976
@pytest.fixture
@@ -79,9 +86,9 @@ def md_changelog():
7986
8087
### Bug fixes
8188
82-
- Another fix with its own bullet points using correct indentation:
83-
- First
84-
- Second
89+
- Another fix with an enumerated list
90+
1. First and some details
91+
2. Second and some details
8592
- Some fix thanks to @username. :bug: (#5467)
8693
- Some fix that mentions user @username.
8794
- Some fix that refers to an issue. :bug: (#5467)

0 commit comments

Comments
 (0)