summaryrefslogtreecommitdiff
path: root/sphinx/domains/python.py
diff options
context:
space:
mode:
authorTakeshi KOMIYA <i.tkomiya@gmail.com>2019-04-24 00:23:55 +0900
committerGitHub <noreply@github.com>2019-04-24 00:23:55 +0900
commitb49ef12e6aed3481188da05955ee1782ebf70778 (patch)
tree3ea5daac16fb678120b6bab671a2ac4d83fe903c /sphinx/domains/python.py
parent80e50c1938ba3b17f85a8958b8baa7319c9fe66f (diff)
parent435ef05b99a73a8b1da1393219d3c660be1b9516 (diff)
downloadsphinx-git-b49ef12e6aed3481188da05955ee1782ebf70778.tar.gz
Merge pull request #6295 from tk0miya/refactor_py_domain4
autodoc: Support coroutine (refs: #4777)
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 ''