summaryrefslogtreecommitdiff
path: root/sphinx/domains/python.py
diff options
context:
space:
mode:
Diffstat (limited to 'sphinx/domains/python.py')
-rw-r--r--sphinx/domains/python.py25
1 files changed, 22 insertions, 3 deletions
diff --git a/sphinx/domains/python.py b/sphinx/domains/python.py
index e268023a5..c1ef3f990 100644
--- a/sphinx/domains/python.py
+++ b/sphinx/domains/python.py
@@ -438,6 +438,18 @@ class PyModulelevel(PyObject):
class PyFunction(PyObject):
"""Description of a function."""
+ option_spec = PyObject.option_spec.copy()
+ option_spec.update({
+ 'async': directives.flag,
+ })
+
+ def get_signature_prefix(self, sig):
+ # type: (str) -> str
+ if 'async' in self.options:
+ return 'async '
+ else:
+ return ''
+
def needs_arglist(self):
# type: () -> bool
return True
@@ -573,6 +585,7 @@ class PyMethod(PyObject):
option_spec = PyObject.option_spec.copy()
option_spec.update({
+ 'async': directives.flag,
'classmethod': directives.flag,
'staticmethod': directives.flag,
})
@@ -583,10 +596,16 @@ class PyMethod(PyObject):
def get_signature_prefix(self, sig):
# type: (str) -> str
+ prefix = []
+ if 'async' in self.options:
+ prefix.append('async')
if 'staticmethod' in self.options:
- return 'static '
- elif 'classmethod' in self.options:
- return 'classmethod '
+ prefix.append('static')
+ if 'classmethod' in self.options:
+ prefix.append('classmethod')
+
+ if prefix:
+ return ' '.join(prefix) + ' '
else:
return ''