docs: kdoc: remove the KernelEntry::is_kernel_comment member
authorJonathan Corbet <corbet@lwn.net>
Fri, 6 Jun 2025 16:34:34 +0000 (10:34 -0600)
committerJonathan Corbet <corbet@lwn.net>
Mon, 9 Jun 2025 20:37:17 +0000 (14:37 -0600)
entry::is_kernel_comment never had anything to do with the entry itself; it
is a bit of local state in one branch of process_name().  It can, in fact,
be removed entirely; rework the code slightly so that it is no longer
needed.

No change in the rendered output.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250606163438.229916-6-corbet@lwn.net
scripts/lib/kdoc/kdoc_parser.py

index 72919a5d71b29f7ac3015eb926a0fe2fbe8f3acf..dffa3055adc16b64e9c6c642643a24c8c43c713b 100644 (file)
@@ -1224,7 +1224,6 @@ class KernelDoc:
 
         if doc_decl.search(line):
             self.entry.identifier = doc_decl.group(1)
-            self.entry.is_kernel_comment = False
 
             decl_start = str(doc_com)       # comment block asterisk
             fn_type = r"(?:\w+\s*\*\s*)?"  # type (for non-functions)
@@ -1242,14 +1241,20 @@ class KernelDoc:
             if r.search(line):
                 self.entry.decl_type = r.group(1)
                 self.entry.identifier = r.group(2)
-                self.entry.is_kernel_comment = True
             #
             # Look for a function description
             #
             elif r2.search(line):
                 self.entry.identifier = r2.group(1)
                 self.entry.decl_type = "function"
-                self.entry.is_kernel_comment = True
+            #
+            # We struck out.
+            #
+            else:
+                self.emit_msg(ln,
+                              f"This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst\n{line}")
+                self.state = state.NORMAL
+                return
 
             self.entry.identifier = self.entry.identifier.strip(" ")
 
@@ -1271,11 +1276,6 @@ class KernelDoc:
             else:
                 self.entry.declaration_purpose = ""
 
-            if not self.entry.is_kernel_comment:
-                self.emit_msg(ln,
-                              f"This comment starts with '/**', but isn't a kernel-doc comment. Refer Documentation/doc-guide/kernel-doc.rst\n{line}")
-                self.state = state.NORMAL
-
             if not self.entry.declaration_purpose and self.config.wshort_desc:
                 self.emit_msg(ln,
                               f"missing initial short description on line:\n{line}")