Skip to content

Commit bda69ab

Browse files
authored
[doc]: Fix missing space in c-api/init.rst and add rstlint rule (GH-28988)
1 parent 975b94b commit bda69ab

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

Doc/c-api/init.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,15 +1177,15 @@ All of the following functions must be called after :c:func:`Py_Initialize`.
11771177
11781178
Suspend tracing and profiling in the Python thread state *tstate*.
11791179
1180-
Resume them using the:c:func:`PyThreadState_LeaveTracing` function.
1180+
Resume them using the :c:func:`PyThreadState_LeaveTracing` function.
11811181
11821182
.. versionadded:: 3.11
11831183
11841184
11851185
.. c:function:: void PyThreadState_LeaveTracing(PyThreadState *tstate)
11861186
11871187
Resume tracing and profiling in the Python thread state *tstate* suspended
1188-
by the:c:func:`PyThreadState_EnterTracing` function.
1188+
by the :c:func:`PyThreadState_EnterTracing` function.
11891189
11901190
See also :c:func:`PyEval_SetTrace` and :c:func:`PyEval_SetProfile`
11911191
functions.

Doc/tools/rstlint.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,18 +43,18 @@
4343
]
4444

4545
roles = [
46-
":class:",
47-
":func:",
48-
":meth:",
49-
":mod:",
46+
"(?<!py):class:",
47+
"(?<!:c|py):func:",
48+
"(?<!py):meth:",
49+
"(?<!:py):mod:",
5050
":exc:",
5151
":issue:",
5252
":attr:",
5353
":c:func:",
5454
":ref:",
5555
":const:",
5656
":term:",
57-
":data:",
57+
"(?<!:c|py):data:",
5858
":keyword:",
5959
":file:",
6060
":pep:",
@@ -128,6 +128,11 @@
128128
# :const:`None`
129129
role_with_no_backticks = re.compile(r"%s[^` ]" % all_roles)
130130

131+
# Find role glued with another word like:
132+
# the:c:func:`PyThreadState_LeaveTracing` function.
133+
# instad of:
134+
# the :c:func:`PyThreadState_LeaveTracing` function.
135+
role_glued_with_word = re.compile(r"[a-zA-Z]%s" % all_roles)
131136

132137
default_role_re = re.compile(r"(^| )`\w([^`]*?\w)?`($| )")
133138
leaked_markup_re = re.compile(r"[a-z]::\s|`|\.\.\s*\w+:")
@@ -176,6 +181,8 @@ def check_suspicious_constructs(fn, lines):
176181
yield lno, "role use a single backtick, double backtick found."
177182
if role_with_no_backticks.search(line):
178183
yield lno, "role use a single backtick, no backtick found."
184+
if role_glued_with_word.search(line):
185+
yield lno, "missing space before role"
179186
if ".. productionlist::" in line:
180187
inprod = True
181188
elif not inprod and default_role_re.search(line):

0 commit comments

Comments
 (0)