summaryrefslogtreecommitdiff
path: root/string_utils.py
diff options
context:
space:
mode:
authorScott Gasch <[email protected]>2022-05-28 19:29:08 -0700
committerScott Gasch <[email protected]>2022-05-28 19:29:08 -0700
commit1e858172519e9339e4720b8bf9b39b6d9801e305 (patch)
tree75306d5a4eb3a9b512646f0acc5c6174644348a6 /string_utils.py
parent52ff365609d3f5a81cb79dc4464b19bd5860cfc0 (diff)
Tweak around docstring to make prettier sphinx autodocs.
Diffstat (limited to 'string_utils.py')
-rw-r--r--string_utils.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/string_utils.py b/string_utils.py
index a2f4633..dbd50f2 100644
--- a/string_utils.py
+++ b/string_utils.py
@@ -1246,13 +1246,18 @@ def strip_ansi_sequences(in_str: str) -> str:
class SprintfStdout(contextlib.AbstractContextManager):
"""
- A context manager that captures outputs to stdout.
+ A context manager that captures outputs to stdout to a buffer
+ without printing them. e.g.::
- with SprintfStdout() as buf:
- print("test")
- print(buf())
+ with SprintfStdout() as buf:
+ print("test")
+ print("1, 2, 3")
+ print(buf())
+
+ This yields::
+
+ 'test\\n1, 2, 3\\n'
- 'test\n'
"""
def __init__(self) -> None: