138 Commits

Author SHA1 Message Date
Jonathan Corbet
c018784377 docs: kdoc: a few more dump_typedef() tweaks
Merge "typedef" into the typedef_type pattern rather than repeating it
later, and add some comments.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:54 -06:00
Jonathan Corbet
00fa9bc4e9 docs: kdoc: remove redundant comment stripping in dump_typedef()
By the time we get here, comments have long since been stripped out; there
is no need to do it again.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:54 -06:00
Jonathan Corbet
999a642d7e docs: kdoc: remove some dead code in dump_typedef()
The regex in this block of code makes no sense, and a quick test shows that
it never matches anything; simply delete the code.

No output changes.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
3dff54410e docs: kdoc: final dump_function() cleanups
Add some more comments to dump_function(), add some comments, and trim out
an unneeded duplicate output_declaration() call.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
370f430527 docs: kdoc: consolidate some of the macro-processing logic
The logic to handle macros is split in dump_function(); bring it all
together into a single place and add a comment saying what's going on.
Remove the unneeded is_define_proto variable, and tighten up the code
a bit.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
ff1f2af341 docs: kdoc: Simplify the dump_function() prototype regexes
The regexes for the parsing of function prototypes were more complicated
than they needed to be and difficult to understand -- at least, I spent a
fair amount of time bashing my head against them.  Simplify them, and add
some documentation comments as well.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
08b5228cf4 docs: kdoc: remove a useless empty capture group
The is_define_proto case in dump_function() uses a regex with an empty
capture group - () - that has no use; just take it out.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
fee63c8f10 docs: kdoc: remove a couple of spurious regex characters
The "name" regex in dump_function() includes both the tilde and colon
characters, but neither has any place in function prototypes.  Remove the
characters, after which the regex simplifies to "\w+"

No output changes.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
a2752f8c63 doc: kdoc: unify transform handling
Both functions and structs are passed through a set of regex-based
transforms, but the two were structured differently, despite being the same
thing.  Create a utility function to apply transformations and use it in
both cases.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
4c232a81b0 docs: kdoc: move the function transform patterns out of dump_function()
Move these definitions to file level, where they are executed once, and
don't clutter the function itself.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
f853e83006 docs: kdoc: remove a single-use variable
struct_attribute is only used once, so just put its value there directly
and drop the name.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
e214cca38f docs: kdoc: tighten up the push_parameter() no-type case
The handling of untyped parameters involved a number of redundant tests;
restructure the code to remove them and be more compact.

No output changes.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
8b00d6fe96 docs: kdoc: trim __cacheline_group_* with the other annotations
The special case for __cacheline_group_begin/end() can be handled by just
adding another pattern to the struct_prefixes, eliminating the need for a
special case in push_parameter().

One change is that these annotations no longer appear in the rendered
output, just like all the other annotations that we clean out.

Signed-off-by: Jonathan Corbet <corbet@lwn.net>
2025-09-18 10:19:53 -06:00
Jonathan Corbet
1d8125e273 docs: kdoc: remove redundant comment stripping
By the time stuff gets to create_parameter_list(), comments have long since
been stripped out, so we do not need to do it again here.

Acked-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250814154035.328769-8-corbet@lwn.net
2025-08-18 10:19:19 -06:00
Jonathan Corbet
e5d91662fc docs: kdoc: tighten up the pointer-to-function case
Tighten up the code and remove an unneeded regex operation.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250814154035.328769-7-corbet@lwn.net
2025-08-18 10:19:19 -06:00
Jonathan Corbet
bf6b310d1b docs: kdoc: tighten up the array-of-pointers case
Simplify one gnarly regex and remove another altogether; add a comment
describing what is going on.  There will be no #-substituted commas in this
case, so don't bother trying to put them back.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250814154035.328769-6-corbet@lwn.net
2025-08-18 10:19:19 -06:00
Jonathan Corbet
8f05fbc5af docs: kdoc: add a couple more comments in create_parameter_list()
Make what the final code is doing a bit more clear to slow readers like me.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250814154035.328769-5-corbet@lwn.net
2025-08-18 10:19:19 -06:00
Jonathan Corbet
05d72fe072 docs: kdoc: clean up the create_parameter_list() "first arg" logic
The logic for finding the name of the first in a series of variable names
is somewhat convoluted and, in the use of .extend(), actively buggy.
Document what is happening and simplify the logic.

Acked-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250814154035.328769-4-corbet@lwn.net
2025-08-18 10:19:19 -06:00
Jonathan Corbet
f51b42b99e docs: kdoc: tidy up space removal in create_parameter_list()
Remove a redundant test and add a comment describing what the space removal
is doing.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250814154035.328769-3-corbet@lwn.net
2025-08-18 10:19:19 -06:00
Jonathan Corbet
670ec7333a docs: kdoc: remove dead code
create_parameter_list() tests an argument against the same regex twice, in
two different locations; remove the pointless extra tests and the
never-executed error cases that go with them.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250814154035.328769-2-corbet@lwn.net
2025-08-18 10:19:19 -06:00
Jonathan Corbet
7b41f6f937 Merge branch 'dump-struct' into docs-mw
In my ongoing effort to truly understand our new kernel-doc, I continue to
make changes to improve the code, and to try to make the understanding task
easier for the next person.  These patches focus on dump_struct() in
particular, which starts out at nearly 300 lines long - to much to fit into
my little brain anyway.  Hopefully the result is easier to manage.

There are no changes in the rendered docs.
2025-08-11 10:29:07 -06:00
Jonathan Corbet
e282303e71 docs: kdoc: a few final dump_struct() touches
Add a couple more comments so that each phase of the process is
now clearly marked.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250807211639.47286-13-corbet@lwn.net
2025-08-11 10:25:43 -06:00
Jonathan Corbet
23c47b0931 docs: kdoc: extract output formatting from dump_struct()
The last thing done in dump_struct() is to format the structure for
printing.  That, too, is a separate activity; split it out into its own
function.

dump_struct() now fits in a single, full-hight editor screen.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250807211639.47286-12-corbet@lwn.net
2025-08-11 10:25:43 -06:00
Jonathan Corbet
e6dd4e2a5c docs: kdoc: further rewrite_struct_members() cleanup
Get rid of some redundant checks, and generally tighten up the code; no
logical change.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250807211639.47286-11-corbet@lwn.net
2025-08-11 10:25:42 -06:00
Jonathan Corbet
a8c4b0a8f1 docs: kdoc: Some rewrite_struct_members() commenting
Add comments to rewrite_struct_members() describing what it is actually
doing, and reformat/comment the main struct_members regex so that it is
(more) comprehensible to humans.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250807211639.47286-10-corbet@lwn.net
2025-08-11 10:25:42 -06:00