docs: kernel-doc.rst: Parse DEFINE_ macros without prefixes

Currently, the logic for vars require a
	type DEFINE_foo();

where type is usually "static".

Make the logic more generic.

Reported-by: Randy Dunlap <rdunlap@infradead.org>
Closes: https://lore.kernel.org/linux-doc/e1dad7e4-a0ca-4be6-a33c-97b75175c12f@infradead.org/
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <be16e087cbc065fbd041fb6d6f8fa5cf0426cca5.1765894964.git.mchehab+huawei@kernel.org>
This commit is contained in:
Mauro Carvalho Chehab
2025-12-16 15:26:17 +01:00
committed by Jonathan Corbet
parent b580fa304c
commit aaacd70fb7

View File

@@ -977,17 +977,23 @@ class KernelDoc:
# Variable name is at the end of the declaration
#
default_val = None
r= KernRe(OPTIONAL_VAR_ATTR + r"\w.*\s+(?:\*+)?([\w_]+)\s*[\d\]\[]*\s*(=.*)?")
if not r.match(proto):
if r.match(proto):
if not declaration_name:
declaration_name = r.group(1)
default_val = r.group(2)
else:
r= KernRe(OPTIONAL_VAR_ATTR + r"(?:\w.*)?\s+(?:\*+)?(?:[\w_]+)\s*[\d\]\[]*\s*(=.*)?")
if r.match(proto):
default_val = r.group(1)
if not declaration_name:
self.emit_msg(ln,f"{proto}: can't parse variable")
return
var_type = r.group(0)
if not declaration_name:
declaration_name = r.group(1)
default_val = r.group(2)
if default_val:
default_val = default_val.lstrip("=").strip()