forked from VimPlug/jedi
Add py__doc__ as a better approach to docstrings.
This commit is contained in:
@@ -94,8 +94,7 @@ class CompiledObject(Context):
|
||||
def is_class(self):
|
||||
return inspect.isclass(self.obj)
|
||||
|
||||
@property
|
||||
def doc(self):
|
||||
def py__doc__(self, include_call_signature=False):
|
||||
return inspect.getdoc(self.obj) or ''
|
||||
|
||||
@property
|
||||
@@ -129,10 +128,11 @@ class CompiledObject(Context):
|
||||
|
||||
@underscore_memoization
|
||||
def _parse_function_doc(self):
|
||||
if self.doc is None:
|
||||
doc = self.py__doc__()
|
||||
if doc is None:
|
||||
return '', ''
|
||||
|
||||
return _parse_function_doc(self.doc)
|
||||
return _parse_function_doc(doc)
|
||||
|
||||
@property
|
||||
def api_type(self):
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
from jedi._compatibility import Python3Method
|
||||
from jedi.common import unite
|
||||
from jedi.parser.python.tree import ExprStmt, CompFor
|
||||
from jedi.parser_utils import clean_scope_docstring, get_doc_with_call_signature
|
||||
|
||||
|
||||
class Context(object):
|
||||
@@ -63,6 +64,18 @@ class Context(object):
|
||||
"""
|
||||
return True
|
||||
|
||||
def py__doc__(self, include_call_signature=False):
|
||||
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 None
|
||||
|
||||
|
||||
class TreeContext(Context):
|
||||
def __init__(self, evaluator, parent_context=None):
|
||||
|
||||
@@ -32,6 +32,8 @@ py__package__() 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)
|
||||
====================================== ========================================
|
||||
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user