Re: [PATCH 08/18] docs: kdoc_parser: fix parser to support multi-word types
From: Jonathan Corbet
Date: Tue Mar 03 2026 - 12:37:12 EST
Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx> writes:
> The regular expression currently expects a single word for the
> type, but it may be something like "struct foo".
>
> Add support for it.
>
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@xxxxxxxxxx>
> Acked-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> Tested-by: Randy Dunlap <rdunlap@xxxxxxxxxxxxx>
> Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@xxxxxxxxx>
> ---
> tools/lib/python/kdoc/kdoc_parser.py | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py
> index 39ff27d421eb..22a820d33dc8 100644
> --- a/tools/lib/python/kdoc/kdoc_parser.py
> +++ b/tools/lib/python/kdoc/kdoc_parser.py
> @@ -1018,14 +1018,14 @@ class KernelDoc:
>
> default_val = None
>
> - r= KernRe(OPTIONAL_VAR_ATTR + r"[\w_]*\s+(?:\*+)?([\w_]+)\s*[\d\]\[]*\s*(=.*)?")
> + r= KernRe(OPTIONAL_VAR_ATTR + r"\s*[\w_\s]*\s+(?:\*+)?([\w_]+)\s*[\d\]\[]*\s*(=.*)?")
Just for future reference...I *really* think that the code is improved
by breaking up and commenting gnarly regexes like this. They are really
unreadable in this form. (And yes, I know the code has been full of
these forever, but we can always try to make it better :)
Anyway, just grumbling.
Thanks,
jon