MCPcopy Index your code
hub / github.com/mne-tools/mne-python / _reflow_param_docstring

Function _reflow_param_docstring

mne/utils/docs.py:37–49  ·  view source on GitHub ↗

Reflow text to a nice width for terminals. WARNING: does not handle gracefully things like .. versionadded::

(docstring, has_first_line=True, width=75)

Source from the content-addressed store, hash-verified

35
36
37def _reflow_param_docstring(docstring, has_first_line=True, width=75):
38 """Reflow text to a nice width for terminals.
39
40 WARNING: does not handle gracefully things like .. versionadded::
41 """
42 maxsplit = docstring.count("\n") - 1 if has_first_line else -1
43 merged = " ".join(
44 line.strip() for line in docstring.rsplit("\n", maxsplit=maxsplit)
45 )
46 reflowed = "\n ".join(re.findall(rf".{{1,{width}}}(?:\s+|$)", merged))
47 if has_first_line:
48 reflowed = reflowed.replace("\n \n", "\n", 1)
49 return reflowed
50
51
52##############################################################################

Callers 1

docs.pyFile · 0.85

Calls 1

countMethod · 0.80

Tested by

no test coverage detected