From 1bdf0d04c33c426221edac69cca17be544fe8ec3 Mon Sep 17 00:00:00 2001 From: Vasudev Kamath Date: Sun, 5 Jan 2014 19:12:19 +0530 Subject: [PATCH 1/2] Added documentation for new core function disassemble Signed-off-by: Vasudev Kamath --- docs/language/core.rst | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/docs/language/core.rst b/docs/language/core.rst index c9b67f2..c11672f 100644 --- a/docs/language/core.rst +++ b/docs/language/core.rst @@ -29,6 +29,27 @@ Raises ``TypeError`` if ``(not (numeric? x))``. 11.3 +.. _disassemble-fn: + +disassemble +----------- + +Usage: ``(disassemble tree &optional [codegen false])`` + +Dump the Python AST for given Hy tree to standard output. If codegen +is true function prints Python code instead. + +.. code-block:: clojure + + => (disassemble '(print "Hello World!")) + Module( + body=[ + Expr(value=Call(func=Name(id='print'), args=[Str(s='Hello World!')], keywords=[], starargs=None, kwargs=None))]) + + => (disassemble '(print "Hello World!")) + print('Hello World!') + + .. _emtpy?-fn: empty? From 5b3f6879c60f2aa0380a6485aa58a0d22381f1cc Mon Sep 17 00:00:00 2001 From: Vasudev Kamath Date: Sun, 5 Jan 2014 19:55:41 +0530 Subject: [PATCH 2/2] Added .. versionadded: 0.9.13 and quoted the arguments. Also added missing true for python code generation example. Signed-off-by: Vasudev Kamath --- docs/language/core.rst | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/language/core.rst b/docs/language/core.rst index c11672f..9585053 100644 --- a/docs/language/core.rst +++ b/docs/language/core.rst @@ -34,10 +34,12 @@ Raises ``TypeError`` if ``(not (numeric? x))``. disassemble ----------- +.. versionadded:: 0.9.13 + Usage: ``(disassemble tree &optional [codegen false])`` -Dump the Python AST for given Hy tree to standard output. If codegen -is true function prints Python code instead. +Dump the Python AST for given Hy ``tree`` to standard output. If *codegen* +is ``true`` function prints Python code instead. .. code-block:: clojure @@ -46,7 +48,7 @@ is true function prints Python code instead. body=[ Expr(value=Call(func=Name(id='print'), args=[Str(s='Hello World!')], keywords=[], starargs=None, kwargs=None))]) - => (disassemble '(print "Hello World!")) + => (disassemble '(print "Hello World!") true) print('Hello World!')