diff --git a/extra/release.py b/extra/release.py index b8aa28f46..25dc940f5 100755 --- a/extra/release.py +++ b/extra/release.py @@ -19,6 +19,7 @@ from typing_extensions import TypeAlias BASE = Path(__file__).parent.parent.absolute() PYPROJECT = BASE / "pyproject.toml" CHANGELOG = BASE / "docs" / "changelog.rst" +DOCS = "https://beets.readthedocs.io/en/stable" version_header = r"\d+\.\d+\.\d+ \([^)]+\)" RST_LATEST_CHANGES = re.compile( @@ -28,7 +29,7 @@ Replacement: TypeAlias = "tuple[str, str | Callable[[re.Match[str]], str]]" RST_REPLACEMENTS: list[Replacement] = [ (r"(?<=\n) {3,4}(?=\*)", " "), # fix indent of nested bullet points ... (r"(?<=\n) {5,6}(?=[\w:`])", " "), # ... and align wrapped text indent - (r"(?<=[\s(])`([^`]+)`(?=[^_])", r"``\1``"), # ticks with verbatim ranges. + (r"(?<=[\s(])(`[^`]+`)(?!_)", r"`\1`"), # double quotes for inline code (r":bug:`(\d+)`", r":bug: (#\1)"), # Issue numbers. (r":user:`(\w+)`", r"\@\1"), # Users. ] @@ -37,8 +38,8 @@ MD_REPLACEMENTS: list[Replacement] = [ (r"^ +( - )", r"\1"), # adjust nested bullet points indent (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"^- `/?plugins/(\w+)`:?", r"- Plugin **`\1`**:"), # highlight plugins - (r"^- `(\w+)-cmd`:?", r"- Command **`\1`**:"), # highlight commands + (r"^- `/?plugins/(\w+)`:?", rf"- Plugin [\1]({DOCS}/plugins/\1.html):"), + (r"^- `(\w+)-cmd`:?", rf"- Command [\1]({DOCS}/reference/cli.html#\1):"), (r"### [^\n]+\n+(?=### )", ""), # remove empty sections ] order_bullet_points = partial( diff --git a/test/test_release.py b/test/test_release.py index 39b6b63fc..005fe8de0 100644 --- a/test/test_release.py +++ b/test/test_release.py @@ -69,8 +69,8 @@ Bug fixes: def md_changelog(): return r"""### New features -- Command **`list`**: Update. -- Plugin **`substitute`**: Some substitute multi-line change. :bug: (\#5467) +- Command [list](https://beets.readthedocs.io/en/stable/reference/cli.html#list): Update. +- Plugin [substitute](https://beets.readthedocs.io/en/stable/plugins/substitute.html): Some substitute multi-line change. :bug: (\#5467) You can do something with this command: