mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #4157 from tk0miya/4156_parse_class_comment
Fix #4156: failed to parse class comment
This commit is contained in:
commit
f224f3ca25
@ -343,6 +343,7 @@ class VariableCommentPicker(ast.NodeVisitor):
|
|||||||
self.current_classes.append(node.name)
|
self.current_classes.append(node.name)
|
||||||
self.add_entry(node.name)
|
self.add_entry(node.name)
|
||||||
self.context.append(node.name)
|
self.context.append(node.name)
|
||||||
|
self.previous = node
|
||||||
for child in node.body:
|
for child in node.body:
|
||||||
self.visit(child)
|
self.visit(child)
|
||||||
self.context.pop()
|
self.context.pop()
|
||||||
|
@ -246,6 +246,18 @@ def test_nested_class():
|
|||||||
'Foo.Bar.attr2': 3}
|
'Foo.Bar.attr2': 3}
|
||||||
|
|
||||||
|
|
||||||
|
def test_class_comment():
|
||||||
|
source = ('import logging\n'
|
||||||
|
'logger = logging.getLogger(__name__)\n'
|
||||||
|
'\n'
|
||||||
|
'class Foo(object):\n'
|
||||||
|
' """Bar"""\n')
|
||||||
|
parser = Parser(source)
|
||||||
|
parser.parse()
|
||||||
|
assert parser.comments == {}
|
||||||
|
assert parser.definitions == {'Foo': ('class', 4, 5)}
|
||||||
|
|
||||||
|
|
||||||
def test_comment_picker_multiline_string():
|
def test_comment_picker_multiline_string():
|
||||||
source = ('class Foo(object):\n'
|
source = ('class Foo(object):\n'
|
||||||
' a = None\n'
|
' a = None\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user