public inbox for netdev@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 00/25] kernel-doc: make it parse new functions and structs
@ 2026-01-28 16:49 Mauro Carvalho Chehab
  2026-01-28 16:49 ` [PATCH v2 01/25] docs: kdoc_re: add support for groups() Mauro Carvalho Chehab
                   ` (25 more replies)
  0 siblings, 26 replies; 56+ messages in thread
From: Mauro Carvalho Chehab @ 2026-01-28 16:49 UTC (permalink / raw)
  To: David S. Miller, Alexander Lobakin, Alexei Starovoitov,
	Daniel Borkmann, Jakub Kicinski, Jesper Dangaard Brouer,
	John Fastabend, Jonathan Corbet, Mauro Carvalho Chehab,
	Richard Cochran
  Cc: Mauro Carvalho Chehab, bpf, intel-wired-lan, linux-doc,
	linux-kernel, netdev, Randy Dunlap, Shuah Khan,
	Stanislav Fomichev

Hi Jon,

It is impressive how a single patch became a series with 25 ones ;-)

This version was rebased on next-20260127, which is after docs-mw
got merged with my doc patches, solving some merge conflicts.

It should now apply cleanly on the top of upstream and it will address
the kernel-doc issues with context analysis patches that are already
at linux-next.

On this version, I opted to do something I always wanted when
porting from the venerable kernel-doc perl logic: properly handle
macros without writing really complex regular expressions.

After those changes, the replacement logic becomes a lot more
easier to write, as we can have a cleaner logic to handle
function calls:

	function_xforms = [
	    (KernRe(r"^static +"), ""),
	    (KernRe(r"^extern +"), ""),
	...
	    (NestedMatch(r"__cond_acquires\s*\("), ""),
	    (NestedMatch(r"__cond_releases\s*\("), ""),
	...
	}

It can even be used to replace comma-separated arguments like here:

	struct_xforms = [
	...
	    (NestedMatch(r'\bstruct_group\s*\('), r'\2'),
	    (NestedMatch(r'\bstruct_group_attr\s*\('), r'\3'),
	    (NestedMatch(r'\bstruct_group_tagged\s*\('), r'struct \1 { \3 } \2;'),
	    (NestedMatch(r'\b__struct_group\s*\('), r'\4'),
	...
	]

As both KernRe and NestedMatch have sub methods, they can be placed
altogether at the same transforms tables.

The regex syntax for them are quite simple: they should end with a
delimiter (usually open parenthesis, but brackets and square
brackets are also supported).

The first 15 patches on this series were co-developed with Randy,
with came up with the original patch. I ended helping identifying
kernel-doc issues and doing some changes to make the parser more
reliable.

Then, I added 10 other patches to improve NestedMatch.

The final two patches on it fixes an issue when parsing
include/net/page_pool/types.h. Right now, it doesn't parse
well struct page_pool_params, as the second struct_group_tagged()
has a /* private */ on it, causing the end parenthesis to be
commented out. After the series, the documentation for it
should be ok.

-

Even NestedMatch being more complex than KernRe, on my machine,
parsing all files is 5% faster than before, because we're not
parsing anymore macro definitions.

Ah, due to the complexity of NestedMatch, I opted to write
some unit tests to verify that the logic there is correct.
We can use it to add other border cases.

Using it is as easy as running:

	$ tools/unittests/nested_match.py

(I opted to create a separate directory for it, as this
is not really documentation)

Mauro Carvalho Chehab (23):
  docs: kdoc_re: add support for groups()
  docs: kdoc_re: don't go past the end of a line
  docs: kdoc_parser: move var transformers to the beginning
  docs: kdoc_parser: don't mangle with function defines
  docs: kdoc_parser: add functions support for NestedMatch
  docs: kdoc_parser: use NestedMatch to handle __attribute__ on
    functions
  docs: kdoc_parser: fix variable regexes to work with size_t
  docs: kdoc_parser: fix the default_value logic for variables
  docs: kdoc_parser: add some debug for variable parsing
  docs: kdoc_parser: don't exclude defaults from prototype
  docs: kdoc_parser: fix parser to support multi-word types
  docs: kdoc_parser: add support for LIST_HEAD
  docs: kdoc_re: properly handle strings and escape chars on it
  docs: kdoc_re: better show KernRe() at documentation
  docs: kdoc_re: don't recompile NextMatch regex every time
  docs: kdoc_re: Change NestedMath args replacement to \0
  docs: kdoc_re: make NextedMatch use KernRe
  tools: kdoc_re: add support on NestedMatch for argument replacement
  tools: python: add helpers to run unit tests
  unittests: add tests for NestedMatch class
  tools/lib/python/unittest_helper.py
  docs: kdoc_parser: better handle struct_group macros
  docs: kdoc_re: fix a parse bug on struct page_pool_params

Randy Dunlap (2):
  docs: kdoc_parser: ignore context analysis and lock attributes
  kdoc_parser: handle struct member macro VIRTIO_DECLARE_FEATURES(name)

 tools/lib/python/kdoc/kdoc_parser.py | 109 +++--
 tools/lib/python/kdoc/kdoc_re.py     | 154 +++++--
 tools/lib/python/unittest_helper.py  | 279 +++++++++++++
 tools/unittests/nested_match.py      | 589 +++++++++++++++++++++++++++
 4 files changed, 1063 insertions(+), 68 deletions(-)
 create mode 100755 tools/lib/python/unittest_helper.py
 create mode 100755 tools/unittests/nested_match.py

-- 
2.52.0


^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2026-02-10 15:27 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-28 16:49 [PATCH v2 00/25] kernel-doc: make it parse new functions and structs Mauro Carvalho Chehab
2026-01-28 16:49 ` [PATCH v2 01/25] docs: kdoc_re: add support for groups() Mauro Carvalho Chehab
2026-01-28 17:44   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 02/25] docs: kdoc_re: don't go past the end of a line Mauro Carvalho Chehab
2026-01-28 17:44   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 03/25] docs: kdoc_parser: move var transformers to the beginning Mauro Carvalho Chehab
2026-01-28 17:44   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 04/25] docs: kdoc_parser: don't mangle with function defines Mauro Carvalho Chehab
2026-01-28 17:45   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 05/25] docs: kdoc_parser: add functions support for NestedMatch Mauro Carvalho Chehab
2026-01-28 16:50 ` [PATCH v2 06/25] docs: kdoc_parser: use NestedMatch to handle __attribute__ on functions Mauro Carvalho Chehab
2026-01-28 16:50 ` [PATCH v2 07/25] docs: kdoc_parser: fix variable regexes to work with size_t Mauro Carvalho Chehab
2026-01-28 17:45   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 08/25] docs: kdoc_parser: fix the default_value logic for variables Mauro Carvalho Chehab
2026-01-28 17:45   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 09/25] docs: kdoc_parser: add some debug for variable parsing Mauro Carvalho Chehab
2026-01-28 17:46   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 10/25] docs: kdoc_parser: don't exclude defaults from prototype Mauro Carvalho Chehab
2026-01-28 17:46   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 11/25] docs: kdoc_parser: fix parser to support multi-word types Mauro Carvalho Chehab
2026-01-28 17:47   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 12/25] docs: kdoc_parser: ignore context analysis and lock attributes Mauro Carvalho Chehab
2026-01-28 17:47   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 13/25] docs: kdoc_parser: add support for LIST_HEAD Mauro Carvalho Chehab
2026-01-28 17:47   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 14/25] kdoc_parser: handle struct member macro VIRTIO_DECLARE_FEATURES(name) Mauro Carvalho Chehab
2026-01-28 17:47   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 15/25] docs: kdoc_re: properly handle strings and escape chars on it Mauro Carvalho Chehab
2026-01-28 17:47   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 16/25] docs: kdoc_re: better show KernRe() at documentation Mauro Carvalho Chehab
2026-01-28 17:48   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 17/25] docs: kdoc_re: don't recompile NextMatch regex every time Mauro Carvalho Chehab
2026-01-28 17:48   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 18/25] docs: kdoc_re: Change NestedMath args replacement to \0 Mauro Carvalho Chehab
2026-01-28 17:48   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 19/25] docs: kdoc_re: make NextedMatch use KernRe Mauro Carvalho Chehab
2026-01-28 16:50 ` [PATCH v2 20/25] tools: kdoc_re: add support on NestedMatch for argument replacement Mauro Carvalho Chehab
2026-01-28 17:49   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 21/25] tools: python: add helpers to run unit tests Mauro Carvalho Chehab
2026-01-28 16:50 ` [PATCH v2 22/25] unittests: add tests for NestedMatch class Mauro Carvalho Chehab
2026-01-28 16:50 ` [PATCH v2 23/25] tools/lib/python/unittest_helper.py Mauro Carvalho Chehab
2026-01-28 17:17   ` Mauro Carvalho Chehab
2026-01-28 17:32   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 18:09   ` Jacob Keller
2026-01-28 21:02     ` Mauro Carvalho Chehab
2026-01-28 22:04       ` Jacob Keller
2026-01-28 16:50 ` [PATCH v2 24/25] docs: kdoc_parser: better handle struct_group macros Mauro Carvalho Chehab
2026-01-28 17:49   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 16:50 ` [PATCH v2 25/25] docs: kdoc_re: fix a parse bug on struct page_pool_params Mauro Carvalho Chehab
2026-01-28 17:49   ` [Intel-wired-lan] " Loktionov, Aleksandr
2026-01-28 17:27 ` [PATCH v2 00/25] kernel-doc: make it parse new functions and structs Jonathan Corbet
2026-01-28 18:15   ` Jacob Keller
2026-01-28 22:00     ` Mauro Carvalho Chehab
2026-01-28 22:08       ` Jacob Keller
2026-01-29  8:14         ` Mauro Carvalho Chehab
2026-02-10 15:27   ` Mauro Carvalho Chehab

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox