Skip to content

Commit 6331e81

Browse files
committed
Clean up function documentation so it renders properly
1 parent e56d191 commit 6331e81

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

cmd2/ansi.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ def strip_style(text: str) -> str:
9494
def style_aware_wcswidth(text: str) -> int:
9595
"""
9696
Wrap wcswidth to make it compatible with strings that contains ANSI style sequences
97+
9798
:param text: the string being measured
9899
:return: the width of the string when printed to the terminal
99100
"""
@@ -104,6 +105,7 @@ def style_aware_wcswidth(text: str) -> int:
104105
def style_aware_write(fileobj: IO, msg: str) -> None:
105106
"""
106107
Write a string to a fileobject and strip its ANSI style sequences if required by allow_style setting
108+
107109
:param fileobj: the file object being written to
108110
:param msg: the string being written
109111
"""
@@ -116,6 +118,7 @@ def style_aware_write(fileobj: IO, msg: str) -> None:
116118
def fg_lookup(fg_name: str) -> str:
117119
"""
118120
Look up ANSI escape codes based on foreground color name.
121+
119122
:param fg_name: foreground color name to look up ANSI escape code(s) for
120123
:return: ANSI escape code(s) associated with this color
121124
:raises ValueError: if the color cannot be found
@@ -130,6 +133,7 @@ def fg_lookup(fg_name: str) -> str:
130133
def bg_lookup(bg_name: str) -> str:
131134
"""
132135
Look up ANSI escape codes based on background color name.
136+
133137
:param bg_name: background color name to look up ANSI escape code(s) for
134138
:return: ANSI escape code(s) associated with this color
135139
:raises ValueError: if the color cannot be found
@@ -194,13 +198,13 @@ def style(text: Any, *, fg: str = '', bg: str = '', bold: bool = False,
194198
# These can be altered to suit an application's needs and only need to be a
195199
# function with the following structure: func(str) -> str
196200
style_success = functools.partial(style, fg='green')
197-
"""Partial function supplying arguments to style() to generate bold green text"""
201+
"""Partial function supplying arguments to :meth:`cmd2.ansi.style()` to generate bold green text"""
198202

199203
style_warning = functools.partial(style, fg='bright_yellow')
200-
"""Partial function supplying arguments to ansi.style() to generate yellow text"""
204+
"""Partial function supplying arguments to :meth:`cmd2.ansi.style()` to generate yellow text"""
201205

202206
style_error = functools.partial(style, fg='bright_red')
203-
"""Partial function supplying arguments to ansi.style() to generate bright red text"""
207+
"""Partial function supplying arguments to :meth:`cmd2.ansi.style()` to generate bright red text"""
204208

205209

206210
def async_alert_str(*, terminal_columns: int, prompt: str, line: str, cursor_offset: int, alert_msg: str) -> str:

0 commit comments

Comments
 (0)