Skip to content

Commit

Permalink
[doc]: Fix missing space in c-api/init.rst and add rstlint rule (pyth…
Browse files Browse the repository at this point in the history
  • Loading branch information
JulienPalard committed Oct 19, 2021
1 parent 975b94b commit bda69ab
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions Doc/c-api/init.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1177,15 +1177,15 @@ 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
.. 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.
Expand Down
17 changes: 12 additions & 5 deletions Doc/tools/rstlint.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@
]

roles = [
":class:",
":func:",
":meth:",
":mod:",
"(?<!py):class:",
"(?<!:c|py):func:",
"(?<!py):meth:",
"(?<!:py):mod:",
":exc:",
":issue:",
":attr:",
":c:func:",
":ref:",
":const:",
":term:",
":data:",
"(?<!:c|py):data:",
":keyword:",
":file:",
":pep:",
Expand Down Expand Up @@ -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+:")
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit bda69ab

Please sign in to comment.