History

docs: kdoc_parser: move nested match transforms to xforms_lists.py

As NestedMatch now has a sub method and a declaration close to what KernRe does, we can move the rules to xforms_lists and simplify kdoc_parser a little bit. No functional changes.

Mauro Carvalho Chehab committed 8 months ago

Commit 85c2a511 parent fc44c0a2 files · +13 −22Browse files

Showing the changes to tools/lib/python (2 of 2 files). Show all

Unified · Split

2 files
  1. tools/lib/python/kdoc/kdoc_parser.py +0 −21
  2. tools/lib/python/kdoc/xforms_lists.py +13 −1
tools/lib/python/kdoc/kdoc_parser.py+0−21
@@ -69,25 +69,6 @@ doc_begin_func = KernRe(str(doc_com) + # initial " * ' · 68 unmodified lines
6969 r'(?:[-:].*)?$', # description (not captured)
7070 cache = False)
7171
72−#
73−# Regexes here are guaranteed to have the end delimiter matching
74−# the start delimiter. Yet, right now, only one replace group
75−# is allowed.
76−#
77−struct_nested_prefixes = [
78− (NestedMatch(r"__cond_acquires\s*\("), ""),
79− (NestedMatch(r"__cond_releases\s*\("), ""),
80− (NestedMatch(r"__acquires\s*\("), ""),
81− (NestedMatch(r"__releases\s*\("), ""),
82− (NestedMatch(r"__must_hold\s*\("), ""),
83− (NestedMatch(r"__must_not_hold\s*\("), ""),
84− (NestedMatch(r"__must_hold_shared\s*\("), ""),
85− (NestedMatch(r"__cond_acquires_shared\s*\("), ""),
86− (NestedMatch(r"__acquires_shared\s*\("), ""),
87− (NestedMatch(r"__releases_shared\s*\("), ""),
88− (NestedMatch(r'\bSTRUCT_GROUP\('), r'\0'),
89−]
90−
9172 #
9273 # Ancillary functions
9374 #
@@ -761,8 +742,6 @@ class KernelDoc: · 667 unmodified lines
761742 members = trim_private_members(members)
762743 members = self.xforms.apply("struct", members)
763744
764− for search, sub in struct_nested_prefixes:
765− members = search.sub(search, sub, members)
766745 #
767746 # Deal with embedded struct and union members, and drop enums entirely.
768747 #
tools/lib/python/kdoc/xforms_lists.py+13−1
@@ -4,7 +4,7 @@ · 3 unmodified lines
44
55 import re
66
7−from kdoc.kdoc_re import KernRe
7+from kdoc.kdoc_re import KernRe, NestedMatch
88
99 struct_args_pattern = r'([^,)]+)'
1010
@@ -94,6 +94,18 @@ class CTransforms: · 83 unmodified lines
9494 (KernRe(r'DEFINE_DMA_UNMAP_ADDR\s*\(' + struct_args_pattern + r'\)', re.S), r'dma_addr_t \1'),
9595 (KernRe(r'DEFINE_DMA_UNMAP_LEN\s*\(' + struct_args_pattern + r'\)', re.S), r'__u32 \1'),
9696 (KernRe(r'VIRTIO_DECLARE_FEATURES\(([\w_]+)\)'), r'union { u64 \1; u64 \1_array[VIRTIO_FEATURES_U64S]; }'),
97+
98+ (NestedMatch(r"__cond_acquires\s*\("), ""),
99+ (NestedMatch(r"__cond_releases\s*\("), ""),
100+ (NestedMatch(r"__acquires\s*\("), ""),
101+ (NestedMatch(r"__releases\s*\("), ""),
102+ (NestedMatch(r"__must_hold\s*\("), ""),
103+ (NestedMatch(r"__must_not_hold\s*\("), ""),
104+ (NestedMatch(r"__must_hold_shared\s*\("), ""),
105+ (NestedMatch(r"__cond_acquires_shared\s*\("), ""),
106+ (NestedMatch(r"__acquires_shared\s*\("), ""),
107+ (NestedMatch(r"__releases_shared\s*\("), ""),
108+ (NestedMatch(r'\bSTRUCT_GROUP\('), r'\0'),
97109 ]
98110
99111 #: Transforms for function prototypes.