docs: kdoc: rework type prototype parsing
authorJonathan Corbet <corbet@lwn.net>
Thu, 3 Jul 2025 18:44:00 +0000 (12:44 -0600)
committerJonathan Corbet <corbet@lwn.net>
Tue, 8 Jul 2025 14:06:25 +0000 (08:06 -0600)
commitb8ac0259f80e12d12cc72572c097b31caf524c88
tree4878690927f7a4579653ec55c8110d0d2998edf2
parent061a1c1a27c9ea7ae5d99f72b579d542e767a3e2
docs: kdoc: rework type prototype parsing

process_proto_type() is using a complex regex and a "while True" loop to
split a declaration into chunks and, in the end, count brackets.  Switch to
using a simpler regex to just do the split directly, and handle each chunk
as it comes.  The result is, IMO, easier to understand and reason about.

The old algorithm would occasionally elide the space between function
parameters; see struct rng_alg->generate(), foe example.  The only output
difference is to not elide that space, which is more correct.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tested-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250703184403.274408-5-corbet@lwn.net
scripts/lib/kdoc/kdoc_parser.py