]> granicus.if.org Git - python/commitdiff
Improve handling of docstrings. I had feared this was a case of
authorTim Peters <tim.peters@gmail.com>
Sun, 16 Sep 2001 02:19:49 +0000 (02:19 +0000)
committerTim Peters <tim.peters@gmail.com>
Sun, 16 Sep 2001 02:19:49 +0000 (02:19 +0000)
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>).

Tools/idle/CallTips.py

index 7c5f41c73d55f1b72ad50f7195ddc5aeaa5ef33f..0a9eb30c3b754f1efc4f0c7258fc5d14fe0e58b0 100644 (file)
@@ -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