Go over docstring handling

This commit is contained in:
rocky
2020-02-02 05:37:07 -05:00
parent de1e7d423c
commit 38e2b8a10b
2 changed files with 9 additions and 4 deletions

View File

@@ -884,7 +884,11 @@ class SourceWalker(GenericASTTraversal, object):
def n_docstring(self, node):
indent = self.indent
docstring = node[0].pattr
doc_node = node[0]
if doc_node.attr:
docstring = doc_node.attr
else:
docstring = node[0].pattr
quote = '"""'
if docstring.find(quote) >= 0:

View File

@@ -26,7 +26,7 @@ from uncompyle6.semantics.consts import RETURN_NONE
def is_docstring(node):
try:
return node[0].kind == "assign" and node[0][1][0].pattr == "__doc__"
return node.kind == "assign" and node[1][0].pattr == "__doc__"
except:
return False
@@ -397,7 +397,7 @@ class TreeTransform(GenericASTTraversal, object):
# Disambiguate a string (expression) which appears as a "call_stmt" at
# the beginning of a function versus a docstring. Seems pretty academic,
# but this is Python.
call_stmt = ast[0][0][0]
call_stmt = ast[0][0]
if is_not_docstring(call_stmt):
call_stmt.kind = "string_at_beginning"
call_stmt.transformed_by = "transform"
@@ -414,7 +414,8 @@ class TreeTransform(GenericASTTraversal, object):
"LOAD_STR",
has_arg=True,
offset=0,
pattr=self.ast[i][0][0][0].pattr,
attr=self.ast[i][0][0].attr,
pattr=self.ast[i][0][0].pattr,
)
],
)