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,
Akira Yokosawa <akiyks@gmail.com>
Subject: Re: [PATCH 4/9] docs: kdoc: split out the special-section state
Date: Sun, 22 Jun 2025 13:50:00 +0200 [thread overview]
Message-ID: <20250622135000.3580ba52@foz.lan> (raw)
In-Reply-To: <20250621203512.223189-5-corbet@lwn.net>
Em Sat, 21 Jun 2025 14:35:07 -0600
Jonathan Corbet <corbet@lwn.net> escreveu:
> The state known as BODY_WITH_BLANK_LINE really, in a convoluted way,
> indicates a "special section" that is terminated by a blank line or the
> beginning of a new section. That is either "@param: desc" sections, or the
> weird "context" section that plays by the same rules.
>
> Rename the state to SPECIAL_SECTION and split its processing into a
> separate function; no real changes to the logic yet.
LGTM.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
>
> Signed-off-by: Jonathan Corbet <corbet@lwn.net>
> ---
> scripts/lib/kdoc/kdoc_parser.py | 24 ++++++++++++------------
> 1 file changed, 12 insertions(+), 12 deletions(-)
>
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index f1491f8c88e7..185ffe4e1469 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -88,7 +88,7 @@ class state:
> NAME = 1 # looking for function name
> DECLARATION = 2 # We have seen a declaration which might not be done
> BODY = 3 # the body of the comment
> - BODY_WITH_BLANK_LINE = 4 # the body which has a blank line
> + SPECIAL_SECTION = 4 # doc section ending with a blank line
> PROTO = 5 # scanning prototype
> DOCBLOCK = 6 # documentation block
> INLINE = 7 # gathering doc outside main block
> @@ -98,7 +98,7 @@ class state:
> "NAME",
> "DECLARATION",
> "BODY",
> - "BODY_WITH_BLANK_LINE",
> + "SPECIAL_SECTION",
> "PROTO",
> "DOCBLOCK",
> "INLINE",
> @@ -1383,18 +1383,18 @@ class KernelDoc:
> self.emit_msg(ln, f"bad line: {line}")
>
>
> + def process_special(self, ln, line):
> + """
> + STATE_SPECIAL_SECTION: a section ending with a blank line
> + """
> + if KernRe(r"\s*\*\s*\S").match(line):
> + self.entry.begin_section(ln, dump = True)
> + self.process_body(ln, line)
> +
> def process_body(self, ln, line):
> """
> STATE_BODY: the bulk of a kerneldoc comment.
> """
> -
> - if self.state == state.BODY_WITH_BLANK_LINE:
> - r = KernRe(r"\s*\*\s*\S")
> - if r.match(line):
> - self.dump_section()
> - self.entry.begin_section(ln)
> - self.entry.contents = ""
> -
> if doc_sect.search(line):
> self.entry.in_doc_sect = True
> newsection = doc_sect.group(1)
> @@ -1452,7 +1452,7 @@ class KernelDoc:
> self.state = state.BODY
> else:
> if self.entry.section != SECTION_DEFAULT:
> - self.state = state.BODY_WITH_BLANK_LINE
> + self.state = state.SPECIAL_SECTION
> else:
> self.state = state.BODY
>
> @@ -1751,7 +1751,7 @@ class KernelDoc:
> state.NAME: process_name,
> state.BODY: process_body,
> state.DECLARATION: process_decl,
> - state.BODY_WITH_BLANK_LINE: process_body,
> + state.SPECIAL_SECTION: process_special,
> state.INLINE: process_inline,
> state.PROTO: process_proto,
> state.DOCBLOCK: process_docblock,
Thanks,
Mauro
next prev parent reply other threads:[~2025-06-22 11:50 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-21 20:35 [PATCH 0/9] docs: kdoc: rework the BODY* processing states Jonathan Corbet
2025-06-21 20:35 ` [PATCH 1/9] docs: kdoc: Make body_with_blank_line parsing more flexible Jonathan Corbet
2025-06-22 11:46 ` Mauro Carvalho Chehab
2025-06-21 20:35 ` [PATCH 2/9] docs: kdoc: consolidate the "begin section" logic Jonathan Corbet
2025-06-22 11:47 ` Mauro Carvalho Chehab
2025-06-21 20:35 ` [PATCH 3/9] docs: kdoc: separate out the handling of the declaration phase Jonathan Corbet
2025-06-22 11:48 ` Mauro Carvalho Chehab
2025-06-21 20:35 ` [PATCH 4/9] docs: kdoc: split out the special-section state Jonathan Corbet
2025-06-22 11:50 ` Mauro Carvalho Chehab [this message]
2025-06-21 20:35 ` [PATCH 5/9] docs: kdoc: coalesce the new-section handling Jonathan Corbet
2025-06-22 11:50 ` Mauro Carvalho Chehab
2025-06-21 20:35 ` [PATCH 6/9] docs: kdoc: rework the handling of SPECIAL_SECTION Jonathan Corbet
2025-06-22 11:51 ` Mauro Carvalho Chehab
2025-06-21 20:35 ` [PATCH 7/9] docs: kdoc: coalesce the end-of-comment processing Jonathan Corbet
2025-06-22 11:52 ` Mauro Carvalho Chehab
2025-06-21 20:35 ` [PATCH 8/9] docs: kdoc: Add some comments to process_decl() Jonathan Corbet
2025-06-22 11:53 ` Mauro Carvalho Chehab
2025-06-21 20:35 ` [PATCH 9/9] docs: kdoc: finish disentangling the BODY and SPECIAL_SECTION states Jonathan Corbet
2025-06-22 11:54 ` 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=20250622135000.3580ba52@foz.lan \
--to=mchehab+huawei@kernel.org \
--cc=akiyks@gmail.com \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.