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: don't reinvent string.strip()

process_proto_type() and process_proto_function() reinventing the strip()
string method with a whole series of separate regexes; take all that out
and just use strip().

The previous implementation also (in process_proto_type()) removed C++
comments *after* the above dance, leaving trailing whitespace in that case;
now we do the stripping afterward. This results in exactly one output
change: the removal of a spurious space in the definition of
BACKLIGHT_POWER_REDUCED - see
https://docs.kernel.org/gpu/backlight.html#c.backlight_properties.

I note that we are putting semicolons after #define lines that really
shouldn't be there - a task for another day.

Reviewed-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
Tested-by: Akira Yokosawa <akiyks@gmail.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>
Link: https://lore.kernel.org/r/20250703184403.274408-2-corbet@lwn.net

+5 -22
+5 -22
scripts/lib/kdoc/kdoc_parser.py
··· 1567 1567 self.entry.prototype += r.group(1) + " " 1568 1568 1569 1569 if '{' in line or ';' in line or KernRe(r'\s*#\s*define').match(line): 1570 - # strip comments 1571 - r = KernRe(r'/\*.*?\*/') 1572 - self.entry.prototype = r.sub('', self.entry.prototype) 1573 - 1574 - # strip newlines/cr's 1575 - r = KernRe(r'[\r\n]+') 1576 - self.entry.prototype = r.sub(' ', self.entry.prototype) 1577 - 1578 - # strip leading spaces 1579 - r = KernRe(r'^\s+') 1580 - self.entry.prototype = r.sub('', self.entry.prototype) 1570 + # strip comments and surrounding spaces 1571 + r = KernRe(r'/\*.*\*/') 1572 + self.entry.prototype = r.sub('', self.entry.prototype).strip() 1581 1573 1582 1574 # Handle self.entry.prototypes for function pointers like: 1583 1575 # int (*pcs_config)(struct foo) ··· 1592 1600 def process_proto_type(self, ln, line): 1593 1601 """Ancillary routine to process a type""" 1594 1602 1595 - # Strip newlines/cr's. 1596 - line = KernRe(r'[\r\n]+', re.S).sub(' ', line) 1597 - 1598 - # Strip leading spaces 1599 - line = KernRe(r'^\s+', re.S).sub('', line) 1600 - 1601 - # Strip trailing spaces 1602 - line = KernRe(r'\s+$', re.S).sub('', line) 1603 - 1604 - # Strip C99-style comments to the end of the line 1605 - line = KernRe(r"\/\/.*$", re.S).sub('', line) 1603 + # Strip C99-style comments and surrounding whitespace 1604 + line = KernRe(r"//.*$", re.S).sub('', line).strip() 1606 1605 1607 1606 # To distinguish preprocessor directive from regular declaration later. 1608 1607 if line.startswith('#'):