diff -r 07a6d4c30c4e Lib/idlelib/CallTips.py --- a/Lib/idlelib/CallTips.py Mon Dec 09 01:59:07 2013 +0100 +++ b/Lib/idlelib/CallTips.py Mon Dec 09 16:47:19 2013 +0200 @@ -116,6 +116,9 @@ # exception, especially if user classes are involved. return None +_MAXARGSPECLINES = 10 +_MAXARGSPECCOLS = 70 + # The following are used in both get_argspec and tests _first_param = re.compile('(?<=\()\w*\,?\s*') _default_callable_argspec = "No docstring, see docs." @@ -125,8 +128,9 @@ For Python-coded functions and methods, the first line is introspected. Delete 'self' parameter for classes (.__init__) and bound methods. - The last line is the first line of the doc string. For builtins, this typically - includes the arguments in addition to the return value. + The next lines are the first lines of the doc string up to the first + empty line. For builtins, this typically includes the arguments in + addition to the return value. ''' argspec = "" @@ -148,13 +152,13 @@ else: doc = getattr(ob, "__doc__", "") if doc: - doc = doc.lstrip() - pos = doc.find("\n") - if pos < 0 or pos > 70: - pos = 70 - if argspec: - argspec += "\n" - argspec += doc[:pos] + lines = [argspec] if argspec else [] + for line in doc.splitlines()[:_MAXARGSPECLINES - len(lines)]: + line = line.strip() + if not line: + break + lines.append(line[:_MAXARGSPECCOLS]) + argspec = '\n'.join(lines) if not argspec: argspec = _default_callable_argspec return argspec @@ -209,12 +213,15 @@ print(fmt % (expression, expected, argspec)) def test_builtins(): - # if first line of a possibly multiline compiled docstring changes, + # if a compiled docstring changes, # must change corresponding test string test('int', "int(x=0) -> integer") + test('int', "int(x=0) -> integer\n" + "int(x, base=10) -> integer") test('Int', Int.__doc__) test('types.MethodType', "method(function, instance)") - test('list', "list() -> new empty list") + test('list', "list() -> new empty list\n" + "list(iterable) -> new list initialized from iterable's items") test('List', List.__doc__) test('list.__new__', 'T.__new__(S, ...) -> a new object with type S, a subtype of T')