Skip to content

Commit 7ef684c

Browse files
mchehabJonathan Corbet
authored andcommitted
docs: kdoc: enrich_formatter: 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: <55ec8b896fe00529d326859cd094230fb5a2cd30.1768838938.git.mchehab+huawei@kernel.org>
1 parent e68c84b commit 7ef684c

1 file changed

Lines changed: 15 additions & 5 deletions

File tree

tools/lib/python/kdoc/enrich_formatter.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,25 +26,33 @@ class EnrichFormatter(argparse.HelpFormatter):
2626
and how they're used at the __doc__ description.
2727
"""
2828
def __init__(self, *args, **kwargs):
29-
"""Initialize class and check if is TTY"""
29+
"""
30+
Initialize class and check if is TTY.
31+
"""
3032
super().__init__(*args, **kwargs)
3133
self._tty = sys.stdout.isatty()
3234

3335
def enrich_text(self, text):
34-
"""Handle ReST markups (currently, only ``foo``)"""
36+
r"""
37+
Handle ReST markups (currently, only \`\`text\`\` markups).
38+
"""
3539
if self._tty and text:
3640
# Replace ``text`` with ANSI SGR (bold)
3741
return re.sub(r'\`\`(.+?)\`\`',
3842
lambda m: f'\033[1m{m.group(1)}\033[0m', text)
3943
return text
4044

4145
def _fill_text(self, text, width, indent):
42-
"""Enrich descriptions with markups on it"""
46+
"""
47+
Enrich descriptions with markups on it.
48+
"""
4349
enriched = self.enrich_text(text)
4450
return "\n".join(indent + line for line in enriched.splitlines())
4551

4652
def _format_usage(self, usage, actions, groups, prefix):
47-
"""Enrich positional arguments at usage: line"""
53+
"""
54+
Enrich positional arguments at usage: line.
55+
"""
4856

4957
prog = self._prog
5058
parts = []
@@ -63,7 +71,9 @@ def _format_usage(self, usage, actions, groups, prefix):
6371
return usage_text
6472

6573
def _format_action_invocation(self, action):
66-
"""Enrich argument names"""
74+
"""
75+
Enrich argument names.
76+
"""
6777
if not action.option_strings:
6878
return self.enrich_text(f"``{action.dest.upper()}``")
6979

0 commit comments

Comments
 (0)