mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-14 17:47:05 +08:00
statements should care for its own docstrings, not the parser
This commit is contained in:
@@ -413,6 +413,7 @@ class Parser(object):
|
|||||||
with common.ignored(IndexError, AttributeError):
|
with common.ignored(IndexError, AttributeError):
|
||||||
# ... then set it as a docstring
|
# ... then set it as a docstring
|
||||||
self._scope.statements[-1].add_docstr(first_tok[1])
|
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()
|
||||||
|
|||||||
@@ -800,6 +800,8 @@ class Statement(Simple):
|
|||||||
|
|
||||||
code = ''.join(assemble(*a) for a in self.assignment_details)
|
code = ''.join(assemble(*a) for a in self.assignment_details)
|
||||||
code += assemble(self.get_commands())
|
code += assemble(self.get_commands())
|
||||||
|
if self.docstr:
|
||||||
|
code += '\n"""%s"""' % self.docstr
|
||||||
|
|
||||||
if new_line:
|
if new_line:
|
||||||
return code + '\n'
|
return code + '\n'
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ def test_get_code():
|
|||||||
class SomeClass(object, mixin):
|
class SomeClass(object, mixin):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.xy = 3.0
|
self.xy = 3.0
|
||||||
'statement docstr'
|
"""statement docstr"""
|
||||||
def some_method(self):
|
def some_method(self):
|
||||||
return 1
|
return 1
|
||||||
def yield_method(self):
|
def yield_method(self):
|
||||||
|
|||||||
Reference in New Issue
Block a user