Skip to content

docs: several improvements to kernel-doc

Mauro Carvalho Chehab intel-wired-lan linux-doc linux-hardening lkml netdev 1 version In review

Get series with b4
b4 am [email protected]

Versions newest first

  1. v1 Latest38 patches 16 repliesIn review

Patches in v1 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/38docs: kdoc_re: add support for groups()tools/lib/python/kdoc/kdoc_re.py+7 -00 replies
2/38docs: kdoc_re: don't go past the end of a linetools/lib/python/kdoc/kdoc_re.py+1 -10 replies
3/38docs: kdoc_parser: move var transformers to the beginningtools/lib/python/kdoc/kdoc_parser.py+13 -100 replies
4/38docs: kdoc_parser: don't mangle with function definestools/lib/python/kdoc/kdoc_parser.py+7 -50 replies
5/38docs: kdoc_parser: add functions support for NestedMatchtools/lib/python/kdoc/kdoc_parser.py+25 -130 replies
6/38docs: kdoc_parser: use NestedMatch to handle __attribute__ on functionstools/lib/python/kdoc/kdoc_parser.py+1 -10 replies
7/38docs: kdoc_parser: fix variable regexes to work with size_ttools/lib/python/kdoc/kdoc_parser.py+2 -20 replies
8/38docs: kdoc_parser: fix the default_value logic for variablestools/lib/python/kdoc/kdoc_parser.py+2 -20 replies
9/38docs: kdoc_parser: add some debug for variable parsingtools/lib/python/kdoc/kdoc_parser.py+11 -00 replies
10/38docs: kdoc_parser: don't exclude defaults from prototypetools/lib/python/kdoc/kdoc_parser.py+0 -10 replies
11/38docs: kdoc_parser: fix parser to support multi-word typestools/lib/python/kdoc/kdoc_parser.py+2 -20 replies
12/38docs: kdoc_parser: ignore context analysis and lock attributestools/lib/python/kdoc/kdoc_parser.py+15 -00 replies
13/38docs: kdoc_parser: add support for LIST_HEADtools/lib/python/kdoc/kdoc_parser.py+1 -00 replies
14/38docs: kdoc_parser: handle struct member macro VIRTIO_DECLARE_FEATURES(name)tools/lib/python/kdoc/kdoc_parser.py+1 -00 replies
15/38docs: kdoc_re: properly handle strings and escape chars on ittools/lib/python/kdoc/kdoc_re.py+18 -00 replies
16/38docs: kdoc_re: better show KernRe() at documentationtools/lib/python/kdoc/kdoc_re.py+22 -10 replies
17/38docs: kdoc_re: don't recompile NestedMatch regex every timetools/lib/python/kdoc/kdoc_re.py+22 -130 replies
18/38docs: kdoc_re: Change NestedMath args replacement to \0tools/lib/python/kdoc/kdoc_parser.py tools/lib/python/kdoc/kdoc_re.py+4 -40 replies
19/38docs: kdoc_re: make NestedMatch use KernRetools/lib/python/kdoc/kdoc_parser.py tools/lib/python/kdoc/kdoc_re.py+33 -460 replies
20/38docs: kdoc_re: add support on NestedMatch for argument replacementtools/lib/python/kdoc/kdoc_re.py+59 -250 replies
21/38docs: kdoc_parser: better handle struct_group macrostools/lib/python/kdoc/kdoc_parser.py+5 -50 replies
22/38docs: kdoc_re: fix a parse bug on struct page_pool_paramstools/lib/python/kdoc/kdoc_re.py+8 -00 replies
23/38docs: kdoc_re: add a helper class to declare C function matchestools/lib/python/kdoc/kdoc_re.py+11 -00 replies
24/38docs: kdoc_parser: use the new CFunction classtools/lib/python/kdoc/kdoc_parser.py+19 -190 replies
25/38docs: kdoc_parser: minimize differences with struct_group_taggedtools/lib/python/kdoc/kdoc_parser.py+1 -10 replies
26/38docs: kdoc_parser: move transform lists to a separate fileDocumentation/tools/kdoc_parser.rst tools/lib/python/kdoc/kdoc_files.py tools/lib/python/kdoc/kdoc_parser.py +1 more+134 -1430 replies
27/38docs: kdoc_re: don't remove the trailing ";" with NestedMatchtools/lib/python/kdoc/kdoc_re.py+0 -40 replies
28/38docs: kdoc_re: prevent adding whitespaces on sub replacementstools/lib/python/kdoc/kdoc_re.py+7 -10 replies
29/38docs: xforms_lists.py: use CFuntion to handle all function macrostools/lib/python/kdoc/xforms_lists.py+31 -400 replies
30/38docs: kdoc_files: allows the caller to use a different xforms classtools/lib/python/kdoc/kdoc_files.py+7 -20 replies
31/38docs: kdoc_re: Fix NestedMatch.sub() which causes PDF builds to breaktools/lib/python/kdoc/kdoc_re.py+18 -120 replies
32/38docs: kdoc_files: document KernelFiles() ABItools/lib/python/kdoc/kdoc_files.py+43 -10 replies
33/38docs: kdoc_output: add optional args to ManOutput classtools/lib/python/kdoc/kdoc_output.py+19 -80 replies
34/38docs: sphinx-build-wrapper: better handle troff .TH markupstools/docs/sphinx-build-wrapper+4 -40 replies
35/38docs: kdoc_output: use a more standard order for .TH on man pagestools/docs/sphinx-build-wrapper tools/lib/python/kdoc/kdoc_output.py+3 -30 replies
36/38docs: sphinx-build-wrapper: don't allow "/" on file namestools/docs/sphinx-build-wrapper+2 -10 replies
37/38docs: kdoc_output: describe the class init parameterstools/lib/python/kdoc/kdoc_output.py+28 -10 replies
38/38docs: kdoc_output: pick a better default for modulenametools/docs/kernel-doc tools/lib/python/kdoc/kdoc_output.py+25 -170 replies

Reviews trailers per patch

27 of 38 patches have a Reviewed-by or Acked-by.

PatchRandy DunlapAleksandr LoktionovMauro Carvalho Chehab
1/38A-b T-b R-b
2/38A-b T-b R-b
3/38A-b T-b R-b
4/38A-b T-b R-b
5/38A-b T-b R-b
6/38A-b T-b R-b
7/38A-b T-b R-b
8/38A-b T-b R-b
9/38A-b T-b R-b
10/38A-b T-b R-b
11/38A-b T-b R-b
12/38R-b R-b
13/38A-b T-b R-b
14/38R-b
15/38R-b
16/38R-b
17/38R-b
18/38R-b
19/38R-b
20/38R-b
21/38R-b
22/38R-b
23/38R-b
24/38R-b
25/38R-b
26/38R-b
27/38R-b
28/38
29/38
30/38
31/38
32/38
33/38
34/38
35/38
36/38
37/38
38/38

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v1 thread

Cover letter [PATCH 00/38] docs: several improvements to kernel-doc

Hi Jon,

This series contain several improvements for kernel-doc.

Most of the patches came from v4 of this series:

	https://lore.kernel.org/linux-doc/[email protected]/

But I dropped from this series the unit tests part. I'll be sumitting it on a separate series.

The rationale is that, when I converted kernel-doc from Perl, the goal were to produce a bug-compatible version.

As anyone that worked before with kernel-doc are aware, using regex to handle C input is not great. Instead, we need something closer to how C statements and declarations are handled.

Yet, to avoid breaking docs, I avoided touching the regex-based algorithms inside it with one exception: struct_group logic was using very complex regexes that are incompatible with Python internal "re" module.

So, I came up with a different approach: NestedMatch. The logic inside it is meant to properly handle brackets, square brackets and parenthesis, which is closer to what C lexical parser does. On that time, I added a TODO about the need to extend that.

The first part of this series do exactly that: it extends it to parse comma-separated arguments, respecting brackets and parenthesis.

It then adds an "alias" to it at class CFunction. With that, specifying functions/macros to be handled becomes much easier.

With such infra in place, it moves the transform functions to a separate file, making it hopefully easier to maintain. As a side effect, it also makes easier for other projects to use kernel-doc (I tested it on QEMU).

Then, it adds support for newer kref annotations.

The remaining patches on this series improve the man page output, making them more compatible with other man pages.

-

I wrote several unit tests to check kernel-doc behavior. I intend to submit them on the top of this series later on.

Regards,
Mauro

Mauro Carvalho Chehab (36):
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 NestedMatch regex every time
docs: kdoc_re: Change NestedMath args replacement to \0
docs: kdoc_re: make NestedMatch use KernRe
docs: kdoc_re: add support on NestedMatch for argument replacement
docs: kdoc_parser: better handle struct_group macros
docs: kdoc_re: fix a parse bug on struct page_pool_params
docs: kdoc_re: add a helper class to declare C function matches
docs: kdoc_parser: use the new CFunction class
docs: kdoc_parser: minimize differences with struct_group_tagged
docs: kdoc_parser: move transform lists to a separate file
docs: kdoc_re: don't remove the trailing ";" with NestedMatch
docs: kdoc_re: prevent adding whitespaces on sub replacements
docs: xforms_lists.py: use CFuntion to handle all function macros
docs: kdoc_files: allows the caller to use a different xforms class
docs: kdoc_re: Fix NestedMatch.sub() which causes PDF builds to break
docs: kdoc_files: document KernelFiles() ABI
docs: kdoc_output: add optional args to ManOutput class
docs: sphinx-build-wrapper: better handle troff .TH markups
docs: kdoc_output: use a more standard order for .TH on man pages
docs: sphinx-build-wrapper: don't allow "/" on file names
docs: kdoc_output: describe the class init parameters
docs: kdoc_output: pick a better default for modulename

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

 Documentation/tools/kdoc_parser.rst   |   8 +
 tools/docs/kernel-doc                 |   1 -
 tools/docs/sphinx-build-wrapper       |   9 +-
 tools/lib/python/kdoc/kdoc_files.py   |  54 +++++-
 tools/lib/python/kdoc/kdoc_output.py  |  73 ++++++--
 tools/lib/python/kdoc/kdoc_parser.py  | 183 ++++---------------
 tools/lib/python/kdoc/kdoc_re.py      | 242 ++++++++++++++++++++------
 tools/lib/python/kdoc/xforms_lists.py | 109 ++++++++++++
 8 files changed, 451 insertions(+), 228 deletions(-)
 create mode 100644 tools/lib/python/kdoc/xforms_lists.py
Signature · 1 line
2.52.0