* [PATCH] docs: automarkup.py: Skip common English words as C identifiers
@ 2026-01-25 12:44 Yulong Han
2026-01-27 17:42 ` Jonathan Corbet
0 siblings, 1 reply; 2+ messages in thread
From: Yulong Han @ 2026-01-25 12:44 UTC (permalink / raw)
To: mchehab; +Cc: corbet, linux-doc, linux-kernel, wheatfox
From: wheatfox <wheatfox17@icloud.com>
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>
---
Documentation/sphinx/automarkup.py | 10 ++++++++++
1 file changed, 10 insertions(+)
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):
--
2.47.3
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] docs: automarkup.py: Skip common English words as C identifiers
2026-01-25 12:44 [PATCH] docs: automarkup.py: Skip common English words as C identifiers Yulong Han
@ 2026-01-27 17:42 ` Jonathan Corbet
0 siblings, 0 replies; 2+ messages in thread
From: Jonathan Corbet @ 2026-01-27 17:42 UTC (permalink / raw)
To: Yulong Han, mchehab; +Cc: linux-doc, linux-kernel, wheatfox
Yulong Han <wheatfox17@icloud.com> writes:
> From: wheatfox <wheatfox17@icloud.com>
>
> 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>
> ---
> Documentation/sphinx/automarkup.py | 10 ++++++++++
> 1 file changed, 10 insertions(+)
>
> 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):
I've applied this as an obvious improvement. I do suspect, though, that
a better fix would be to have the automarkup code just not do markup for
"struct" references that don't exist.
Thanks,
jon
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-01-27 17:42 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-25 12:44 [PATCH] docs: automarkup.py: Skip common English words as C identifiers Yulong Han
2026-01-27 17:42 ` Jonathan Corbet
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox