[PATCH v2 24/25] docs: kdoc_parser: better handle struct_group macros

Mauro Carvalho Chehab posted 25 patches 1 week, 3 days ago
There is a newer version of this series
[PATCH v2 24/25] docs: kdoc_parser: better handle struct_group macros
Posted by Mauro Carvalho Chehab 1 week, 3 days ago
Instead of converting them on two steps, implement a single
logic to parse them using the new sub functionality of
NestedMatch.sub().

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

diff --git a/tools/lib/python/kdoc/kdoc_parser.py b/tools/lib/python/kdoc/kdoc_parser.py
index 3a5614106af7..d2eb93f9d489 100644
--- a/tools/lib/python/kdoc/kdoc_parser.py
+++ b/tools/lib/python/kdoc/kdoc_parser.py
@@ -124,10 +124,11 @@ struct_xforms = [
     # matched. So, the implementation to drop STRUCT_GROUP() will be
     # handled in separate.
     #
-    (KernRe(r'\bstruct_group\s*\(([^,]*,)', re.S), r'STRUCT_GROUP('),
-    (KernRe(r'\bstruct_group_attr\s*\(([^,]*,){2}', re.S), r'STRUCT_GROUP('),
-    (KernRe(r'\bstruct_group_tagged\s*\(([^,]*),([^,]*),', re.S), r'struct \1 \2; STRUCT_GROUP('),
-    (KernRe(r'\b__struct_group\s*\(([^,]*,){3}', re.S), r'STRUCT_GROUP('),
+    (NestedMatch(r'\bstruct_group\s*\('), r'\2'),
+    (NestedMatch(r'\bstruct_group_attr\s*\('), r'\3'),
+    (NestedMatch(r'\bstruct_group_tagged\s*\('), r'struct \1 { \3 } \2;'),
+    (NestedMatch(r'\b__struct_group\s*\('), r'\4'),
+
     #
     # Replace macros
     #
@@ -153,7 +154,6 @@ struct_xforms = [
     (KernRe(r'DEFINE_DMA_UNMAP_ADDR\s*\(' + struct_args_pattern + r'\)', re.S), r'dma_addr_t \1'),
     (KernRe(r'DEFINE_DMA_UNMAP_LEN\s*\(' + struct_args_pattern + r'\)', re.S), r'__u32 \1'),
     (KernRe(r'VIRTIO_DECLARE_FEATURES\(([\w_]+)\)'), r'union { u64 \1; u64 \1_array[VIRTIO_FEATURES_U64S]; }'),
-    (NestedMatch(r'\bSTRUCT_GROUP\('), r'\0'),
 ]
 
 #
-- 
2.52.0
RE: [Intel-wired-lan] [PATCH v2 24/25] docs: kdoc_parser: better handle struct_group macros
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 24/25] docs: kdoc_parser: better
> handle struct_group macros
> 
> Instead of converting them on two steps, implement a single logic to
> parse them using the new sub functionality of NestedMatch.sub().
> 
> Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
> ---
>  tools/lib/python/kdoc/kdoc_parser.py | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/tools/lib/python/kdoc/kdoc_parser.py
> b/tools/lib/python/kdoc/kdoc_parser.py
> index 3a5614106af7..d2eb93f9d489 100644
> --- a/tools/lib/python/kdoc/kdoc_parser.py
> +++ b/tools/lib/python/kdoc/kdoc_parser.py
> @@ -124,10 +124,11 @@ struct_xforms = [
>      # matched. So, the implementation to drop STRUCT_GROUP() will be
>      # handled in separate.
>      #
> -    (KernRe(r'\bstruct_group\s*\(([^,]*,)', re.S), r'STRUCT_GROUP('),
> -    (KernRe(r'\bstruct_group_attr\s*\(([^,]*,){2}', re.S),
> r'STRUCT_GROUP('),
> -    (KernRe(r'\bstruct_group_tagged\s*\(([^,]*),([^,]*),', re.S),
> r'struct \1 \2; STRUCT_GROUP('),
> -    (KernRe(r'\b__struct_group\s*\(([^,]*,){3}', re.S),
> r'STRUCT_GROUP('),
> +    (NestedMatch(r'\bstruct_group\s*\('), r'\2'),
> +    (NestedMatch(r'\bstruct_group_attr\s*\('), r'\3'),
> +    (NestedMatch(r'\bstruct_group_tagged\s*\('), r'struct \1 { \3 }
> \2;'),
> +    (NestedMatch(r'\b__struct_group\s*\('), r'\4'),
> +
>      #
>      # Replace macros
>      #
> @@ -153,7 +154,6 @@ struct_xforms = [
>      (KernRe(r'DEFINE_DMA_UNMAP_ADDR\s*\(' + struct_args_pattern +
> r'\)', re.S), r'dma_addr_t \1'),
>      (KernRe(r'DEFINE_DMA_UNMAP_LEN\s*\(' + struct_args_pattern +
> r'\)', re.S), r'__u32 \1'),
>      (KernRe(r'VIRTIO_DECLARE_FEATURES\(([\w_]+)\)'), r'union { u64
> \1; u64 \1_array[VIRTIO_FEATURES_U64S]; }'),
> -    (NestedMatch(r'\bSTRUCT_GROUP\('), r'\0'),
>  ]
> 
>  #
> --
> 2.52.0
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>