mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-09 07:14:48 +08:00
Fix ExprStmt docstring bugs.
This commit is contained in:
@@ -65,10 +65,17 @@ class DocstringMixin(object):
|
|||||||
""" Returns a cleaned version of the docstring token. """
|
""" Returns a cleaned version of the docstring token. """
|
||||||
if isinstance(self, Module):
|
if isinstance(self, Module):
|
||||||
stmt = self.children[0]
|
stmt = self.children[0]
|
||||||
else:
|
elif isinstance(self, ClassOrFunc):
|
||||||
stmt = self.children[self.children.index(':') + 1]
|
stmt = self.children[self.children.index(':') + 1]
|
||||||
if is_node(stmt, 'suite'): # Normally a suite
|
if is_node(stmt, 'suite'): # Normally a suite
|
||||||
stmt = stmt.children[2] # -> NEWLINE INDENT stmt
|
stmt = stmt.children[2] # -> NEWLINE INDENT stmt
|
||||||
|
else:
|
||||||
|
c = self.parent.children
|
||||||
|
index = c.index(self) - 1
|
||||||
|
if not index:
|
||||||
|
return ''
|
||||||
|
stmt = c[index - 1]
|
||||||
|
|
||||||
if is_node(stmt, 'simple_stmt'):
|
if is_node(stmt, 'simple_stmt'):
|
||||||
stmt = stmt.children[0]
|
stmt = stmt.children[0]
|
||||||
|
|
||||||
|
|||||||
@@ -119,11 +119,16 @@ def test_completion_docstring():
|
|||||||
"""
|
"""
|
||||||
Jedi should follow imports in certain conditions
|
Jedi should follow imports in certain conditions
|
||||||
"""
|
"""
|
||||||
|
def docstr(src, result):
|
||||||
|
c = Script(src).completions()[0]
|
||||||
|
assert c.docstring(raw=True, fast=False) == cleandoc(result)
|
||||||
|
|
||||||
c = Script('import jedi\njed').completions()[0]
|
c = Script('import jedi\njed').completions()[0]
|
||||||
assert c.docstring(fast=False) == cleandoc(jedi_doc)
|
assert c.docstring(fast=False) == cleandoc(jedi_doc)
|
||||||
|
|
||||||
c = Script('import jedi\njedi.Scr').completions()[0]
|
docstr('import jedi\njedi.Scr', cleandoc(Script.__doc__))
|
||||||
assert c.docstring(raw=True, fast=False) == cleandoc(Script.__doc__)
|
|
||||||
|
docstr('abcd=3;abcd', '')
|
||||||
|
|
||||||
|
|
||||||
def test_completion_params():
|
def test_completion_params():
|
||||||
|
|||||||
Reference in New Issue
Block a user