mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
pycode: Support "async" syntax
This commit is contained in:
parent
e0abb10792
commit
a77613fcfa
@ -381,6 +381,10 @@ class VariableCommentPicker(ast.NodeVisitor):
|
|||||||
self.context.pop()
|
self.context.pop()
|
||||||
self.current_function = None
|
self.current_function = None
|
||||||
|
|
||||||
|
def visit_AsyncFunctionDef(self, node):
|
||||||
|
# type: (ast.AsyncFunctionDef) -> None
|
||||||
|
self.visit_FunctionDef(node) # type: ignore
|
||||||
|
|
||||||
|
|
||||||
class DefinitionFinder(TokenProcessor):
|
class DefinitionFinder(TokenProcessor):
|
||||||
def __init__(self, lines):
|
def __init__(self, lines):
|
||||||
|
@ -314,6 +314,21 @@ def test_decorators():
|
|||||||
'Foo.method': ('def', 13, 15)}
|
'Foo.method': ('def', 13, 15)}
|
||||||
|
|
||||||
|
|
||||||
|
def test_async_function_and_method():
|
||||||
|
source = ('async def some_function():\n'
|
||||||
|
' """docstring"""\n'
|
||||||
|
' a = 1 + 1 #: comment1\n'
|
||||||
|
'\n'
|
||||||
|
'class Foo:\n'
|
||||||
|
' async def method(self):\n'
|
||||||
|
' pass\n')
|
||||||
|
parser = Parser(source)
|
||||||
|
parser.parse()
|
||||||
|
assert parser.definitions == {'some_function': ('def', 1, 3),
|
||||||
|
'Foo': ('class', 5, 7),
|
||||||
|
'Foo.method': ('def', 6, 7)}
|
||||||
|
|
||||||
|
|
||||||
def test_formfeed_char():
|
def test_formfeed_char():
|
||||||
source = ('class Foo:\n'
|
source = ('class Foo:\n'
|
||||||
'\f\n'
|
'\f\n'
|
||||||
|
Loading…
Reference in New Issue
Block a user