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 9/9] docs: kdoc: some final touches for process_name()
Date: Sat, 7 Jun 2025 12:13:13 +0200 [thread overview]
Message-ID: <20250607121313.0edc0a3d@foz.lan> (raw)
In-Reply-To: <20250606163438.229916-10-corbet@lwn.net>
Em Fri, 6 Jun 2025 10:34:38 -0600
Jonathan Corbet <corbet@lwn.net> escreveu:
> Add some comments to process_name() to cover its broad phases of operation,
> and slightly restructure the if/then/else structure to remove some early
> returns.
>
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
More comments describing the parse steps are always welcomed!
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
> scripts/lib/kdoc/kdoc_parser.py | 33 ++++++++++++++++++++-------------
> 1 file changed, 20 insertions(+), 13 deletions(-)
>
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index 55f38240d4e5..9a1ce6ed8605 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -1219,7 +1219,9 @@ class KernelDoc:
> """
> STATE_NAME: Looking for the "name - description" line
> """
> -
> + #
> + # Check for a DOC: block and handle them specially.
> + #
> if doc_block.search(line):
> self.entry.new_start_line = ln
>
> @@ -1230,9 +1232,10 @@ class KernelDoc:
>
> self.entry.identifier = self.entry.section
> self.state = state.DOCBLOCK
> - return
> -
> - if doc_decl.search(line):
> + #
> + # Otherwise we're looking for a normal kerneldoc declaration line.
> + #
> + elif doc_decl.search(line):
> self.entry.identifier = doc_decl.group(1)
>
> # Test for data declaration
> @@ -1253,15 +1256,19 @@ class KernelDoc:
> 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(" ")
> -
> + #
> + # OK, set up for a new kerneldoc entry.
> + #
> self.state = state.BODY
> -
> + self.entry.identifier = self.entry.identifier.strip(" ")
> # if there's no @param blocks need to set up default section here
> self.entry.section = SECTION_DEFAULT
> self.entry.new_start_line = ln + 1
> -
> + #
> + # Find the description portion, which *should* be there but
> + # isn't always.
> + # (We should be able to capture this from the previous parsing - someday)
> + #
> r = KernRe("[-:](.*)")
> if r.search(line):
> self.entry.declaration_purpose = trim_whitespace(r.group(1))
> @@ -1282,11 +1289,11 @@ class KernelDoc:
> self.emit_msg(ln,
> f"Scanning doc for {self.entry.decl_type} {self.entry.identifier}",
> warning=False)
> -
> - return
> -
> + #
> # Failed to find an identifier. Emit a warning
> - self.emit_msg(ln, f"Cannot find identifier on line:\n{line}")
> + #
> + else:
> + self.emit_msg(ln, f"Cannot find identifier on line:\n{line}")
>
> def process_body(self, ln, line):
> """
Thanks,
Mauro
next prev parent reply other threads:[~2025-06-07 10:13 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
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 [this message]
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=20250607121313.0edc0a3d@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;
as well as URLs for NNTP newsgroup(s).