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>
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 4/9] docs: kdoc: simplify the kerneldoc recognition code
Date: Sat, 7 Jun 2025 12:05:01 +0200	[thread overview]
Message-ID: <20250607120501.7a0db912@foz.lan> (raw)
In-Reply-To: <20250606163438.229916-5-corbet@lwn.net>

Em Fri,  6 Jun 2025 10:34:33 -0600
Jonathan Corbet <corbet@lwn.net> escreveu:

> process_name() looks for the first line of a kerneldoc comment.  It
> contains two nearly identical regular expressions, the second of which only
> catches six cases in the kernel, all of the form:
> 
>   define SOME_MACRO_NAME - description
> 
> Simply put the "define" into the regex and discard it, eliminating the loop
> and the code to remove it specially.
> 
> Note that this still treats these defines as if they were functions, but
> that's a separate issue.
> 
> There is no change in the generated output.
> 
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>

Nice cleanup!

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>

> ---
>  scripts/lib/kdoc/kdoc_parser.py | 24 ++++++++----------------
>  1 file changed, 8 insertions(+), 16 deletions(-)
> 
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index 90b53b70cfee..3ea260b423e2 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -1230,26 +1230,18 @@ class KernelDoc:
>  
>              # Test for data declaration
>              r = KernRe(r"^\s*\*?\s*(struct|union|enum|typedef)\b\s*(\w*)")
> +            r2 = KernRe(fr"^{decl_start}{fn_type}(?:define\s+)?(\w+)\s*{parenthesis}\s*{decl_end}?$")
>              if r.search(line):
>                  self.entry.decl_type = r.group(1)
>                  self.entry.identifier = r.group(2)
>                  self.entry.is_kernel_comment = True
> -            else:
> -                # Look for foo() or static void foo() - description;
> -                # or misspelt identifier
> -
> -                r1 = KernRe(fr"^{decl_start}{fn_type}(\w+)\s*{parenthesis}\s*{decl_end}?$")
> -                r2 = KernRe(fr"^{decl_start}{fn_type}(\w+[^-:]*){parenthesis}\s*{decl_end}$")
> -
> -                for r in [r1, r2]:
> -                    if r.search(line):
> -                        self.entry.identifier = r.group(1)
> -                        self.entry.decl_type = "function"
> -
> -                        r = KernRe(r"define\s+")
> -                        self.entry.identifier = r.sub("", self.entry.identifier)
> -                        self.entry.is_kernel_comment = True
> -                        break
> +            #
> +            # 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
>  
>              self.entry.identifier = self.entry.identifier.strip(" ")
>  



Thanks,
Mauro

  reply	other threads:[~2025-06-07 10:05 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-06-06 16:34 [PATCH 0/9] A series of kernel-doc tweaks Jonathan Corbet
2025-06-06 16:34 ` [PATCH 1/9] docs: kdoc: simplify the PROTO continuation logic Jonathan Corbet
2025-06-07  9:59   ` Mauro Carvalho Chehab
2025-06-06 16:34 ` [PATCH 2/9] docs: kdoc: move the core dispatch into a state table Jonathan Corbet
2025-06-07 10:00   ` Mauro Carvalho Chehab
2025-06-06 16:34 ` [PATCH 3/9] docs: kdoc: remove the section_intro variable Jonathan Corbet
2025-06-07 10:03   ` Mauro Carvalho Chehab
2025-06-06 16:34 ` [PATCH 4/9] docs: kdoc: simplify the kerneldoc recognition code Jonathan Corbet
2025-06-07 10:05   ` Mauro Carvalho Chehab [this message]
2025-06-06 16:34 ` [PATCH 5/9] docs: kdoc: remove the KernelEntry::is_kernel_comment member Jonathan Corbet
2025-06-07 10:07   ` Mauro Carvalho Chehab
2025-06-07 13:22     ` Jonathan Corbet
2025-06-08  3:18       ` Mauro Carvalho Chehab
2025-06-06 16:34 ` [PATCH 6/9] docs: kdoc: remove the KernelEntry::descr pseudo member Jonathan Corbet
2025-06-07 10:14   ` Mauro Carvalho Chehab
2025-06-06 16:34 ` [PATCH 7/9] docs: kdoc: remove some ineffective code Jonathan Corbet
2025-06-07 10:09   ` Mauro Carvalho Chehab
2025-06-06 16:34 ` [PATCH 8/9] docs: kdoc: move the declaration regexes out of process_name() Jonathan Corbet
2025-06-07 10:11   ` Mauro Carvalho Chehab
2025-06-06 16:34 ` [PATCH 9/9] docs: kdoc: some final touches for process_name() Jonathan Corbet
2025-06-07 10:13   ` Mauro Carvalho Chehab
2025-06-07  9:58 ` [PATCH 0/9] A series of kernel-doc tweaks 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=20250607120501.7a0db912@foz.lan \
    --to=mchehab+huawei@kernel.org \
    --cc=corbet@lwn.net \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®