Re: [PATCH 6/9] docs: kdoc: remove the KernelEntry::descr pseudo member
From: Mauro Carvalho Chehab
Date: Sat Jun 07 2025 - 06:15:03 EST
Em Fri, 6 Jun 2025 10:34:35 -0600
Jonathan Corbet <corbet@xxxxxxx> escreveu:
> The entry.descr value used in process_name() is not actually a member of
> the KernelEntry class; it is a bit of local state. So just manage it
> locally.
>
> A trim_whitespace() helper was added to clean up the code slightly.
>
> Signed-off-by: Jonathan Corbet <corbet@xxxxxxx>
LGTM.
Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
> ---
> scripts/lib/kdoc/kdoc_parser.py | 14 ++++++++------
> 1 file changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/scripts/lib/kdoc/kdoc_parser.py b/scripts/lib/kdoc/kdoc_parser.py
> index 56299695abd1..7c635000f3de 100644
> --- a/scripts/lib/kdoc/kdoc_parser.py
> +++ b/scripts/lib/kdoc/kdoc_parser.py
> @@ -60,6 +60,13 @@ export_symbol_ns = KernRe(r'^\s*EXPORT_SYMBOL_NS(_GPL)?\s*\(\s*(\w+)\s*,\s*"\S+"
>
> type_param = KernRe(r"\@(\w*((\.\w+)|(->\w+))*(\.\.\.)?)", cache=False)
>
> +#
> +# A little helper to get rid of excess white space
> +#
> +multi_space = KernRe(r'\s\s+')
> +def trim_whitespace(s):
> + return multi_space.sub(' ', s.strip())
> +
> class state:
> """
> State machine enums
> @@ -1258,12 +1265,7 @@ class KernelDoc:
>
> r = KernRe("[-:](.*)")
> if r.search(line):
> - # strip leading/trailing/multiple spaces
> - self.entry.descr = r.group(1).strip(" ")
> -
> - r = KernRe(r"\s+")
> - self.entry.descr = r.sub(" ", self.entry.descr)
> - self.entry.declaration_purpose = self.entry.descr
> + self.entry.declaration_purpose = trim_whitespace(r.group(1))
> self.state = state.BODY_MAYBE
> else:
> self.entry.declaration_purpose = ""
Thanks,
Mauro