summaryrefslogtreecommitdiffstats
path: root/Doc/tools
diff options
context:
space:
mode:
authorJulien Palard <julien@palard.fr>2021-10-19 19:13:24 (GMT)
committerGitHub <noreply@github.com>2021-10-19 19:13:24 (GMT)
commitbda69abe849b37467350d3750ae24d356230c940 (patch)
tree1ad035050363383a9f85f6d3d99ca1fedb21daa5 /Doc/tools
parent975b94b9de969777218e96a9950c1dab2dab65a0 (diff)
downloadcpython-bda69abe849b37467350d3750ae24d356230c940.zip
cpython-bda69abe849b37467350d3750ae24d356230c940.tar.gz
cpython-bda69abe849b37467350d3750ae24d356230c940.tar.bz2
[doc]: Fix missing space in c-api/init.rst and add rstlint rule (GH-28988)
Diffstat (limited to 'Doc/tools')
-rwxr-xr-xDoc/tools/rstlint.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py
index 045b7d7..33cbaad 100755
--- a/Doc/tools/rstlint.py
+++ b/Doc/tools/rstlint.py
@@ -43,10 +43,10 @@ directives = [
]
roles = [
- ":class:",
- ":func:",
- ":meth:",
- ":mod:",
+ "(?<!py):class:",
+ "(?<!:c|py):func:",
+ "(?<!py):meth:",
+ "(?<!:py):mod:",
":exc:",
":issue:",
":attr:",
@@ -54,7 +54,7 @@ roles = [
":ref:",
":const:",
":term:",
- ":data:",
+ "(?<!:c|py):data:",
":keyword:",
":file:",
":pep:",
@@ -128,6 +128,11 @@ double_backtick_role = re.compile(r"(?<!``)%s``" % all_roles)
# :const:`None`
role_with_no_backticks = re.compile(r"%s[^` ]" % all_roles)
+# Find role glued with another word like:
+# the:c:func:`PyThreadState_LeaveTracing` function.
+# instad of:
+# the :c:func:`PyThreadState_LeaveTracing` function.
+role_glued_with_word = re.compile(r"[a-zA-Z]%s" % all_roles)
default_role_re = re.compile(r"(^| )`\w([^`]*?\w)?`($| )")
leaked_markup_re = re.compile(r"[a-z]::\s|`|\.\.\s*\w+:")
@@ -176,6 +181,8 @@ def check_suspicious_constructs(fn, lines):
yield lno, "role use a single backtick, double backtick found."
if role_with_no_backticks.search(line):
yield lno, "role use a single backtick, no backtick found."
+ if role_glued_with_word.search(line):
+ yield lno, "missing space before role"
if ".. productionlist::" in line:
inprod = True
elif not inprod and default_role_re.search(line):