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: 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>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
b2d231f4 14b7775e

+7 -2
+7 -2
tools/lib/python/kdoc/kdoc_re.py
··· 70 70 71 71 flags_name = " | ".join(flags) 72 72 73 + max_len = 60 74 + pattern = "" 75 + for pos in range(0, len(self.regex.pattern), max_len): 76 + pattern += '"' + self.regex.pattern[pos:max_len + pos] + '" ' 77 + 73 78 if flags_name: 74 - return f'KernRe("{self.regex.pattern}", {flags_name})' 79 + return f'KernRe({pattern}, {flags_name})' 75 80 else: 76 - return f'KernRe("{self.regex.pattern}")' 81 + return f'KernRe({pattern})' 77 82 78 83 def __add__(self, other): 79 84 """