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

ambv webhook-mailer at python.org
Tue Oct 19 15:13:32 EDT 2021


https://github.com/python/cpython/commit/bda69abe849b37467350d3750ae24d356230c940
commit: bda69abe849b37467350d3750ae24d356230c940
branch: main
author: Julien Palard <julien at palard.fr>
committer: ambv <lukasz at langa.pl>
date: 2021-10-19T21:13:24+02:00
summary:

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

files:
M Doc/c-api/init.rst
M Doc/tools/rstlint.py

diff --git a/Doc/c-api/init.rst b/Doc/c-api/init.rst
index 5e817268a2036..09dfc68fee57d 100644
--- a/Doc/c-api/init.rst
+++ b/Doc/c-api/init.rst
@@ -1177,7 +1177,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
 
    Suspend tracing and profiling in the Python thread state *tstate*.
 
-   Resume them using the:c:func:`PyThreadState_LeaveTracing` function.
+   Resume them using the :c:func:`PyThreadState_LeaveTracing` function.
 
    .. versionadded:: 3.11
 
@@ -1185,7 +1185,7 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
 .. c:function:: void PyThreadState_LeaveTracing(PyThreadState *tstate)
 
    Resume tracing and profiling in the Python thread state *tstate* suspended
-   by the:c:func:`PyThreadState_EnterTracing` function.
+   by the :c:func:`PyThreadState_EnterTracing` function.
 
    See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile`
    functions.
diff --git a/Doc/tools/rstlint.py b/Doc/tools/rstlint.py
index 045b7d7c945df..33cbaadfce944 100755
--- a/Doc/tools/rstlint.py
+++ b/Doc/tools/rstlint.py
@@ -43,10 +43,10 @@
 ]
 
 roles = [
-    ":class:",
-    ":func:",
-    ":meth:",
-    ":mod:",
+    "(?<!py):class:",
+    "(?<!:c|py):func:",
+    "(?<!py):meth:",
+    "(?<!:py):mod:",
     ":exc:",
     ":issue:",
     ":attr:",
@@ -54,7 +54,7 @@
     ":ref:",
     ":const:",
     ":term:",
-    ":data:",
+    "(?<!:c|py):data:",
     ":keyword:",
     ":file:",
     ":pep:",
@@ -128,6 +128,11 @@
 # :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):



More information about the Python-checkins mailing list