Skip to content

Implement kernel-doc in Python

Mauro Carvalho Chehab linux-doc linux-hardening lkml netdev 4 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest33 patches 22 repliesIn review
  2. v2 posting 2/239 patches 10 repliesApplied
  3. v2 RFC posting 1/25 patches 4 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v1 RFC1 patch0 repliesSuperseded

Changes in v3 from the cover letter

- rebased on the top of v6.15-rc1;
- Removed patches that weren't touching kernel-doc and its Sphinx extension;
- The "Re" class was renamed to "KernRe"
- It contains one patch from Sean with an additional hunk for the python version.

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/33scripts/kernel-doc: rename it to scripts/kernel-doc.plscripts/kernel-doc.pl+0 -00 replies
2/33scripts/kernel-doc: add a symlink to the Perl version of kernel-docscripts/kernel-doc+1 -00 replies
3/33scripts/kernel-doc.py: add a Python parserscripts/kernel-doc.py+2832 -00 replies
4/33scripts/kernel-doc.py: output warnings the same way as kerneldocscripts/kernel-doc.py+16 -40 replies
5/33scripts/kernel-doc.py: better handle empty sectionsscripts/kernel-doc.py+28 -30 replies
6/33scripts/kernel-doc.py: properly handle struct_group macrosscripts/kernel-doc.py+213 -70 replies
7/33scripts/kernel-doc.py: move regex methods to a separate filescripts/kernel-doc.py scripts/lib/kdoc/kdoc_re.py+277 -2180 replies
8/33scripts/kernel-doc.py: move KernelDoc class to a separate filescripts/kernel-doc.py scripts/lib/kdoc/kdoc_parser.py+1692 -16320 replies
9/33scripts/kernel-doc.py: move KernelFiles class to a separate filescripts/kernel-doc.py scripts/lib/kdoc/kdoc_files.py+271 -2190 replies
10/33scripts/kernel-doc.py: move output classes to a separate filescripts/kernel-doc.py scripts/lib/kdoc/kdoc_output.py+739 -7240 replies
11/33scripts/kernel-doc.py: convert message output to an interactorscripts/kernel-doc.py scripts/lib/kdoc/kdoc_files.py scripts/lib/kdoc/kdoc_output.py+104 -910 replies
12/33scripts/kernel-doc.py: move file lists to the parser functionscripts/kernel-doc.py scripts/lib/kdoc/kdoc_files.py+20 -240 replies
13/33scripts/kernel-doc.py: implement support for -no-doc-sectionsscripts/kernel-doc.py scripts/lib/kdoc/kdoc_files.py scripts/lib/kdoc/kdoc_output.py+15 -50 replies
14/33scripts/kernel-doc.py: fix line number outputscripts/lib/kdoc/kdoc_output.py scripts/lib/kdoc/kdoc_parser.py+24 -100 replies
15/33scripts/kernel-doc.py: fix handling of doc output checkscripts/lib/kdoc/kdoc_output.py scripts/lib/kdoc/kdoc_parser.py+14 -180 replies
16/33scripts/kernel-doc.py: properly handle out_section for ReSTscripts/lib/kdoc/kdoc_output.py+4 -40 replies
17/33scripts/kernel-doc.py: postpone warnings to the output pluginscripts/lib/kdoc/kdoc_output.py scripts/lib/kdoc/kdoc_parser.py+39 -260 replies
18/33docs: add a .pylintrc file with sys path for docs scripts.pylintrc+2 -00 replies
19/33docs: sphinx: kerneldoc: verbose kernel-doc command if V=1Documentation/sphinx/kerneldoc.py+34 -00 replies
20/33docs: sphinx: kerneldoc: ignore "\" characters from optionsDocumentation/sphinx/kerneldoc.py+12 -00 replies
21/33docs: sphinx: kerneldoc: use kernel-doc.py scriptDocumentation/Makefile Documentation/conf.py+2 -20 replies
22/33scripts/kernel-doc.py: Set an output format for --nonescripts/lib/kdoc/kdoc_files.py+4 -00 replies
23/33scripts/kernel-doc.py: adjust some coding style issuesscripts/kernel-doc.py scripts/lib/kdoc/kdoc_files.py scripts/lib/kdoc/kdoc_output.py +2 more+57 -420 replies
24/33scripts/lib/kdoc/kdoc_parser.py: fix Python compat with < v3.13scripts/lib/kdoc/kdoc_output.py scripts/lib/kdoc/kdoc_parser.py+6 -60 replies
25/33scripts/kernel-doc.py: move modulename to man classscripts/kernel-doc.py scripts/lib/kdoc/kdoc_files.py scripts/lib/kdoc/kdoc_output.py +1 more+11 -220 replies
26/33scripts/kernel-doc.py: properly handle KBUILD_BUILD_TIMESTAMPscripts/lib/kdoc/kdoc_files.py scripts/lib/kdoc/kdoc_output.py+21 -160 replies
27/33scripts/lib/kdoc/kdoc_parser.py: remove a python 3.9 dependencyscripts/lib/kdoc/kdoc_parser.py+1 -10 replies
28/33scripts/kernel-doc.py: Properly handle Werror and exit codesscripts/kernel-doc.py scripts/lib/kdoc/kdoc_files.py scripts/lib/kdoc/kdoc_output.py +1 more+35 -180 replies
29/33scripts/kernel-doc: switch to use kernel-doc.pyscripts/kernel-doc+1 -10 replies
30/33scripts/lib/kdoc/kdoc_files.py: allow filtering output per fnamescripts/lib/kdoc/kdoc_files.py+12 -120 replies
31/33scripts/kernel_doc.py: better handle exported symbolsscripts/kernel-doc.py scripts/lib/kdoc/kdoc_files.py scripts/lib/kdoc/kdoc_output.py +1 more+125 -800 replies
32/33scripts/kernel-doc.py: Rename the kernel doc Re class to KernRescripts/lib/kdoc/kdoc_output.py scripts/lib/kdoc/kdoc_parser.py scripts/lib/kdoc/kdoc_re.py+159 -1590 replies
33/33scripts: kernel-doc: fix parsing function-like typedefs (again)scripts/kernel-doc.pl scripts/lib/kdoc/kdoc_parser.py+2 -20 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 00/33] Implement kernel-doc in Python

Hi Jon,

This changeset contains the kernel-doc.py script to replace the verable kernel-doc originally written in Perl. It replaces the first version and the second series I sent on the top of it.

I tried to stay as close as possible of the original Perl implementation on the first patch introducing kernel-doc.py, as it helps to double check if each function was properly translated to Python. This have been helpful debugging troubles that happened during the conversion.

I worked hard to make it bug-compatible with the original one. Still, its output has a couple of differences from the original one:

- The tab expansion works better with the Python script. With that, some outputs that contain tabs at kernel-doc markups are now different;

- The new script works better stripping blank lines. So, there are a couple of empty new lines that are now stripped with this version;

- There is a buggy logic at kernel-doc to strip empty description and return sections. I was not able to replicate the exact behavior. So, I ended adding an extra logic to strip empty sections with a different algorithm.

Yet, on my tests, the results are compatible with the venerable script output for all .. kernel-doc tags found in Documentation/. I double-checked this by adding support to output the kernel-doc commands when V=1, and then I ran a diff between kernel-doc.pl and kernel-doc.py for the same command lines.

The only patch that doesn't belong to this series is a patch dropping kernel-doc.pl. I opted to keep it for now, as it can help to better test the new tools.

With such changes, if one wants to build docs with the old script, all it is needed is to use KERNELDOC parameter, e.g.:

	$ make KERNELDOC=scripts/kernel-doc.pl htmldocs

---

v3:
- rebased on the top of v6.15-rc1;
- Removed patches that weren't touching kernel-doc and its Sphinx extension;
- The "Re" class was renamed to "KernRe"
- It contains one patch from Sean with an additional hunk for the python version.

Mauro Carvalho Chehab (32):
scripts/kernel-doc: rename it to scripts/kernel-doc.pl scripts/kernel-doc: add a symlink to the Perl version of kernel-doc scripts/kernel-doc.py: add a Python parser scripts/kernel-doc.py: output warnings the same way as kerneldoc scripts/kernel-doc.py: better handle empty sections scripts/kernel-doc.py: properly handle struct_group macros scripts/kernel-doc.py: move regex methods to a separate file scripts/kernel-doc.py: move KernelDoc class to a separate file scripts/kernel-doc.py: move KernelFiles class to a separate file scripts/kernel-doc.py: move output classes to a separate file scripts/kernel-doc.py: convert message output to an interactor scripts/kernel-doc.py: move file lists to the parser function scripts/kernel-doc.py: implement support for -no-doc-sections scripts/kernel-doc.py: fix line number output scripts/kernel-doc.py: fix handling of doc output check scripts/kernel-doc.py: properly handle out_section for ReST scripts/kernel-doc.py: postpone warnings to the output plugin
docs: add a .pylintrc file with sys path for docs scripts
docs: sphinx: kerneldoc: verbose kernel-doc command if V=1
docs: sphinx: kerneldoc: ignore "\" characters from options
docs: sphinx: kerneldoc: use kernel-doc.py script scripts/kernel-doc.py: Set an output format for --none scripts/kernel-doc.py: adjust some coding style issues scripts/lib/kdoc/kdoc_parser.py: fix Python compat with < v3.13 scripts/kernel-doc.py: move modulename to man class scripts/kernel-doc.py: properly handle KBUILD_BUILD_TIMESTAMP scripts/lib/kdoc/kdoc_parser.py: remove a python 3.9 dependency scripts/kernel-doc.py: Properly handle Werror and exit codes scripts/kernel-doc: switch to use kernel-doc.py scripts/lib/kdoc/kdoc_files.py: allow filtering output per fname scripts/kernel_doc.py: better handle exported symbols scripts/kernel-doc.py: Rename the kernel doc Re class to KernRe

Sean Anderson (1):
scripts: kernel-doc: fix parsing function-like typedefs (again)

 .pylintrc                         |    2 +
 Documentation/Makefile            |    2 +-
 Documentation/conf.py             |    2 +-
 Documentation/sphinx/kerneldoc.py |   46 +
 scripts/kernel-doc                | 2440 +----------------------------
 scripts/kernel-doc.pl             | 2439 ++++++++++++++++++++++++++++
 scripts/kernel-doc.py             |  315 ++++
 scripts/lib/kdoc/kdoc_files.py    |  282 ++++
 scripts/lib/kdoc/kdoc_output.py   |  793 ++++++++++
 scripts/lib/kdoc/kdoc_parser.py   | 1715 ++++++++++++++++++++
 scripts/lib/kdoc/kdoc_re.py       |  273 ++++
 11 files changed, 5868 insertions(+), 2441 deletions(-)
 create mode 100644 .pylintrc
 mode change 100755 => 120000 scripts/kernel-doc
 create mode 100755 scripts/kernel-doc.pl
 create mode 100755 scripts/kernel-doc.py
 create mode 100644 scripts/lib/kdoc/kdoc_files.py
 create mode 100755 scripts/lib/kdoc/kdoc_output.py
 create mode 100755 scripts/lib/kdoc/kdoc_parser.py
 create mode 100755 scripts/lib/kdoc/kdoc_re.py
Signature · 1 line
2.49.0