summaryrefslogtreecommitdiffstats
path: root/Doc/library/ast.rst
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2019-09-09 16:33:13 (GMT)
committerGitHub <noreply@github.com>2019-09-09 16:33:13 (GMT)
commit850573b836d5b82d1a1ebe75a635aaa0a3dff997 (patch)
treeeb7aa5da66e0dfa0520104fac656ae93f3a12a34 /Doc/library/ast.rst
parent92709a263e9cec0bc646ccc1ea051fc528800d8d (diff)
downloadcpython-850573b836d5b82d1a1ebe75a635aaa0a3dff997.zip
cpython-850573b836d5b82d1a1ebe75a635aaa0a3dff997.tar.gz
cpython-850573b836d5b82d1a1ebe75a635aaa0a3dff997.tar.bz2
bpo-37995: Add an option to ast.dump() to produce a multiline output. (GH-15631)
Diffstat (limited to 'Doc/library/ast.rst')
-rw-r--r--Doc/library/ast.rst13
1 files changed, 12 insertions, 1 deletions
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst
index 92bf891..cb8e7ec 100644
--- a/Doc/library/ast.rst
+++ b/Doc/library/ast.rst
@@ -319,7 +319,7 @@ and classes for traversing abstract syntax trees:
node = YourTransformer().visit(node)
-.. function:: dump(node, annotate_fields=True, include_attributes=False)
+.. function:: dump(node, annotate_fields=True, include_attributes=False, *, indent=None)
Return a formatted dump of the tree in *node*. This is mainly useful for
debugging purposes. If *annotate_fields* is true (by default),
@@ -329,6 +329,17 @@ and classes for traversing abstract syntax trees:
numbers and column offsets are not dumped by default. If this is wanted,
*include_attributes* can be set to true.
+ If *indent* is a non-negative integer or string, then the tree will be
+ pretty-printed with that indent level. An indent level
+ of 0, negative, or ``""`` will only insert newlines. ``None`` (the default)
+ selects the single line representation. Using a positive integer indent
+ indents that many spaces per level. If *indent* is a string (such as ``"\t"``),
+ that string is used to indent each level.
+
+ .. versionchanged:: 3.9
+ Added the *indent* option.
+
+
.. seealso::
`Green Tree Snakes <https://greentreesnakes.readthedocs.io/>`_, an external documentation resource, has good