[doc]: Fix missing space in c-api/init.rst and add rstlint rule (GH-28988)

This commit is contained in:
Julien Palard 2021-10-19 21:13:24 +02:00 committed by GitHub
parent 975b94b9de
commit bda69abe84
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 14 additions and 7 deletions

View file

@ -43,10 +43,10 @@ directives = [
] ]
roles = [ roles = [
":class:", "(?<!py):class:",
":func:", "(?<!:c|py):func:",
":meth:", "(?<!py):meth:",
":mod:", "(?<!:py):mod:",
":exc:", ":exc:",
":issue:", ":issue:",
":attr:", ":attr:",
@ -54,7 +54,7 @@ roles = [
":ref:", ":ref:",
":const:", ":const:",
":term:", ":term:",
":data:", "(?<!:c|py):data:",
":keyword:", ":keyword:",
":file:", ":file:",
":pep:", ":pep:",
@ -128,6 +128,11 @@ double_backtick_role = re.compile(r"(?<!``)%s``" % all_roles)
# :const:`None` # :const:`None`
role_with_no_backticks = re.compile(r"%s[^` ]" % all_roles) 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)?`($| )") default_role_re = re.compile(r"(^| )`\w([^`]*?\w)?`($| )")
leaked_markup_re = re.compile(r"[a-z]::\s|`|\.\.\s*\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." yield lno, "role use a single backtick, double backtick found."
if role_with_no_backticks.search(line): if role_with_no_backticks.search(line):
yield lno, "role use a single backtick, no backtick found." 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: if ".. productionlist::" in line:
inprod = True inprod = True
elif not inprod and default_role_re.search(line): elif not inprod and default_role_re.search(line):