diff options
author | Terry Jan Reedy <tjreedy@udel.edu> | 2014-01-26 19:55:34 -0500 |
---|---|---|
committer | Terry Jan Reedy <tjreedy@udel.edu> | 2014-01-26 19:55:34 -0500 |
commit | a0f1e220684506f703f859350024a1365fa5cf7b (patch) | |
tree | b336db4b46e6c70ac86a6ad302a334bb54b38cce /Lib/idlelib/CallTips.py | |
parent | 94338de49b6eb67efbaae6112787f2596a16d9d6 (diff) | |
download | cpython-git-a0f1e220684506f703f859350024a1365fa5cf7b.tar.gz |
Issue #20338: Increase allowed tip width slightly and wrap long signagure lines.
Original patch by Serhiy Storchaka.
Diffstat (limited to 'Lib/idlelib/CallTips.py')
-rw-r--r-- | Lib/idlelib/CallTips.py | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/Lib/idlelib/CallTips.py b/Lib/idlelib/CallTips.py index 4f88da6f5d..81bd5f1890 100644 --- a/Lib/idlelib/CallTips.py +++ b/Lib/idlelib/CallTips.py @@ -5,16 +5,16 @@ parameter and docstring information when you type an opening parenthesis, and which disappear when you type a closing parenthesis. """ +import __main__ +import inspect import re import sys +import textwrap import types -import inspect from idlelib import CallTipWindow from idlelib.HyperParser import HyperParser -import __main__ - class CallTips: menudefs = [ @@ -117,8 +117,9 @@ def get_entity(expression): return None # The following are used in get_argspec and some in tests -_MAX_COLS = 79 +_MAX_COLS = 85 _MAX_LINES = 5 # enough for bytes +_INDENT = ' '*4 # for wrapped signatures _first_param = re.compile('(?<=\()\w*\,?\s*') _default_callable_argspec = "See source or doc" @@ -149,13 +150,15 @@ def get_argspec(ob): isinstance(ob_call, types.MethodType)): argspec = _first_param.sub("", argspec) + lines = (textwrap.wrap(argspec, _MAX_COLS, subsequent_indent=_INDENT) + if len(argspec) > _MAX_COLS else [argspec] if argspec else []) + if isinstance(ob_call, types.MethodType): doc = ob_call.__doc__ else: doc = getattr(ob, "__doc__", "") if doc: - lines = [argspec] if argspec else [] - for line in doc.split('\n', 5)[:_MAX_LINES]: + for line in doc.split('\n', _MAX_LINES)[:_MAX_LINES]: line = line.strip() if not line: break |