mirror of
https://github.com/davidhalter/jedi.git
synced 2026-05-19 23:09:43 +08:00
Merge pull request #53 from tkf/call-signature-in-completion
Call signature in Completion.doc
This commit is contained in:
+7
-2
@@ -72,9 +72,14 @@ class Completion(object):
|
|||||||
|
|
||||||
@property
|
@property
|
||||||
def doc(self):
|
def doc(self):
|
||||||
""" Returns the docstring `__doc__` for any object """
|
""" Return a document string for this completion object. """
|
||||||
try:
|
try:
|
||||||
return str(self.name.parent().docstr)
|
parent = self.name.parent()
|
||||||
|
try:
|
||||||
|
return '%s\n\n%s' % (parent.get_call_signature(),
|
||||||
|
parent.docstr)
|
||||||
|
except AttributeError:
|
||||||
|
return str(parent.docstr)
|
||||||
except AttributeError:
|
except AttributeError:
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
|
|||||||
@@ -385,6 +385,31 @@ class Function(Scope):
|
|||||||
debug.warning("multiple names in param %s" % n)
|
debug.warning("multiple names in param %s" % n)
|
||||||
return n
|
return n
|
||||||
|
|
||||||
|
def get_call_signature(self, width=72):
|
||||||
|
"""
|
||||||
|
Generate call signature of this function.
|
||||||
|
|
||||||
|
:param width: Fold lines if a line is longer than this value.
|
||||||
|
:type width: int
|
||||||
|
|
||||||
|
:rtype: str
|
||||||
|
"""
|
||||||
|
l = self.name.names[-1] + '('
|
||||||
|
lines = []
|
||||||
|
for (i, p) in enumerate(self.params):
|
||||||
|
code = p.get_code(False)
|
||||||
|
if i != len(self.params) - 1:
|
||||||
|
code += ', '
|
||||||
|
if len(l + code) > width:
|
||||||
|
lines.append(l[:-1] if l[-1] == ' ' else l)
|
||||||
|
l = code
|
||||||
|
else:
|
||||||
|
l += code
|
||||||
|
if l:
|
||||||
|
lines.append(l)
|
||||||
|
lines[-1] += ')'
|
||||||
|
return '\n'.join(lines)
|
||||||
|
|
||||||
|
|
||||||
class Flow(Scope):
|
class Flow(Scope):
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user