-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #348 from KeepSafe/coroutine_docs
Add sphinx extension for coroutinemethod and coroutinefunction markup
- Loading branch information
Showing
4 changed files
with
47 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from sphinx.domains.python import PyModulelevel, PyClassmember | ||
from sphinx import addnodes | ||
|
||
|
||
class PyCoroutineMixin(object): | ||
def handle_signature(self, sig, signode): | ||
ret = super(PyCoroutineMixin, self).handle_signature(sig, signode) | ||
signode.insert(0, addnodes.desc_annotation('coroutine ', 'coroutine ')) | ||
return ret | ||
|
||
|
||
class PyCoroutineFunction(PyCoroutineMixin, PyModulelevel): | ||
def run(self): | ||
self.name = 'py:function' | ||
return PyModulelevel.run(self) | ||
|
||
|
||
class PyCoroutineMethod(PyCoroutineMixin, PyClassmember): | ||
def run(self): | ||
self.name = 'py:method' | ||
return PyClassmember.run(self) | ||
|
||
|
||
def setup(app): | ||
app.add_directive_to_domain('py', 'coroutinefunction', PyCoroutineFunction) | ||
app.add_directive_to_domain('py', 'coroutinemethod', PyCoroutineMethod) | ||
return {'version': '1.0', 'parallel_read_safe': True} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters