Skip to content

Commit 379dca9

Browse files
committed
docs: move decorator docs into core.py and use autodecorator
1 parent 284dda5 commit 379dca9

File tree

3 files changed

+23
-22
lines changed

3 files changed

+23
-22
lines changed

docs/api.rst

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -26,29 +26,10 @@ mitogen.core
2626
.. automodule:: mitogen.core
2727

2828
.. currentmodule:: mitogen.core
29-
.. decorator:: takes_econtext
30-
31-
Decorator that marks a function or class method to automatically receive a
32-
kwarg named `econtext`, referencing the
33-
:class:`mitogen.core.ExternalContext` active in the context in which the
34-
function is being invoked in. The decorator is only meaningful when the
35-
function is invoked via :data:`CALL_FUNCTION
36-
<mitogen.core.CALL_FUNCTION>`.
37-
38-
When the function is invoked directly, `econtext` must still be passed to
39-
it explicitly.
29+
.. autodecorator:: takes_econtext
4030

4131
.. currentmodule:: mitogen.core
42-
.. decorator:: takes_router
43-
44-
Decorator that marks a function or class method to automatically receive a
45-
kwarg named `router`, referencing the :class:`mitogen.core.Router`
46-
active in the context in which the function is being invoked in. The
47-
decorator is only meaningful when the function is invoked via
48-
:data:`CALL_FUNCTION <mitogen.core.CALL_FUNCTION>`.
49-
50-
When the function is invoked directly, `router` must still be passed to it
51-
explicitly.
32+
.. autodecorator:: takes_router
5233

5334

5435
mitogen.master

docs/conf.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
author = u'Network Genomics'
99
copyright = u'2019, Network Genomics'
10-
exclude_patterns = ['_build']
10+
exclude_patterns = ['_build', '.venv']
1111
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinxcontrib.programoutput']
1212
html_show_copyright = False
1313
html_show_sourcelink = False

mitogen/core.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,11 +448,31 @@ def fire(obj, name, *args, **kwargs):
448448

449449

450450
def takes_econtext(func):
451+
"""
452+
Decorator that marks a function or class method to automatically receive a
453+
kwarg named `econtext`, referencing the
454+
:class:`mitogen.core.ExternalContext` active in the context in which the
455+
function is being invoked in. The decorator is only meaningful when the
456+
function is invoked via :data:`CALL_FUNCTION <mitogen.core.CALL_FUNCTION>`.
457+
458+
When the function is invoked directly, `econtext` must still be passed to
459+
it explicitly.
460+
"""
451461
func.mitogen_takes_econtext = True
452462
return func
453463

454464

455465
def takes_router(func):
466+
"""
467+
Decorator that marks a function or class method to automatically receive a
468+
kwarg named `router`, referencing the :class:`mitogen.core.Router` active
469+
in the context in which the function is being invoked in. The decorator is
470+
only meaningful when the function is invoked via :data:`CALL_FUNCTION
471+
<mitogen.core.CALL_FUNCTION>`.
472+
473+
When the function is invoked directly, `router` must still be passed to it
474+
explicitly.
475+
"""
456476
func.mitogen_takes_router = True
457477
return func
458478

0 commit comments

Comments
 (0)