summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwheatfox <wheatfox17@icloud.com>2026-01-25 20:44:50 +0800
committerJonathan Corbet <corbet@lwn.net>2026-01-27 10:35:57 -0700
commit6b8edfcd661b569f077cc1ea1f7463ec38547779 (patch)
treee442d7332b8fab8890d52ef25b1631646dfbe2d0
parenta592a36e49372172d7c7551ec19ed18184c935e1 (diff)
docs: automarkup.py: Skip common English words as C identifiers
The automarkup extension incorrectly recognizes common English words as C identifiers when they follow struct/union/enum/typedef keywords, causing normal text like "... (a simple) struct that" (in `workqueue.rst`) to be rendered as code blocks. This patch adds Skipidentifiers list to filter out these words. Signed-off-by: Yulong Han <wheatfox17@icloud.com> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <20260125124450.2005006-1-wheatfox17@icloud.com>
-rw-r--r--Documentation/sphinx/automarkup.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/Documentation/sphinx/automarkup.py b/Documentation/sphinx/automarkup.py
index 1d9dada40a74..c2227ab0a891 100644
--- a/Documentation/sphinx/automarkup.py
+++ b/Documentation/sphinx/automarkup.py
@@ -46,6 +46,12 @@ RE_namespace = re.compile(r'^\s*..\s*c:namespace::\s*(\S+)\s*$')
#
Skipnames = [ 'for', 'if', 'register', 'sizeof', 'struct', 'unsigned' ]
+#
+# Common English words that should not be recognized as C identifiers
+# when following struct/union/enum/typedef keywords.
+# Example: "a simple struct that" in workqueue.rst should not be marked as code.
+#
+Skipidentifiers = [ 'that', 'which', 'where', 'whose' ]
#
# Many places in the docs refer to common system calls. It is
@@ -163,6 +169,10 @@ def markup_c_ref(docname, app, match):
if c_namespace:
possible_targets.insert(0, c_namespace + "." + base_target)
+ # Skip common English words that match identifier pattern but are not C code.
+ if base_target in Skipidentifiers:
+ return target_text
+
if base_target not in Skipnames:
for target in possible_targets:
if not (match.re == RE_function and target in Skipfuncs):