Update release conversion logic accordingly

This commit is contained in:
Šarūnas Nejus 2025-08-08 17:15:26 +01:00
parent ab5acaabb3
commit 13080c17a3
No known key found for this signature in database
GPG key ID: DD28F6704DBE3435
2 changed files with 26 additions and 27 deletions

View file

@ -105,10 +105,6 @@ def create_rst_replacements() -> list[Replacement]:
r.split("/")[-1] for r in refs if r.startswith("plugins/") r.split("/")[-1] for r in refs if r.startswith("plugins/")
) )
return [ return [
# Fix nested bullet points indent: use 2 spaces consistently
(r"(?<=\n) {3,4}(?=\*)", " "),
# Fix nested text indent: use 4 spaces consistently
(r"(?<=\n) {5,6}(?=[\w:`])", " "),
# Replace Sphinx :ref: and :doc: directives by documentation URLs # Replace Sphinx :ref: and :doc: directives by documentation URLs
# :ref:`/plugins/autobpm` -> [AutoBPM Plugin](DOCS/plugins/autobpm.html) # :ref:`/plugins/autobpm` -> [AutoBPM Plugin](DOCS/plugins/autobpm.html)
( (
@ -124,9 +120,6 @@ def create_rst_replacements() -> list[Replacement]:
# Convert plugin references to documentation URLs # Convert plugin references to documentation URLs
# `fetchart` plugin -> [fetchart](DOCS/plugins/fetchart.html) # `fetchart` plugin -> [fetchart](DOCS/plugins/fetchart.html)
(rf"`+({plugins})`+", lambda m: make_ref_link(f"plugins/{m[1]}")), (rf"`+({plugins})`+", lambda m: make_ref_link(f"plugins/{m[1]}")),
# Add additional backticks around existing backticked text to ensure it
# is rendered as inline code in Markdown
(r"(?<=[\s])(`[^`]+`)(?!_)", r"`\1`"),
# Convert bug references to GitHub issue links # Convert bug references to GitHub issue links
(r":bug:`(\d+)`", r":bug: (#\1)"), (r":bug:`(\d+)`", r":bug: (#\1)"),
# Convert user references to GitHub @mentions # Convert user references to GitHub @mentions
@ -135,13 +128,12 @@ def create_rst_replacements() -> list[Replacement]:
MD_REPLACEMENTS: list[Replacement] = [ MD_REPLACEMENTS: list[Replacement] = [
(r"<span[^>]+>([^<]+)</span>", r"_\1"), # remove a couple of wild span refs
(r"^(\w[^\n]{,80}):(?=\n\n[^ ])", r"### \1"), # format section headers (r"^(\w[^\n]{,80}):(?=\n\n[^ ])", r"### \1"), # format section headers
(r"^(\w[^\n]{81,}):(?=\n\n[^ ])", r"**\1**"), # and bolden too long ones (r"^(\w[^\n]{81,}):(?=\n\n[^ ])", r"**\1**"), # and bolden too long ones
(r"### [^\n]+\n+(?=### )", ""), # remove empty sections (r"### [^\n]+\n+(?=### )", ""), # remove empty sections
] ]
order_bullet_points = partial( order_bullet_points = partial(
re.compile("(\n- .*?(?=\n(?! *- )|$))", flags=re.DOTALL).sub, re.compile(r"(\n- .*?(?=\n(?! *(-|\d\.) )|$))", flags=re.DOTALL).sub,
lambda m: "\n- ".join(sorted(m.group().split("\n- "))), lambda m: "\n- ".join(sorted(m.group().split("\n- "))),
) )

View file

@ -22,29 +22,36 @@ pytestmark = pytest.mark.skipif(
def rst_changelog(): def rst_changelog():
return """New features: return """New features:
* :doc:`/plugins/substitute`: Some substitute - :doc:`/plugins/substitute`: Some substitute
multi-line change. multi-line change.
:bug:`5467` :bug:`5467`
* :ref:`list-cmd` Update. - :ref:`list-cmd` Update.
You can do something with this command:: You can do something with this command:
::
$ do-something $ do-something
Bug fixes: Bug fixes:
* Some fix that refers to an issue. - Some fix that refers to an issue.
:bug:`5467` :bug:`5467`
* Some fix that mentions user :user:`username`. - Some fix that mentions user :user:`username`.
* Some fix thanks to - Some fix thanks to
:user:`username`. :bug:`5467` :user:`username`. :bug:`5467`
* Some fix with its own bullet points using incorrect indentation: - Some fix with its own bullet points using incorrect indentation:
* First nested bullet point
- First nested bullet point
with some text that wraps to the next line with some text that wraps to the next line
* Second nested bullet point - Second nested bullet point
* Another fix with its own bullet points using correct indentation:
* First - Another fix with an enumerated list
* Second
1. First
and some details
2. Second
and some details
Section naaaaaaaaaaaaaaaaaaaaaaaammmmmmmmmmmmmmmmeeeeeeeeeeeeeee with over 80 Section naaaaaaaaaaaaaaaaaaaaaaaammmmmmmmmmmmmmmmeeeeeeeeeeeeeee with over 80
characters: characters:
@ -53,7 +60,7 @@ Empty section:
Other changes: Other changes:
* Changed `bitesize` label to `good first issue`. Our `contribute`_ page is now - Changed ``bitesize`` label to ``good first issue``. Our `contribute`_ page is now
automatically populated with these issues. :bug:`4855` automatically populated with these issues. :bug:`4855`
.. _contribute: https://github.com/beetbox/beets/contribute .. _contribute: https://github.com/beetbox/beets/contribute
@ -63,7 +70,7 @@ Other changes:
Bug fixes: Bug fixes:
* Fixed something.""" - Fixed something."""
@pytest.fixture @pytest.fixture
@ -79,9 +86,9 @@ You can do something with this command:
### Bug fixes ### Bug fixes
- Another fix with its own bullet points using correct indentation: - Another fix with an enumerated list
- First 1. First and some details
- Second 2. Second and some details
- Some fix thanks to @username. :bug: (#5467) - Some fix thanks to @username. :bug: (#5467)
- Some fix that mentions user @username. - Some fix that mentions user @username.
- Some fix that refers to an issue. :bug: (#5467) - Some fix that refers to an issue. :bug: (#5467)