Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

docs: kdoc_re: Improve docstrings and comments

In preparation to document kernel-doc module, improve its
documentation.

Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Message-ID: <14a12a43144d52345bfd405d0401d246f0885acf.1768838938.git.mchehab+huawei@kernel.org>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
b0b88915 245f1ab2

+11 -7
+11 -7
tools/lib/python/kdoc/kdoc_re.py
··· 51 51 """ 52 52 return self.regex.pattern 53 53 54 + def __repr__(self): 55 + return f're.compile("{self.regex.pattern}")' 56 + 54 57 def __add__(self, other): 55 58 """ 56 59 Allows adding two regular expressions into one. ··· 64 61 65 62 def match(self, string): 66 63 """ 67 - Handles a re.match storing its results 64 + Handles a re.match storing its results. 68 65 """ 69 66 70 67 self.last_match = self.regex.match(string) ··· 72 69 73 70 def search(self, string): 74 71 """ 75 - Handles a re.search storing its results 72 + Handles a re.search storing its results. 76 73 """ 77 74 78 75 self.last_match = self.regex.search(string) ··· 80 77 81 78 def findall(self, string): 82 79 """ 83 - Alias to re.findall 80 + Alias to re.findall. 84 81 """ 85 82 86 83 return self.regex.findall(string) 87 84 88 85 def split(self, string): 89 86 """ 90 - Alias to re.split 87 + Alias to re.split. 91 88 """ 92 89 93 90 return self.regex.split(string) 94 91 95 92 def sub(self, sub, string, count=0): 96 93 """ 97 - Alias to re.sub 94 + Alias to re.sub. 98 95 """ 99 96 100 97 return self.regex.sub(sub, string, count=count) 101 98 102 99 def group(self, num): 103 100 """ 104 - Returns the group results of the last match 101 + Returns the group results of the last match. 105 102 """ 106 103 107 104 return self.last_match.group(num) ··· 113 110 even harder on Python with its normal re module, as there are several 114 111 advanced regular expressions that are missing. 115 112 116 - This is the case of this pattern: 113 + This is the case of this pattern:: 117 114 118 115 '\\bSTRUCT_GROUP(\\(((?:(?>[^)(]+)|(?1))*)\\))[^;]*;' 119 116 ··· 124 121 replace nested expressions. 125 122 126 123 The original approach was suggested by: 124 + 127 125 https://stackoverflow.com/questions/5454322/python-how-to-match-nested-parentheses-with-regex 128 126 129 127 Although I re-implemented it to make it more generic and match 3 types