Add py__doc__ as a better approach to docstrings.

This commit is contained in:
Dave Halter
2017-04-20 09:45:12 +02:00
parent b4631d6dd4
commit 7ca62578e1
6 changed files with 56 additions and 38 deletions

View File

@@ -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):