[PATCH v2 16/25] docs: kdoc_re: better show KernRe() at documentation

Mauro Carvalho Chehab posted 25 patches 1 week, 3 days ago
There is a newer version of this series
[PATCH v2 16/25] docs: kdoc_re: better show KernRe() at documentation
Posted by Mauro Carvalho Chehab 1 week, 3 days ago
the __repr__() function is used by autodoc to document macro
initialization.

Add a better representation for them.

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

diff --git a/tools/lib/python/kdoc/kdoc_re.py b/tools/lib/python/kdoc/kdoc_re.py
index 1861799f1966..f082f82bad67 100644
--- a/tools/lib/python/kdoc/kdoc_re.py
+++ b/tools/lib/python/kdoc/kdoc_re.py
@@ -52,7 +52,10 @@ class KernRe:
         return self.regex.pattern
 
     def __repr__(self):
-        return f're.compile("{self.regex.pattern}")'
+        if self.regex.flags:
+            return f'KernRe("{self.regex.pattern}", {self.regex.flags})'
+        else:
+            return f'KernRe("{self.regex.pattern}")'
 
     def __add__(self, other):
         """
-- 
2.52.0
RE: [Intel-wired-lan] [PATCH v2 16/25] docs: kdoc_re: better show KernRe() at documentation
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: Wednesday, January 28, 2026 5:50 PM
> 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-
> kernel@vger.kernel.org; netdev@vger.kernel.org; Peter Zijlstra
> <peterz@infradead.org>; Randy Dunlap <rdunlap@infradead.org>; Stephen
> Rothwell <sfr@canb.auug.org.au>
> Subject: [Intel-wired-lan] [PATCH v2 16/25] docs: kdoc_re: better show
> KernRe() at documentation
> 
> the __repr__() function is used by autodoc to document macro
> initialization.
> 
> Add a better representation for them.
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  tools/lib/python/kdoc/kdoc_re.py | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/tools/lib/python/kdoc/kdoc_re.py
> b/tools/lib/python/kdoc/kdoc_re.py
> index 1861799f1966..f082f82bad67 100644
> --- a/tools/lib/python/kdoc/kdoc_re.py
> +++ b/tools/lib/python/kdoc/kdoc_re.py
> @@ -52,7 +52,10 @@ class KernRe:
>          return self.regex.pattern
> 
>      def __repr__(self):
> -        return f're.compile("{self.regex.pattern}")'
> +        if self.regex.flags:
> +            return f'KernRe("{self.regex.pattern}",
> {self.regex.flags})'
> +        else:
> +            return f'KernRe("{self.regex.pattern}")'
> 
>      def __add__(self, other):
>          """
> --
> 2.52.0
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>