summaryrefslogtreecommitdiffstats
path: root/Tools/idle
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2001-09-16 02:19:49 (GMT)
committerTim Peters <tim.peters@gmail.com>2001-09-16 02:19:49 (GMT)
commita2e2dbe8cda41d5c612d41acad2fe5cfb841402e (patch)
tree1dd5068e355f6f0c2468d6dbd3e85836e64fa9e5 /Tools/idle
parent5b7759f9db347ececfa0f0cfba0639d9c8caa17c (diff)
downloadcpython-a2e2dbe8cda41d5c612d41acad2fe5cfb841402e.zip
cpython-a2e2dbe8cda41d5c612d41acad2fe5cfb841402e.tar.gz
cpython-a2e2dbe8cda41d5c612d41acad2fe5cfb841402e.tar.bz2
Improve handling of docstrings. I had feared this was a case of
introspection incompatibility, but in fact it's just that calltips always gave up on a docstring that started with a newline (but didn't realize they were giving up <wink>).
Diffstat (limited to 'Tools/idle')
-rw-r--r--Tools/idle/CallTips.py15
1 files changed, 10 insertions, 5 deletions
diff --git a/Tools/idle/CallTips.py b/Tools/idle/CallTips.py
index 7c5f41c..0a9eb30 100644
--- a/Tools/idle/CallTips.py
+++ b/Tools/idle/CallTips.py
@@ -143,11 +143,16 @@ def get_arg_text(ob):
except:
pass
# See if we can use the docstring
- if hasattr(ob, "__doc__") and ob.__doc__:
- pos = string.find(ob.__doc__, "\n")
- if pos<0 or pos>70: pos=70
- if argText: argText = argText + "\n"
- argText = argText + ob.__doc__[:pos]
+ doc = getattr(ob, "__doc__", "")
+ if doc:
+ while doc[:1] in " \t\n":
+ doc = doc[1:]
+ pos = doc.find("\n")
+ if pos < 0 or pos > 70:
+ pos = 70
+ if argText:
+ argText += "\n"
+ argText += doc[:pos]
return argText