summaryrefslogtreecommitdiff
path: root/tools/lib/python/kdoc
diff options
context:
space:
mode:
authorMauro Carvalho Chehab <mchehab+huawei@kernel.org>2026-03-18 10:11:02 +0100
committerJonathan Corbet <corbet@lwn.net>2026-03-22 15:10:40 -0600
commitb2d231f4a77800661b3fb812d997841a548c6526 (patch)
tree782586ce1f2df7cfcd0a8798484f51c2422a1a00 /tools/lib/python/kdoc
parent14b7775ef7471fbb9380048aabb3e96faa1e9123 (diff)
downloadlwn-b2d231f4a77800661b3fb812d997841a548c6526.tar.gz
lwn-b2d231f4a77800661b3fb812d997841a548c6526.zip
docs: kdoc_re: better represent long regular expressions
The Sphinx output from autodoc doesn't automatically break long lines, except on spaces. Change KernRe __repr__() to break the pattern on multiple strings, each one with a maximum limit of 60 characters. With that, documentation output for KernRe should now be displayable, even on long strings. Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org> Signed-off-by: Jonathan Corbet <corbet@lwn.net> Message-ID: <60c264a9d277fed655b1a62df2195562c8596090.1773823995.git.mchehab+huawei@kernel.org>
Diffstat (limited to 'tools/lib/python/kdoc')
-rw-r--r--tools/lib/python/kdoc/kdoc_re.py9
1 files changed, 7 insertions, 2 deletions
diff --git a/tools/lib/python/kdoc/kdoc_re.py b/tools/lib/python/kdoc/kdoc_re.py
index 6f3ae28859ea..28292efe25a2 100644
--- a/tools/lib/python/kdoc/kdoc_re.py
+++ b/tools/lib/python/kdoc/kdoc_re.py
@@ -70,10 +70,15 @@ class KernRe:
flags_name = " | ".join(flags)
+ max_len = 60
+ pattern = ""
+ for pos in range(0, len(self.regex.pattern), max_len):
+ pattern += '"' + self.regex.pattern[pos:max_len + pos] + '" '
+
if flags_name:
- return f'KernRe("{self.regex.pattern}", {flags_name})'
+ return f'KernRe({pattern}, {flags_name})'
else:
- return f'KernRe("{self.regex.pattern}")'
+ return f'KernRe({pattern})'
def __add__(self, other):
"""