scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
#!/usr/bin/env python3
|
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
# Copyright(c) 2025: Mauro Carvalho Chehab <mchehab@kernel.org>.
|
|
|
|
#
|
2025-04-08 10:09:13 +00:00
|
|
|
# pylint: disable=C0103
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
#
|
|
|
|
# Converted from the kernel-doc script originally written in Perl
|
|
|
|
# under GPLv2, copyrighted since 1998 by the following authors:
|
|
|
|
#
|
|
|
|
# Aditya Srivastava <yashsri421@gmail.com>
|
|
|
|
# Akira Yokosawa <akiyks@gmail.com>
|
|
|
|
# Alexander A. Klimov <grandmaster@al2klimov.de>
|
|
|
|
# Alexander Lobakin <aleksander.lobakin@intel.com>
|
|
|
|
# André Almeida <andrealmeid@igalia.com>
|
|
|
|
# Andy Shevchenko <andriy.shevchenko@linux.intel.com>
|
|
|
|
# Anna-Maria Behnsen <anna-maria@linutronix.de>
|
|
|
|
# Armin Kuster <akuster@mvista.com>
|
|
|
|
# Bart Van Assche <bart.vanassche@sandisk.com>
|
|
|
|
# Ben Hutchings <ben@decadent.org.uk>
|
|
|
|
# Borislav Petkov <bbpetkov@yahoo.de>
|
|
|
|
# Chen-Yu Tsai <wenst@chromium.org>
|
|
|
|
# Coco Li <lixiaoyan@google.com>
|
|
|
|
# Conchúr Navid <conchur@web.de>
|
|
|
|
# Daniel Santos <daniel.santos@pobox.com>
|
|
|
|
# Danilo Cesar Lemes de Paula <danilo.cesar@collabora.co.uk>
|
|
|
|
# Dan Luedtke <mail@danrl.de>
|
|
|
|
# Donald Hunter <donald.hunter@gmail.com>
|
|
|
|
# Gabriel Krisman Bertazi <krisman@collabora.co.uk>
|
|
|
|
# Greg Kroah-Hartman <gregkh@linuxfoundation.org>
|
|
|
|
# Harvey Harrison <harvey.harrison@gmail.com>
|
|
|
|
# Horia Geanta <horia.geanta@freescale.com>
|
|
|
|
# Ilya Dryomov <idryomov@gmail.com>
|
|
|
|
# Jakub Kicinski <kuba@kernel.org>
|
|
|
|
# Jani Nikula <jani.nikula@intel.com>
|
|
|
|
# Jason Baron <jbaron@redhat.com>
|
|
|
|
# Jason Gunthorpe <jgg@nvidia.com>
|
|
|
|
# Jérémy Bobbio <lunar@debian.org>
|
|
|
|
# Johannes Berg <johannes.berg@intel.com>
|
|
|
|
# Johannes Weiner <hannes@cmpxchg.org>
|
|
|
|
# Jonathan Cameron <Jonathan.Cameron@huawei.com>
|
|
|
|
# Jonathan Corbet <corbet@lwn.net>
|
|
|
|
# Jonathan Neuschäfer <j.neuschaefer@gmx.net>
|
|
|
|
# Kamil Rytarowski <n54@gmx.com>
|
|
|
|
# Kees Cook <kees@kernel.org>
|
|
|
|
# Laurent Pinchart <laurent.pinchart@ideasonboard.com>
|
|
|
|
# Levin, Alexander (Sasha Levin) <alexander.levin@verizon.com>
|
|
|
|
# Linus Torvalds <torvalds@linux-foundation.org>
|
|
|
|
# Lucas De Marchi <lucas.demarchi@profusion.mobi>
|
|
|
|
# Mark Rutland <mark.rutland@arm.com>
|
|
|
|
# Markus Heiser <markus.heiser@darmarit.de>
|
|
|
|
# Martin Waitz <tali@admingilde.org>
|
|
|
|
# Masahiro Yamada <masahiroy@kernel.org>
|
|
|
|
# Matthew Wilcox <willy@infradead.org>
|
|
|
|
# Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
|
|
|
|
# Michal Wajdeczko <michal.wajdeczko@intel.com>
|
|
|
|
# Michael Zucchi
|
|
|
|
# Mike Rapoport <rppt@linux.ibm.com>
|
|
|
|
# Niklas Söderlund <niklas.soderlund@corigine.com>
|
|
|
|
# Nishanth Menon <nm@ti.com>
|
|
|
|
# Paolo Bonzini <pbonzini@redhat.com>
|
|
|
|
# Pavan Kumar Linga <pavan.kumar.linga@intel.com>
|
|
|
|
# Pavel Pisa <pisa@cmp.felk.cvut.cz>
|
|
|
|
# Peter Maydell <peter.maydell@linaro.org>
|
|
|
|
# Pierre-Louis Bossart <pierre-louis.bossart@linux.intel.com>
|
|
|
|
# Randy Dunlap <rdunlap@infradead.org>
|
|
|
|
# Richard Kennedy <richard@rsk.demon.co.uk>
|
|
|
|
# Rich Walker <rw@shadow.org.uk>
|
|
|
|
# Rolf Eike Beer <eike-kernel@sf-tec.de>
|
|
|
|
# Sakari Ailus <sakari.ailus@linux.intel.com>
|
|
|
|
# Silvio Fricke <silvio.fricke@gmail.com>
|
|
|
|
# Simon Huggins
|
|
|
|
# Tim Waugh <twaugh@redhat.com>
|
|
|
|
# Tomasz Warniełło <tomasz.warniello@gmail.com>
|
|
|
|
# Utkarsh Tripathi <utripathi2002@gmail.com>
|
|
|
|
# valdis.kletnieks@vt.edu <valdis.kletnieks@vt.edu>
|
|
|
|
# Vegard Nossum <vegard.nossum@oracle.com>
|
|
|
|
# Will Deacon <will.deacon@arm.com>
|
|
|
|
# Yacine Belkadi <yacine.belkadi.1@gmail.com>
|
|
|
|
# Yujie Liu <yujie.liu@intel.com>
|
|
|
|
|
|
|
|
# TODO: implement warning filtering
|
|
|
|
|
|
|
|
"""
|
|
|
|
kernel_doc
|
|
|
|
==========
|
|
|
|
|
|
|
|
Print formatted kernel documentation to stdout
|
|
|
|
|
|
|
|
Read C language source or header FILEs, extract embedded
|
|
|
|
documentation comments, and print formatted documentation
|
|
|
|
to standard output.
|
|
|
|
|
|
|
|
The documentation comments are identified by the "/**"
|
|
|
|
opening comment mark.
|
|
|
|
|
|
|
|
See Documentation/doc-guide/kernel-doc.rst for the
|
|
|
|
documentation comment syntax.
|
|
|
|
"""
|
|
|
|
|
|
|
|
import argparse
|
|
|
|
import logging
|
|
|
|
import os
|
|
|
|
import sys
|
|
|
|
|
2025-04-08 10:09:10 +00:00
|
|
|
# Import Python modules
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
|
2025-04-08 10:09:10 +00:00
|
|
|
LIB_DIR = "lib/kdoc"
|
|
|
|
SRC_DIR = os.path.dirname(os.path.realpath(__file__))
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
|
2025-04-08 10:09:10 +00:00
|
|
|
sys.path.insert(0, os.path.join(SRC_DIR, LIB_DIR))
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
|
2025-04-08 10:09:13 +00:00
|
|
|
from kdoc_files import KernelFiles # pylint: disable=C0413
|
|
|
|
from kdoc_output import RestFormat, ManFormat # pylint: disable=C0413
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
|
|
|
|
DESC = """
|
|
|
|
Read C language source or header FILEs, extract embedded documentation comments,
|
|
|
|
and print formatted documentation to standard output.
|
|
|
|
|
|
|
|
The documentation comments are identified by the "/**" opening comment mark.
|
|
|
|
|
|
|
|
See Documentation/doc-guide/kernel-doc.rst for the documentation comment syntax.
|
|
|
|
"""
|
|
|
|
|
|
|
|
EXPORT_FILE_DESC = """
|
|
|
|
Specify an additional FILE in which to look for EXPORT_SYMBOL information.
|
|
|
|
|
|
|
|
May be used multiple times.
|
|
|
|
"""
|
|
|
|
|
|
|
|
EXPORT_DESC = """
|
|
|
|
Only output documentation for the symbols that have been
|
|
|
|
exported using EXPORT_SYMBOL() and related macros in any input
|
|
|
|
FILE or -export-file FILE.
|
|
|
|
"""
|
|
|
|
|
|
|
|
INTERNAL_DESC = """
|
|
|
|
Only output documentation for the symbols that have NOT been
|
|
|
|
exported using EXPORT_SYMBOL() and related macros in any input
|
|
|
|
FILE or -export-file FILE.
|
|
|
|
"""
|
|
|
|
|
|
|
|
FUNCTION_DESC = """
|
|
|
|
Only output documentation for the given function or DOC: section
|
|
|
|
title. All other functions and DOC: sections are ignored.
|
|
|
|
|
|
|
|
May be used multiple times.
|
|
|
|
"""
|
|
|
|
|
|
|
|
NOSYMBOL_DESC = """
|
|
|
|
Exclude the specified symbol from the output documentation.
|
|
|
|
|
|
|
|
May be used multiple times.
|
|
|
|
"""
|
|
|
|
|
|
|
|
FILES_DESC = """
|
|
|
|
Header and C source files to be parsed.
|
|
|
|
"""
|
|
|
|
|
|
|
|
WARN_CONTENTS_BEFORE_SECTIONS_DESC = """
|
|
|
|
Warns if there are contents before sections (deprecated).
|
|
|
|
|
|
|
|
This option is kept just for backward-compatibility, but it does nothing,
|
|
|
|
neither here nor at the original Perl script.
|
|
|
|
"""
|
|
|
|
|
|
|
|
|
2025-04-08 10:09:07 +00:00
|
|
|
class MsgFormatter(logging.Formatter):
|
|
|
|
def format(self, record):
|
|
|
|
record.levelname = record.levelname.capitalize()
|
|
|
|
return logging.Formatter.format(self, record)
|
|
|
|
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
def main():
|
|
|
|
"""Main program"""
|
|
|
|
|
|
|
|
parser = argparse.ArgumentParser(formatter_class=argparse.RawTextHelpFormatter,
|
|
|
|
description=DESC)
|
|
|
|
|
|
|
|
# Normal arguments
|
|
|
|
|
|
|
|
parser.add_argument("-v", "-verbose", "--verbose", action="store_true",
|
|
|
|
help="Verbose output, more warnings and other information.")
|
|
|
|
|
|
|
|
parser.add_argument("-d", "-debug", "--debug", action="store_true",
|
|
|
|
help="Enable debug messages")
|
|
|
|
|
|
|
|
parser.add_argument("-M", "-modulename", "--modulename",
|
|
|
|
help="Allow setting a module name at the output.")
|
|
|
|
|
|
|
|
parser.add_argument("-l", "-enable-lineno", "--enable_lineno",
|
|
|
|
action="store_true",
|
|
|
|
help="Enable line number output (only in ReST mode)")
|
|
|
|
|
|
|
|
# Arguments to control the warning behavior
|
|
|
|
|
|
|
|
parser.add_argument("-Wreturn", "--wreturn", action="store_true",
|
|
|
|
help="Warns about the lack of a return markup on functions.")
|
|
|
|
|
|
|
|
parser.add_argument("-Wshort-desc", "-Wshort-description", "--wshort-desc",
|
|
|
|
action="store_true",
|
|
|
|
help="Warns if initial short description is missing")
|
|
|
|
|
|
|
|
parser.add_argument("-Wcontents-before-sections",
|
|
|
|
"--wcontents-before-sections", action="store_true",
|
|
|
|
help=WARN_CONTENTS_BEFORE_SECTIONS_DESC)
|
|
|
|
|
|
|
|
parser.add_argument("-Wall", "--wall", action="store_true",
|
|
|
|
help="Enable all types of warnings")
|
|
|
|
|
|
|
|
parser.add_argument("-Werror", "--werror", action="store_true",
|
|
|
|
help="Treat warnings as errors.")
|
|
|
|
|
|
|
|
parser.add_argument("-export-file", "--export-file", action='append',
|
|
|
|
help=EXPORT_FILE_DESC)
|
|
|
|
|
|
|
|
# Output format mutually-exclusive group
|
|
|
|
|
|
|
|
out_group = parser.add_argument_group("Output format selection (mutually exclusive)")
|
|
|
|
|
|
|
|
out_fmt = out_group.add_mutually_exclusive_group()
|
|
|
|
|
|
|
|
out_fmt.add_argument("-m", "-man", "--man", action="store_true",
|
|
|
|
help="Output troff manual page format.")
|
|
|
|
out_fmt.add_argument("-r", "-rst", "--rst", action="store_true",
|
|
|
|
help="Output reStructuredText format (default).")
|
|
|
|
out_fmt.add_argument("-N", "-none", "--none", action="store_true",
|
|
|
|
help="Do not output documentation, only warnings.")
|
|
|
|
|
|
|
|
# Output selection mutually-exclusive group
|
|
|
|
|
|
|
|
sel_group = parser.add_argument_group("Output selection (mutually exclusive)")
|
|
|
|
sel_mut = sel_group.add_mutually_exclusive_group()
|
|
|
|
|
|
|
|
sel_mut.add_argument("-e", "-export", "--export", action='store_true',
|
|
|
|
help=EXPORT_DESC)
|
|
|
|
|
|
|
|
sel_mut.add_argument("-i", "-internal", "--internal", action='store_true',
|
|
|
|
help=INTERNAL_DESC)
|
|
|
|
|
|
|
|
sel_mut.add_argument("-s", "-function", "--symbol", action='append',
|
|
|
|
help=FUNCTION_DESC)
|
|
|
|
|
|
|
|
# This one is valid for all 3 types of filter
|
|
|
|
parser.add_argument("-n", "-nosymbol", "--nosymbol", action='append',
|
|
|
|
help=NOSYMBOL_DESC)
|
|
|
|
|
|
|
|
parser.add_argument("files", metavar="FILE",
|
|
|
|
nargs="+", help=FILES_DESC)
|
|
|
|
|
|
|
|
args = parser.parse_args()
|
|
|
|
|
|
|
|
if args.wall:
|
|
|
|
args.wreturn = True
|
|
|
|
args.wshort_desc = True
|
|
|
|
args.wcontents_before_sections = True
|
|
|
|
|
2025-04-08 10:09:07 +00:00
|
|
|
logger = logging.getLogger()
|
|
|
|
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
if not args.debug:
|
2025-04-08 10:09:07 +00:00
|
|
|
logger.setLevel(logging.INFO)
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
else:
|
2025-04-08 10:09:07 +00:00
|
|
|
logger.setLevel(logging.DEBUG)
|
|
|
|
|
|
|
|
formatter = MsgFormatter('%(levelname)s: %(message)s')
|
|
|
|
|
|
|
|
handler = logging.StreamHandler()
|
|
|
|
handler.setFormatter(formatter)
|
|
|
|
|
|
|
|
logger.addHandler(handler)
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
|
|
|
|
if args.man:
|
|
|
|
out_style = ManFormat()
|
|
|
|
elif args.none:
|
|
|
|
out_style = None
|
|
|
|
else:
|
|
|
|
out_style = RestFormat()
|
|
|
|
|
2025-04-08 10:09:15 +00:00
|
|
|
kfiles = KernelFiles(verbose=args.verbose,
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
out_style=out_style, werror=args.werror,
|
|
|
|
wreturn=args.wreturn, wshort_desc=args.wshort_desc,
|
|
|
|
wcontents_before_sections=args.wcontents_before_sections,
|
2025-04-08 10:09:15 +00:00
|
|
|
modulename=args.modulename)
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
|
2025-04-08 10:09:15 +00:00
|
|
|
kfiles.parse(args.files, export_file=args.export_file)
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
|
2025-04-08 10:09:14 +00:00
|
|
|
for t in kfiles.msg(enable_lineno=args.enable_lineno, export=args.export,
|
|
|
|
internal=args.internal, symbol=args.symbol,
|
|
|
|
nosymbol=args.nosymbol):
|
|
|
|
msg = t[1]
|
|
|
|
if msg:
|
|
|
|
print(msg)
|
scripts/kernel-doc.py: add a Python parser
Maintaining kernel-doc has been a challenge, as there aren't many
perl developers among maintainers. Also, the logic there is too
complex. Having lots of global variables and using pure functions
doesn't help.
Rewrite the script in Python, placing most global variables
inside classes. This should help maintaining the script in long
term.
It also allows a better integration with kernel-doc Sphinx
extension in the future.
I opted to keep this version as close as possible to what we
have already in Perl. There are some differences though:
1. There is one regular expression that required a rewrite:
/\bSTRUCT_GROUP(\(((?:(?>[^)(]+)|(?1))*)\))[^;]*;/
As this one uses two features that aren't available by the native
Python regular expression module (re):
- recursive patterns: ?1
- atomic grouping (?>...)
Rewrite it to use a much simpler regular expression:
/\bSTRUCT_GROUP\(([^\)]+)\)[^;]*;/
Extra care should be taken when validating this script, as such
replacement might cause some regressions.
2. The filters are now applied only during output generation.
In particular, "nosymbol" argument is only handled there.
It means that, if the same file is processed twice for
different symbols, the warnings will be duplicated.
I opted to use this behavior as it allows the Sphinx extension
to read the file(s) only once, and apply the filtering only
when producing the ReST output. This hopefully will help
to speed up doc generation
3. This version can handle multiple files and multiple directories.
So, if one just wants to produce a big output with everything
inside a file, this could be done with
$ time ./scripts/kernel-doc.py -man . 2>/dev/null >new
real 0m54.592s
user 0m53.345s
sys 0m0.997s
4. I tried to replicate as much as possible the same arguments
from kernel-doc, with about the same behavior, for the
command line parameters starting with a single dash (-parameter).
I also added one letter aliases for each parameter, and a
--parameter (sometimes with a better name).
5. There are some sutile nuances between how Perl handles
certain regular expressions. In special, the qr operatior,
which compiles a regular expression also works as a
non-capturing group. It means that some regexes like
this one:
my $type1 = qr{[\w\s]+};
needs to be mapped as:
type1 = r'(?:[\w\s]+)?'
Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/2fa671a9fb08d03a376a42d46cc0b1d3aab4ae3f.1744106241.git.mchehab+huawei@kernel.org
2025-04-08 10:09:06 +00:00
|
|
|
|
|
|
|
|
|
|
|
# Call main method
|
|
|
|
if __name__ == "__main__":
|
|
|
|
main()
|