Skip to content

Commit fb50021

Browse files
committed
use footnotes to improve the perform docstring
1 parent c24e7b6 commit fb50021

1 file changed

Lines changed: 19 additions & 13 deletions

File tree

effect/_base.py

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -97,25 +97,31 @@ def perform(dispatcher, effect):
9797
performer (another callable). See :obj:`TypeDispatcher` and
9898
:obj:`ComposedDispatcher` for some implementations of dispatchers, and
9999
:obj:`effect.base_dispatcher` for a dispatcher supporting basic intents
100-
like :obj:`ConstantIntent` et al.
100+
like :obj:`Constant` et al.
101101
102-
The performer will then be invoked with the dispatcher, the intent, and
103-
the box, and should perform the desired effect.
104-
105-
The dispatcher is passed so the performer can make recursive calls to
106-
:func:`perform`, if it needs to perform other effects (see :func:`parallel`
107-
and :func:`perform_parallel` for an example of this).
108-
109-
The box is an object that lets the performer provide the result (optionally
110-
asynchronously). See :func:`_Box.succeed` and :func:`_Box.fail`. Usually
111-
you can ignore the box by using a decorator like :func:`sync_performer` or
112-
:func:`effect.twisted.deferred_performer`.
102+
The performer will often be decorated with :func:`sync_performer` or
103+
something like :func:`.deferred_performer`, and will be
104+
invoked with the dispatcher [#dispatcher]_ and the intent, and should
105+
perform the desired effect. [#box]_
113106
114107
Note that this function does _not_ return the final result of the effect.
115-
You may instead want to use :func:`effect.sync_perform` or
108+
You may instead want to use :func:`.sync_perform` or
116109
:func:`effect.twisted.perform`.
117110
118111
:returns: None
112+
113+
.. [#dispatcher] The dispatcher is passed because some performers need to
114+
make recursive calls to :func:`perform`, because they need to perform
115+
other effects (see :func:`parallel` and :func:`.perform_parallel_async`
116+
for an example of this).
117+
118+
.. [#box] Without using one of those decorators, the performer is actually
119+
passed three arguments, not two: the dispatcher, the intent, and a
120+
"box". The box is an object that lets the performer provide the result,
121+
optionally asynchronously. To provide the result, use
122+
``box.succeed(result)`` or ``box.fail(exc_info)``, where ``exc_info`` is
123+
a ``sys.exc_info()``-style tuple. Decorators like :func:`sync_performer`
124+
simply abstract this away.
119125
"""
120126
def _run_callbacks(bouncer, chain, result):
121127
is_error, value = result

0 commit comments

Comments
 (0)