MCPcopy Create free account
hub / github.com/ipython/ipython / dedent

Function dedent

IPython/utils/text.py:359–383  ·  view source on GitHub ↗

Equivalent of textwrap.dedent that ignores unindented first line. This means it will still dedent strings like: '''foo is a bar ''' For use in wrap_paragraphs.

(text)

Source from the content-addressed store, hash-verified

357
358
359def dedent(text):
360 """Equivalent of textwrap.dedent that ignores unindented first line.
361
362 This means it will still dedent strings like:
363 '''foo
364 is a bar
365 '''
366
367 For use in wrap_paragraphs.
368 """
369
370 if text.startswith('\n'):
371 # text starts with blank line, don't ignore the first line
372 return textwrap.dedent(text)
373
374 # split first line
375 splits = text.split('\n',1)
376 if len(splits) == 1:
377 # only one line
378 return textwrap.dedent(text)
379
380 first, rest = splits
381 # dedent everything but the first line
382 rest = textwrap.dedent(rest)
383 return '\n'.join([first, rest])
384
385
386def wrap_paragraphs(text, ncols=80):

Callers 15

_fill_textMethod · 0.90
_magic_docsMethod · 0.90
format_docstringFunction · 0.90
wrap_paragraphsFunction · 0.85
_asyncifyFunction · 0.85
_function_magic_markerFunction · 0.85
getsourceFunction · 0.85
test_xmode_skipFunction · 0.85
test_mix_termsMethod · 0.85
test_multiline_timeFunction · 0.85
test_nested_genexprMethod · 0.85

Calls

no outgoing calls

Tested by 10

test_xmode_skipFunction · 0.68
test_mix_termsMethod · 0.68
test_multiline_timeFunction · 0.68
test_nested_genexprMethod · 0.68
test_should_be_asyncMethod · 0.68
_get_top_level_casesMethod · 0.68
_get_ry_syntax_errorsMethod · 0.68
test_in_func_no_errorMethod · 0.68
test_check_completeFunction · 0.68