diff options
author | Victor Stinner <victor.stinner@gmail.com> | 2015-02-12 21:49:18 (GMT) |
---|---|---|
committer | Victor Stinner <victor.stinner@gmail.com> | 2015-02-12 21:49:18 (GMT) |
commit | bdd574d09a834f4b9935d91fe9d16a0d4a56d846 (patch) | |
tree | fc8a317993cf8681d13318e8ea7443cd46abbba1 /Doc/tools/extensions | |
parent | 3d6c784371bccc2407048652bce50c5bccf9b1af (diff) | |
download | cpython-bdd574d09a834f4b9935d91fe9d16a0d4a56d846.zip cpython-bdd574d09a834f4b9935d91fe9d16a0d4a56d846.tar.gz cpython-bdd574d09a834f4b9935d91fe9d16a0d4a56d846.tar.bz2 |
asyncio doc: annotate coroutine on coroutine functions and methods
Diffstat (limited to 'Doc/tools/extensions')
-rw-r--r-- | Doc/tools/extensions/pyspecific.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/Doc/tools/extensions/pyspecific.py b/Doc/tools/extensions/pyspecific.py index 7baacc4..17b3c82 100644 --- a/Doc/tools/extensions/pyspecific.py +++ b/Doc/tools/extensions/pyspecific.py @@ -145,6 +145,30 @@ class PyDecoratorMethod(PyDecoratorMixin, PyClassmember): return PyClassmember.run(self) +class PyCoroutineMixin(object): + def handle_signature(self, sig, signode): + ret = super(PyCoroutineMixin, self).handle_signature(sig, signode) +# signode.insert(0, addnodes.desc_addname('coroutine ', 'coroutine ')) + signode.insert(0, addnodes.desc_annotation('coroutine ', 'coroutine ')) + return ret + + def needs_arglist(self): + return False + + +class PyCoroutineFunction(PyCoroutineMixin, PyModulelevel): + def run(self): + # a decorator function is a function after all + self.name = 'py:function' + return PyModulelevel.run(self) + + +class PyCoroutineMethod(PyCoroutineMixin, PyClassmember): + def run(self): + self.name = 'py:method' + return PyClassmember.run(self) + + # Support for documenting version of removal in deprecations class DeprecatedRemoved(Directive): @@ -347,5 +371,7 @@ def setup(app): app.add_description_unit('2to3fixer', '2to3fixer', '%s (2to3 fixer)') app.add_directive_to_domain('py', 'decorator', PyDecoratorFunction) app.add_directive_to_domain('py', 'decoratormethod', PyDecoratorMethod) + app.add_directive_to_domain('py', 'coroutinefunction', PyCoroutineFunction) + app.add_directive_to_domain('py', 'coroutinemethod', PyCoroutineMethod) app.add_directive('miscnews', MiscNews) return {'version': '1.0', 'parallel_read_safe': True} |