docs: kdoc_re: make NestedMatch use KernRe

Instead of using re_compile, let's create the class with the
regex and use KernRe to keep it cached.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Reviewed-by: Aleksandr Loktionov <aleksandr.loktionov@intel.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <cdf900faf0ed8a08f8c6ac1db5a43342968c0739.1772469446.git.mchehab+huawei@kernel.org>
This commit is contained in:
Mauro Carvalho Chehab
2026-03-02 17:41:00 +01:00
committed by Jonathan Corbet
parent 34503b5fd1
commit fc44c0a0b2
2 changed files with 29 additions and 20 deletions

View File

@@ -75,17 +75,17 @@ doc_begin_func = KernRe(str(doc_com) + # initial " * '
# is allowed.
#
struct_nested_prefixes = [
(re.compile(r"__cond_acquires\s*\("), ""),
(re.compile(r"__cond_releases\s*\("), ""),
(re.compile(r"__acquires\s*\("), ""),
(re.compile(r"__releases\s*\("), ""),
(re.compile(r"__must_hold\s*\("), ""),
(re.compile(r"__must_not_hold\s*\("), ""),
(re.compile(r"__must_hold_shared\s*\("), ""),
(re.compile(r"__cond_acquires_shared\s*\("), ""),
(re.compile(r"__acquires_shared\s*\("), ""),
(re.compile(r"__releases_shared\s*\("), ""),
(re.compile(r'\bSTRUCT_GROUP\('), r'\0'),
(NestedMatch(r"__cond_acquires\s*\("), ""),
(NestedMatch(r"__cond_releases\s*\("), ""),
(NestedMatch(r"__acquires\s*\("), ""),
(NestedMatch(r"__releases\s*\("), ""),
(NestedMatch(r"__must_hold\s*\("), ""),
(NestedMatch(r"__must_not_hold\s*\("), ""),
(NestedMatch(r"__must_hold_shared\s*\("), ""),
(NestedMatch(r"__cond_acquires_shared\s*\("), ""),
(NestedMatch(r"__acquires_shared\s*\("), ""),
(NestedMatch(r"__releases_shared\s*\("), ""),
(NestedMatch(r'\bSTRUCT_GROUP\('), r'\0'),
]
#
@@ -761,9 +761,8 @@ class KernelDoc:
members = trim_private_members(members)
members = self.xforms.apply("struct", members)
nested = NestedMatch()
for search, sub in struct_nested_prefixes:
members = nested.sub(search, sub, members)
members = search.sub(search, sub, members)
#
# Deal with embedded struct and union members, and drop enums entirely.
#