mirror of
https://github.com/beetbox/beets.git
synced 2025-12-06 08:39:17 +01:00
Convert replacements and Include URLs for :class: refs in release notes
This commit is contained in:
parent
fbc12a358c
commit
f33c030ebb
1 changed files with 14 additions and 2 deletions
|
|
@ -19,6 +19,8 @@ from packaging.version import Version, parse
|
||||||
from sphinx.ext import intersphinx
|
from sphinx.ext import intersphinx
|
||||||
from typing_extensions import TypeAlias
|
from typing_extensions import TypeAlias
|
||||||
|
|
||||||
|
from docs.conf import rst_epilog
|
||||||
|
|
||||||
BASE = Path(__file__).parent.parent.absolute()
|
BASE = Path(__file__).parent.parent.absolute()
|
||||||
PYPROJECT = BASE / "pyproject.toml"
|
PYPROJECT = BASE / "pyproject.toml"
|
||||||
CHANGELOG = BASE / "docs" / "changelog.rst"
|
CHANGELOG = BASE / "docs" / "changelog.rst"
|
||||||
|
|
@ -104,11 +106,21 @@ def create_rst_replacements() -> list[Replacement]:
|
||||||
plugins = "|".join(
|
plugins = "|".join(
|
||||||
r.split("/")[-1] for r in refs if r.startswith("plugins/")
|
r.split("/")[-1] for r in refs if r.startswith("plugins/")
|
||||||
)
|
)
|
||||||
|
explicit_replacements = dict(
|
||||||
|
line.removeprefix(".. ").split(" replace:: ")
|
||||||
|
for line in filter(None, rst_epilog.splitlines())
|
||||||
|
)
|
||||||
return [
|
return [
|
||||||
# Replace Sphinx :ref: and :doc: directives by documentation URLs
|
# Replace explicitly defined substitutions from rst_epilog
|
||||||
|
# |BeetsPlugin| -> :class:`beets.plugins.BeetsPlugin`
|
||||||
|
(
|
||||||
|
r"\|\w[^ ]*\|",
|
||||||
|
lambda m: explicit_replacements.get(m[0], m[0]),
|
||||||
|
),
|
||||||
|
# Replace Sphinx directives by documentation URLs, e.g.,
|
||||||
# :ref:`/plugins/autobpm` -> [AutoBPM Plugin](DOCS/plugins/autobpm.html)
|
# :ref:`/plugins/autobpm` -> [AutoBPM Plugin](DOCS/plugins/autobpm.html)
|
||||||
(
|
(
|
||||||
r":(?:ref|doc):`+(?:([^`<]+)<)?/?([\w./_-]+)>?`+",
|
r":(?:ref|doc|class):`+(?:([^`<]+)<)?/?([\w./_-]+)>?`+",
|
||||||
lambda m: make_ref_link(m[2], m[1]),
|
lambda m: make_ref_link(m[2], m[1]),
|
||||||
),
|
),
|
||||||
# Convert command references to documentation URLs
|
# Convert command references to documentation URLs
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue