mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
To: Jonathan Corbet <corbet@lwn.net>,
	Linux Doc Mailing List <linux-doc@vger.kernel.org>
Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>,
	linux-kernel@vger.kernel.org,
	Peter Zijlstra <peterz@infradead.org>,
	Randy Dunlap <rdunlap@infradead.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>
Subject: [PATCH 04/14] docs: kdoc_parser: don't mangle with function defines
Date: Tue, 27 Jan 2026 11:13:23 +0100	[thread overview]
Message-ID: <2ef0ce1d668207cdbab9ffe9ebb568c9f4135de7.1769508371.git.mchehab+huawei@kernel.org> (raw)
In-Reply-To: <cover.1769508371.git.mchehab+huawei@kernel.org>

Mangling with #defines is not nice, as we may end removing
the macro names, preventing several macros from being properly
documented.

Also, on defines, we have something like:

	#define foo(a1, a2, a3, ...)			 \
		/* some real implementation */

The prototype part (first line on this example) won't contain
any macros, so no need to apply any regexes on it.

With that, move the apply_transforms() logic to ensure that
it will be called only on functions.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Tested-by: Randy Dunlap <rdunlap@infradead.org>
---
 tools/lib/python/kdoc/kdoc_parser.py | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py
index de75b102dd64..834a527542b3 100644
--- a/tools/lib/python/kdoc/kdoc_parser.py
+++ b/tools/lib/python/kdoc/kdoc_parser.py
@@ -166,7 +166,7 @@ struct_nested_prefixes = [
 #
 # Transforms for function prototypes
 #
-function_xforms  = [
+function_xforms = [
     (KernRe(r"^static +"), ""),
     (KernRe(r"^extern +"), ""),
     (KernRe(r"^asmlinkage +"), ""),
@@ -1049,10 +1049,7 @@ class KernelDoc:
         found = func_macro = False
         return_type = ''
         decl_type = 'function'
-        #
-        # Apply the initial transformations.
-        #
-        prototype = apply_transforms(function_xforms, prototype)
+
         #
         # If we have a macro, remove the "#define" at the front.
         #
@@ -1071,6 +1068,11 @@ class KernelDoc:
                 declaration_name = r.group(1)
                 func_macro = True
                 found = True
+        else:
+            #
+            # Apply the initial transformations.
+            #
+            prototype = apply_transforms(function_xforms, prototype)
 
         # Yes, this truly is vile.  We are looking for:
         # 1. Return type (may be nothing if we're looking at a macro)
-- 
2.52.0


  parent reply	other threads:[~2026-01-27 10:13 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27 10:13 [PATCH 00/14] kernel-doc: make it parse new functions and structs Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 01/14] docs: kdoc_re: add support for groups() Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 02/14] docs: kdoc_re: don't go past the end of a line Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 03/14] docs: kdoc_parser: move var transformers to the beginning Mauro Carvalho Chehab
2026-01-27 10:13 ` Mauro Carvalho Chehab [this message]
2026-01-27 10:13 ` [PATCH 05/14] docs: kdoc_parser: add functions support for NestedMatch Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 06/14] docs: kdoc_parser: use NestedMatch to handle __attribute__ on functions Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 07/14] docs: kdoc_parser: fix variable regexes to work with size_t Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 08/14] docs: kdoc_parser: fix the default_value logic for variables Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 09/14] docs: kdoc_parser: add some debug for variable parsing Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 10/14] docs: kdoc_parser: don't exclude defaults from prototype Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 11/14] docs: kdoc_parser: fix parser to support multi-word types Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 12/14] docs: kdoc_parser: ignore context analysis and lock attributes Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 13/14] docs: kdoc_parser: add support for LIST_HEAD Mauro Carvalho Chehab
2026-01-27 10:13 ` [PATCH 14/14] kdoc_parser: handle struct member macro VIRTIO_DECLARE_FEATURES(name) Mauro Carvalho Chehab

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2ef0ce1d668207cdbab9ffe9ebb568c9f4135de7.1769508371.git.mchehab+huawei@kernel.org \
    --to=mchehab+huawei@kernel.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=peterz@infradead.org \
    --cc=rdunlap@infradead.org \
    --cc=sfr@canb.auug.org.au \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®