summaryrefslogtreecommitdiffstats
path: root/Lib/inspect.py
diff options
context:
space:
mode:
authorGeorg Brandl <georg@python.org>2008-06-07 15:59:10 (GMT)
committerGeorg Brandl <georg@python.org>2008-06-07 15:59:10 (GMT)
commit7be19aabe20a04d8038383bc96c3dd96f27892c0 (patch)
tree535f4ab7bff1301239a2c5f3f2d7492c0ab5634b /Lib/inspect.py
parent6a5a177cba3aa36e53438901a1a52149b9010e92 (diff)
downloadcpython-7be19aabe20a04d8038383bc96c3dd96f27892c0.zip
cpython-7be19aabe20a04d8038383bc96c3dd96f27892c0.tar.gz
cpython-7be19aabe20a04d8038383bc96c3dd96f27892c0.tar.bz2
Factor out docstring dedenting from inspect.getdoc() into inspect.cleandoc()
to ease standalone use of the algorithm.
Diffstat (limited to 'Lib/inspect.py')
-rw-r--r--Lib/inspect.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/Lib/inspect.py b/Lib/inspect.py
index b492514..ad94ad1 100644
--- a/Lib/inspect.py
+++ b/Lib/inspect.py
@@ -368,6 +368,13 @@ def getdoc(object):
return None
if not isinstance(doc, types.StringTypes):
return None
+ return cleandoc(doc)
+
+def cleandoc(doc):
+ """Clean up indentation from docstrings.
+
+ Any whitespace that can be uniformly removed from the second line
+ onwards is removed."""
try:
lines = string.split(string.expandtabs(doc), '\n')
except UnicodeError: