diff options
Diffstat (limited to 'Doc')
-rw-r--r-- | Doc/library/ast.rst | 14 | ||||
-rw-r--r-- | Doc/whatsnew/3.7.rst | 6 |
2 files changed, 17 insertions, 3 deletions
diff --git a/Doc/library/ast.rst b/Doc/library/ast.rst index 8d4ae2c..bda46f4 100644 --- a/Doc/library/ast.rst +++ b/Doc/library/ast.rst @@ -133,9 +133,17 @@ and classes for traversing abstract syntax trees: .. function:: get_docstring(node, clean=True) Return the docstring of the given *node* (which must be a - :class:`FunctionDef`, :class:`ClassDef` or :class:`Module` node), or ``None`` - if it has no docstring. If *clean* is true, clean up the docstring's - indentation with :func:`inspect.cleandoc`. + :class:`FunctionDef`, :class:`AsyncFunctionDef`, :class:`ClassDef`, + or :class:`Module` node), or ``None`` if it has no docstring. + If *clean* is true, clean up the docstring's indentation with + :func:`inspect.cleandoc`. + + .. versionchanged:: 3.5 + :class:`AsyncFunctionDef` is now supported. + + .. versionchanged:: 3.7 + The docstring is now exported from the node docstring field, instead of + the first body statement. .. function:: fix_missing_locations(node) diff --git a/Doc/whatsnew/3.7.rst b/Doc/whatsnew/3.7.rst index f6367fd..861c537 100644 --- a/Doc/whatsnew/3.7.rst +++ b/Doc/whatsnew/3.7.rst @@ -196,6 +196,12 @@ Changes in the Python API Use the :meth:`~http.cookies.Morsel.set` method for setting them. (Contributed by Serhiy Storchaka in :issue:`29192`.) +* ``Module``, ``FunctionDef``, ``AsyncFunctionDef``, and + ``ClassDef`` AST nodes now have a new ``docstring`` field. + The first statement in their body is not considered as a docstring + anymore. ``co_firstlineno`` and ``co_lnotab`` of code object for class + and module are affected by this change. + (Contributed by INADA Naoki and Eugene Toder in :issue:`29463`.) CPython bytecode changes ------------------------ |