summaryrefslogtreecommitdiff
path: root/tools/lib/python/kdoc/kdoc_parser.py
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2025-12-16 15:26:13 +0100
committerJonathan Corbet <corbet@lwn.net>2025-12-22 14:43:25 -0700
commitbdd1cf87847ff6aaadd53a185209d2bb2db72165 (patch)
tree650f2fb74292c650ec59bb6975b377ab732c89a1 /tools/lib/python/kdoc/kdoc_parser.py
parent1045ec382c6019b63cab24428783749a1cecc439 (diff)
kernel-doc: add support to handle DEFINE_ variables
Improve the parser and output plugin to work with macros, adding support for the common pattern of using DEFINE_* to create variables. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <757a45100cfc493984574ff780aa9d90506eecb4.1765894964.git.mchehab+huawei@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc/kdoc_parser.py')
-rw-r--r--tools/lib/python/kdoc/kdoc_parser.py25
1 files changed, 21 insertions, 4 deletions
diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py
index 06bed1a12a45..aaa352855717 100644
--- a/tools/lib/python/kdoc/kdoc_parser.py
+++ b/tools/lib/python/kdoc/kdoc_parser.py
@@ -949,12 +949,27 @@ class KernelDoc:
# Store the full prototype before modifying it
#
full_proto = proto
+ declaration_name = None
+
+ #
+ # Handle macro definitions
+ #
+ macro_prefixes = [
+ KernRe(r"DEFINE_[\w_]+\s*\(([\w_]+)\)"),
+ ]
+
+ for r in macro_prefixes:
+ match = r.search(proto)
+ if match:
+ declaration_name = match.group(1)
+ break
#
# Drop comments and macros to have a pure C prototype
#
- for search, sub in sub_prefixes:
- proto = search.sub(sub, proto)
+ if not declaration_name:
+ for r, sub in sub_prefixes:
+ proto = r.sub(sub, proto)
proto = proto.rstrip()
@@ -968,14 +983,16 @@ class KernelDoc:
return
var_type = r.group(0)
- declaration_name = r.group(1)
+
+ if not declaration_name:
+ declaration_name = r.group(1)
+
default_val = r.group(2)
if default_val:
default_val = default_val.lstrip("=").strip()
self.output_declaration("var", declaration_name,
full_proto=full_proto,
- var_type=var_type,
default_val=default_val,
purpose=self.entry.declaration_purpose)