forked from VimPlug/jedi
simplified and united docstring version
This commit is contained in:
@@ -389,12 +389,25 @@ class Parser(object):
|
|||||||
|
|
||||||
if not tok_list:
|
if not tok_list:
|
||||||
return None, tok
|
return None, tok
|
||||||
# print 'new_stat', set_vars, used_vars
|
|
||||||
if self.freshscope and not self.no_docstr and len(tok_list) == 1 \
|
first_tok = tok_list[0]
|
||||||
and self.last_token[0] == tokenize.STRING:
|
# docstrings
|
||||||
self._scope.add_docstr(self.last_token[1])
|
if len(tok_list) == 1 and not isinstance(first_tok, pr.Name) \
|
||||||
|
and first_tok[0] == tokenize.STRING:
|
||||||
|
# Normal docstring check
|
||||||
|
if self.freshscope and not self.no_docstr:
|
||||||
|
self._scope.add_docstr(first_tok[1])
|
||||||
return None, tok
|
return None, tok
|
||||||
|
|
||||||
|
# Attribute docstring (PEP 224) support (sphinx uses it, e.g.)
|
||||||
|
# If string literal is being parsed...
|
||||||
|
elif first_tok[0] == tokenize.STRING:
|
||||||
|
with common.ignored(IndexError, AttributeError):
|
||||||
|
# ...then set it as a docstring
|
||||||
|
self._scope.statements[-1].add_docstr(first_tok[1])
|
||||||
|
return None, tok
|
||||||
|
|
||||||
|
|
||||||
stmt = stmt_class(self.module, set_vars, used_vars, tok_list,
|
stmt = stmt_class(self.module, set_vars, used_vars, tok_list,
|
||||||
first_pos, self.end_pos, as_names=as_names)
|
first_pos, self.end_pos, as_names=as_names)
|
||||||
|
|
||||||
@@ -404,17 +417,6 @@ class Parser(object):
|
|||||||
# TODO somehow this is important here. But it slows down Jedi, remove!
|
# TODO somehow this is important here. But it slows down Jedi, remove!
|
||||||
stmt.get_set_vars()
|
stmt.get_set_vars()
|
||||||
|
|
||||||
first_tok = stmt.token_list[0]
|
|
||||||
# Attribute docstring (PEP 224) support (sphinx uses it, e.g.)
|
|
||||||
# If string literal is being parsed...
|
|
||||||
if len(stmt.token_list) == 1 \
|
|
||||||
and not isinstance(first_tok, pr.Name) \
|
|
||||||
and first_tok[0] == tokenize.STRING:
|
|
||||||
with common.ignored(IndexError, AttributeError):
|
|
||||||
# ... then set it as a docstring
|
|
||||||
self._scope.statements[-1].add_docstr(first_tok[1])
|
|
||||||
return None, tok
|
|
||||||
|
|
||||||
if tok in always_break + not_first_break:
|
if tok in always_break + not_first_break:
|
||||||
self._gen.push_last_back()
|
self._gen.push_last_back()
|
||||||
return stmt, tok
|
return stmt, tok
|
||||||
|
|||||||
Reference in New Issue
Block a user