summaryrefslogtreecommitdiff
path: root/sphinx/pycode/parser.py
diff options
context:
space:
mode:
authorshimizukawa <shimizukawa@gmail.com>2018-05-25 08:17:19 +0900
committershimizukawa <shimizukawa@gmail.com>2018-05-25 08:17:19 +0900
commiteacaaed1c7602da9a73aa31caf8addf824070ef2 (patch)
treef78ed27ad7fb6bc07b0369c0f5f887dcc23a0bae /sphinx/pycode/parser.py
parent157619c4e369dace8f4caebc076080d7e66c72e0 (diff)
parent0d96401c43dda36cc5a7023c1d7fc4b20c23b166 (diff)
downloadsphinx-git-eacaaed1c7602da9a73aa31caf8addf824070ef2.tar.gz
Merge branch 1.7
Diffstat (limited to 'sphinx/pycode/parser.py')
-rw-r--r--sphinx/pycode/parser.py9
1 files changed, 5 insertions, 4 deletions
diff --git a/sphinx/pycode/parser.py b/sphinx/pycode/parser.py
index f943b7985..31d2c465a 100644
--- a/sphinx/pycode/parser.py
+++ b/sphinx/pycode/parser.py
@@ -225,12 +225,13 @@ class AfterCommentParser(TokenProcessor):
def parse(self):
# type: () -> None
"""Parse the code and obtain comment after assignment."""
- # skip lvalue (until '=' operator)
- while self.fetch_token() != [OP, '=']:
+ # skip lvalue (or whole of AnnAssign)
+ while not self.fetch_token().match([OP, '='], NEWLINE, COMMENT):
assert self.current
- # skip rvalue
- self.fetch_rvalue()
+ # skip rvalue (if exists)
+ if self.current == [OP, '=']:
+ self.fetch_rvalue()
if self.current == COMMENT:
self.comment = self.current.value