1
0
forked from VimPlug/jedi

Better signature support for docstrings

This commit is contained in:
Dave Halter
2019-05-05 19:09:21 +02:00
parent f996df087e
commit 2cb1bd162f
9 changed files with 42 additions and 34 deletions

View File

@@ -12,7 +12,7 @@ from parso.python.tree import ExprStmt, CompFor
from jedi import debug
from jedi._compatibility import Python3Method, zip_longest, unicode
from jedi.parser_utils import clean_scope_docstring, get_doc_with_call_signature
from jedi.parser_utils import clean_scope_docstring
from jedi.common import BaseContextSet, BaseContext
from jedi.evaluate.helpers import SimpleGetItemNotFound, execute_evaluated
from jedi.evaluate.utils import safe_property
@@ -168,16 +168,13 @@ class Context(HelperContextMixin, BaseContext):
"""
return True
def py__doc__(self, include_call_signature=False):
def py__doc__(self):
try:
self.tree_node.get_doc_node
except AttributeError:
return ''
else:
if include_call_signature:
return get_doc_with_call_signature(self.tree_node)
else:
return clean_scope_docstring(self.tree_node)
return clean_scope_docstring(self.tree_node)
return None
def py__stop_iteration_returns(self):

View File

@@ -197,7 +197,7 @@ class DirectObjectAccess(object):
except AttributeError:
return None
def py__doc__(self, include_call_signature=False):
def py__doc__(self):
return force_unicode(inspect.getdoc(self._obj)) or u''
def py__name__(self):

View File

@@ -108,7 +108,7 @@ class CompiledObject(Context):
def is_stub(self):
return False
def py__doc__(self, include_call_signature=False):
def py__doc__(self):
return self.access_handle.py__doc__()
def get_param_names(self):

View File

@@ -32,8 +32,7 @@ py__package__() -> List[str] Only on modules. For the import system.
py__path__() Only on modules. For the import system.
py__get__(call_object) Only on instances. Simulates
descriptors.
py__doc__(include_call_signature: Returns the docstring for a context.
bool)
py__doc__() Returns the docstring for a context.
====================================== ========================================
"""

View File

@@ -53,5 +53,8 @@ class ImplicitNamespaceContext(Context, SubModuleDictMixin):
def py__name__(self):
return self._fullname
def is_stub(self):
return False
def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self._fullname)

View File

@@ -1,4 +1,5 @@
from abc import abstractproperty
from jedi.parser_utils import get_call_signature
class AbstractSignature(object):
@@ -38,7 +39,7 @@ class TreeSignature(AbstractSignature):
return self._function_context.tree_node.annotation
def to_string(self, normalize=False):
return self._function_context.tree_node
return get_call_signature(self._function_context.tree_node)
class BuiltinSignature(AbstractSignature):