Skip to content

Commit 3050edf

Browse files
Nícolas F. R. A. Pradomchehab
authored andcommitted
docs: automarkup.py: Skip C reserved words when cross-referencing
With the transition to Sphinx 3, new warnings were caused by automarkup, exposing bugs in the name matching. When automarkup parsed a text like "struct struct" in the documentation, it tried to cross-reference to a "struct" symbol, which is recognized as a C reserved word by Sphinx 3, generating a warning. Add some C reserved words (only the ones that were causing warnings) to a list and skip them while trying to cross-reference. Signed-off-by: Nícolas F. R. A. Prado <nfraprado@protonmail.com> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
1 parent f66e47f commit 3050edf

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

‎Documentation/sphinx/automarkup.py‎

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,12 @@
4545
#
4646
RE_doc = re.compile(r'\bDocumentation(/[\w\-_/]+)(\.\w+)*')
4747

48+
#
49+
# Reserved C words that we should skip when cross-referencing
50+
#
51+
Skipnames = [ 'for', 'if', 'register', 'sizeof', 'struct', 'unsigned' ]
52+
53+
4854
#
4955
# Many places in the docs refer to common system calls. It is
5056
# pointless to try to cross-reference them and, as has been known
@@ -133,7 +139,8 @@ def markup_c_ref(docname, app, match):
133139
target = match.group(2)
134140
target_text = nodes.Text(match.group(0))
135141
xref = None
136-
if not (match.re == RE_function and target in Skipfuncs):
142+
if not ((match.re == RE_function and target in Skipfuncs)
143+
or (target in Skipnames)):
137144
lit_text = nodes.literal(classes=['xref', 'c', class_str[match.re]])
138145
lit_text += target_text
139146
pxref = addnodes.pending_xref('', refdomain = 'c',

0 commit comments

Comments
 (0)