summaryrefslogtreecommitdiff
path: root/sphinx/pycode/parser.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-06-08 16:09:45 +0900
committerTakeshi KOMIYA <i.tkomiya@gmail.com>2019-06-08 19:06:52 +0900
commit0aed08b5be0244aef3d8bab7e50376fee1450480 (patch)
tree634d5daf45edac7fa325fa5e5bc5c80f81cc3a2a /sphinx/pycode/parser.py
parentf0b1cbb734b2ad699d8bdcb41a53b221923aab61 (diff)
downloadsphinx-git-0aed08b5be0244aef3d8bab7e50376fee1450480.tar.gz
Fix #6451: autodoc: generates docs for "optional import"ed modules as variables
Diffstat (limited to 'sphinx/pycode/parser.py')
-rw-r--r--sphinx/pycode/parser.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py
index f9489e91a..1746537bb 100644
--- a/sphinx/pycode/parser.py
+++ b/sphinx/pycode/parser.py
@@ -357,6 +357,17 @@ class VariableCommentPicker(ast.NodeVisitor):
except TypeError:
pass # this assignment is not new definition!
+ def visit_Try(self, node):
+ # type: (ast.Try) -> None
+ """Handles Try node and processes body and else-clause.
+
+ .. note:: pycode parser ignores objects definition in except-clause.
+ """
+ for subnode in node.body:
+ self.visit(subnode)
+ for subnode in node.orelse:
+ self.visit(subnode)
+
def visit_ClassDef(self, node):
# type: (ast.ClassDef) -> None
"""Handles ClassDef node and set context."""