Skip to content

Commit 51a5483

Browse files
committed
Turn RST roles in changelog in pkg meta to inline
1 parent 8e343c4 commit 51a5483

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

setup.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,22 @@ def read(name):
3838
return f.read()
3939

4040

41+
# $ echo ':something:`test <sdf>`' | sed 's/:\w\+:`\(\w\+\)\(\s\+\(.*\)\)\?`/``\1``/g'
42+
# ``test``
43+
def sanitize_rst_roles(rst_source_text: str) -> str:
44+
"""Replace RST roles with inline highlighting."""
45+
role_regex = r":\w+:`(?P<rendered_text>[^`]+)(\s+(.*))?`"
46+
substitution_pattern = r"``(?P=rendered_text)``"
47+
return re.sub(role_regex, substitution_pattern, rst_source_text)
48+
49+
4150
args = dict(
4251
name="yarl",
4352
version=version,
4453
description=("Yet another URL library"),
45-
long_description="\n\n".join([read("README.rst"), read("CHANGES.rst")]),
54+
long_description="\n\n".join(
55+
[read("README.rst"), sanitize_rst_roles(read("CHANGES.rst"))]
56+
),
4657
long_description_content_type="text/x-rst",
4758
classifiers=[
4859
"License :: OSI Approved :: Apache Software License",

0 commit comments

Comments
 (0)