Skip to content

Commit

Permalink
Partially added docstrings. Not working
Browse files Browse the repository at this point in the history
  • Loading branch information
dmitrii-eremin committed Jan 10, 2017
1 parent 93fd913 commit ace05e1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions pythonlua/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ def __init__(self, values=None):
"locals": SymbolsStack(),
"globals": SymbolsStack(), # Not working yet
"loop_label_name": "",
"docstring": False,
}

self.ctx_stack = [values]
Expand Down
4 changes: 3 additions & 1 deletion pythonlua/nodevisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,13 @@ def visit_Starred(self, node):
self.emit(line)

def visit_Str(self, node):
"""Visit str"""
"""Visit str"""
value = node.s
if value.startswith(NodeVisitor.LUACODE):
value = value[len(NodeVisitor.LUACODE):]
self.emit(value)
elif self.context.last()["docstring"]:
self.emit('--[[ {} ]]'.format(node.s))
else:
self.emit('"{}"'.format(node.s))

Expand Down
5 changes: 5 additions & 0 deletions tests/comments.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
"""Documentation comments test"""

name = "John Parrish"

print(name)
1 change: 1 addition & 0 deletions tests/comments.py.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
John Parrish

0 comments on commit ace05e1

Please sign in to comment.