mirror of
https://github.com/python/cpython.git
synced 2025-10-23 15:12:02 +00:00
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>).
This commit is contained in:
parent
5b7759f9db
commit
a2e2dbe8cd
1 changed files with 10 additions and 5 deletions
|
@ -143,11 +143,16 @@ def get_arg_text(ob):
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
# See if we can use the docstring
|
# See if we can use the docstring
|
||||||
if hasattr(ob, "__doc__") and ob.__doc__:
|
doc = getattr(ob, "__doc__", "")
|
||||||
pos = string.find(ob.__doc__, "\n")
|
if doc:
|
||||||
if pos<0 or pos>70: pos=70
|
while doc[:1] in " \t\n":
|
||||||
if argText: argText = argText + "\n"
|
doc = doc[1:]
|
||||||
argText = argText + ob.__doc__[:pos]
|
pos = doc.find("\n")
|
||||||
|
if pos < 0 or pos > 70:
|
||||||
|
pos = 70
|
||||||
|
if argText:
|
||||||
|
argText += "\n"
|
||||||
|
argText += doc[:pos]
|
||||||
|
|
||||||
return argText
|
return argText
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue