[PATCH v3 25/30] docs: kdoc_re: add a helper class to declare C function matches

Mauro Carvalho Chehab posted 30 patches 1 week, 3 days ago
There is a newer version of this series
[PATCH v3 25/30] docs: kdoc_re: add a helper class to declare C function matches
Posted by Mauro Carvalho Chehab 1 week, 3 days ago
Add a more convenient class to match C functions and avoiding
issues at the beginning and ending of NestedMatch inits.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
---
 tools/lib/python/kdoc/kdoc_re.py | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/tools/lib/python/kdoc/kdoc_re.py b/tools/lib/python/kdoc/kdoc_re.py
index 5f455ffff7b2..a49b42e3d189 100644
--- a/tools/lib/python/kdoc/kdoc_re.py
+++ b/tools/lib/python/kdoc/kdoc_re.py
@@ -380,3 +380,14 @@ class NestedMatch:
         """
 
         return f'NestedMatch("{self.regex.regex.pattern}")'
+
+
+class CFunction(NestedMatch):
+    r"""
+    Variant of NestedMatch.
+
+    It overrides the init method to ensure that the regular expression will
+    start with a ``\b`` and end with a C function delimiter (open parenthesis).
+    """
+    def __init__(self, regex):
+        self.regex = KernRe(r"\b" + regex + r"\s*\(")
-- 
2.52.0
RE: [Intel-wired-lan] [PATCH v3 25/30] docs: kdoc_re: add a helper class to declare C function matches
Posted by Loktionov, Aleksandr 1 week, 3 days ago

> -----Original Message-----
> From: Intel-wired-lan <intel-wired-lan-bounces@osuosl.org> On Behalf
> Of Mauro Carvalho Chehab
> Sent: Thursday, January 29, 2026 9:08 AM
> To: Jonathan Corbet <corbet@lwn.net>; Linux Doc Mailing List <linux-
> doc@vger.kernel.org>
> Cc: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>;
> bpf@vger.kernel.org; intel-wired-lan@lists.osuosl.org; linux-
> hardening@vger.kernel.org; linux-kernel@vger.kernel.org;
> netdev@vger.kernel.org; Mauro Carvalho Chehab <mchehab@kernel.org>;
> Randy Dunlap <rdunlap@infradead.org>
> Subject: [Intel-wired-lan] [PATCH v3 25/30] docs: kdoc_re: add a
> helper class to declare C function matches
> 
> Add a more convenient class to match C functions and avoiding issues
> at the beginning and ending of NestedMatch inits.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  tools/lib/python/kdoc/kdoc_re.py | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/tools/lib/python/kdoc/kdoc_re.py
> b/tools/lib/python/kdoc/kdoc_re.py
> index 5f455ffff7b2..a49b42e3d189 100644
> --- a/tools/lib/python/kdoc/kdoc_re.py
> +++ b/tools/lib/python/kdoc/kdoc_re.py
> @@ -380,3 +380,14 @@ class NestedMatch:
>          """
> 
>          return f'NestedMatch("{self.regex.regex.pattern}")'
> +
> +
> +class CFunction(NestedMatch):
> +    r"""
> +    Variant of NestedMatch.
> +
> +    It overrides the init method to ensure that the regular
> expression will
> +    start with a ``\b`` and end with a C function delimiter (open
> parenthesis).
> +    """
> +    def __init__(self, regex):
> +        self.regex = KernRe(r"\b" + regex + r"\s*\(")
> --
> 2.52.0

Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>