1
0
forked from VimPlug/jedi

Merge pull request #141 from tkf/attribute-docstring

Attribute docstring support
This commit is contained in:
David Halter
2013-03-10 13:23:47 -07:00
4 changed files with 55 additions and 1 deletions

View File

@@ -733,7 +733,8 @@ class Statement(Simple):
:param start_pos: Position (line, column) of the Statement.
"""
__slots__ = ('token_list', 'used_vars',
'set_vars', '_commands', '_assignment_details')
'set_vars', '_commands', '_assignment_details',
'docstr')
def __init__(self, module, set_vars, used_vars, token_list,
start_pos, end_pos, parent=None):
@@ -744,12 +745,17 @@ class Statement(Simple):
s.parent = self.use_as_parent
self.set_vars = self._remove_executions_from_set_vars(set_vars)
self.parent = parent
self.docstr = ''
# cache
self._commands = None
self._assignment_details = []
# this is important for other scripts
def add_docstr(self, string):
""" Clean up a docstring """
self.docstr = cleandoc(literal_eval(string))
def _remove_executions_from_set_vars(self, set_vars):
"""
Important mainly for assosiative arrays::
@@ -1339,6 +1345,11 @@ class Name(Simple):
""" Returns the names in a full string format """
return ".".join(self.names)
@property
def docstr(self):
"""Return attribute docstring (PEP 257) if exists."""
return self.parent.docstr
def __str__(self):
return self.get_code()