summaryrefslogtreecommitdiff
path: root/Tools/parser/unparse.py
diff options
context:
space:
mode:
authorINADA Naoki <methane@users.noreply.github.com>2017-02-23 00:31:59 +0900
committerVictor Stinner <victor.stinner@gmail.com>2017-02-22 16:31:59 +0100
commitcb41b2766de646435743b6af7dd152751b54e73f (patch)
tree4033a04617524787defe4699c45327783fe44d8d /Tools/parser/unparse.py
parent1bc156430bad8177b5beecf57979628c1d071230 (diff)
downloadcpython-git-cb41b2766de646435743b6af7dd152751b54e73f.tar.gz
bpo-29463: Add docstring field to some AST nodes. (#46)
* bpo-29463: Add docstring field to some AST nodes. ClassDef, ModuleDef, FunctionDef, and AsyncFunctionDef has docstring field for now. It was first statement of there body. * fix document. thanks travis! * doc fixes
Diffstat (limited to 'Tools/parser/unparse.py')
-rw-r--r--Tools/parser/unparse.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/Tools/parser/unparse.py b/Tools/parser/unparse.py
index 7e1cc4ea5d..3eb63108c5 100644
--- a/Tools/parser/unparse.py
+++ b/Tools/parser/unparse.py
@@ -71,6 +71,8 @@ class Unparser:
########################################################
def _Module(self, tree):
+ if tree.docstring is not None:
+ self.fill(repr(tree.docstring))
for stmt in tree.body:
self.dispatch(stmt)
@@ -235,6 +237,8 @@ class Unparser:
self.write(")")
self.enter()
+ if t.docstring is not None:
+ self.fill(repr(t.docstring))
self.dispatch(t.body)
self.leave()
@@ -257,6 +261,8 @@ class Unparser:
self.write(" -> ")
self.dispatch(t.returns)
self.enter()
+ if t.docstring is not None:
+ self.fill(repr(t.docstring))
self.dispatch(t.body)
self.leave()