From 379dca90b957c84758b890703d19395d2e96ccf1 Mon Sep 17 00:00:00 2001 From: David Wilson Date: Sat, 10 Aug 2019 17:21:11 +0100 Subject: [PATCH] docs: move decorator docs into core.py and use autodecorator --- docs/api.rst | 23 ++--------------------- docs/conf.py | 2 +- mitogen/core.py | 20 ++++++++++++++++++++ 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/docs/api.rst b/docs/api.rst index 51895318..273e31e3 100644 --- a/docs/api.rst +++ b/docs/api.rst @@ -26,29 +26,10 @@ mitogen.core .. automodule:: mitogen.core .. currentmodule:: mitogen.core -.. decorator:: takes_econtext - - Decorator that marks a function or class method to automatically receive a - kwarg named `econtext`, referencing the - :class:`mitogen.core.ExternalContext` active in the context in which the - function is being invoked in. The decorator is only meaningful when the - function is invoked via :data:`CALL_FUNCTION - `. - - When the function is invoked directly, `econtext` must still be passed to - it explicitly. +.. autodecorator:: takes_econtext .. currentmodule:: mitogen.core -.. decorator:: takes_router - - Decorator that marks a function or class method to automatically receive a - kwarg named `router`, referencing the :class:`mitogen.core.Router` - active in the context in which the function is being invoked in. The - decorator is only meaningful when the function is invoked via - :data:`CALL_FUNCTION `. - - When the function is invoked directly, `router` must still be passed to it - explicitly. +.. autodecorator:: takes_router mitogen.master diff --git a/docs/conf.py b/docs/conf.py index 2ee63aa8..aa91c8b8 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -7,7 +7,7 @@ VERSION = '%s.%s.%s' % mitogen.__version__ author = u'Network Genomics' copyright = u'2019, Network Genomics' -exclude_patterns = ['_build'] +exclude_patterns = ['_build', '.venv'] extensions = ['sphinx.ext.autodoc', 'sphinx.ext.intersphinx', 'sphinxcontrib.programoutput'] html_show_copyright = False html_show_sourcelink = False diff --git a/mitogen/core.py b/mitogen/core.py index aebd337e..a8de98e2 100644 --- a/mitogen/core.py +++ b/mitogen/core.py @@ -448,11 +448,31 @@ def fire(obj, name, *args, **kwargs): def takes_econtext(func): + """ + Decorator that marks a function or class method to automatically receive a + kwarg named `econtext`, referencing the + :class:`mitogen.core.ExternalContext` active in the context in which the + function is being invoked in. The decorator is only meaningful when the + function is invoked via :data:`CALL_FUNCTION `. + + When the function is invoked directly, `econtext` must still be passed to + it explicitly. + """ func.mitogen_takes_econtext = True return func def takes_router(func): + """ + Decorator that marks a function or class method to automatically receive a + kwarg named `router`, referencing the :class:`mitogen.core.Router` active + in the context in which the function is being invoked in. The decorator is + only meaningful when the function is invoked via :data:`CALL_FUNCTION + `. + + When the function is invoked directly, `router` must still be passed to it + explicitly. + """ func.mitogen_takes_router = True return func