mirror of
https://github.com/ChristianLight/tutor.git
synced 2024-05-29 12:20:49 +00:00
33e4f33afe
Now that the mypy bugs have been resolved, we are able to define more precisely and cleanly the types of Actions and Filters. Moreover, can now strongly type named actions and hooks (in consts.py). With such a strong typing, we get early alerts of hooks called with incorrect arguments, which is nothing short of awesome :) This change breaks the hooks API by removing the `context=...` argument. The reason for that is that we cannot insert arbitrary arguments between `P.args, P.kwargs`: https://peps.python.org/pep-0612/#the-components-of-a-paramspec > A function declared as def inner(a: A, b: B, *args: P.args, **kwargs: > P.kwargs) -> R has type Callable[Concatenate[A, B, P], R]. Placing > keyword-only parameters between the *args and **kwargs is forbidden. Getting the documentation to build in nitpicky mode is quite difficult... We need to add `nitpick_ignore` to the docs conf.py, otherwise sphinx complains about many missing class references. This, despite upgrading almost all doc requirements (except docutils).
23 lines
1.2 KiB
ReStructuredText
23 lines
1.2 KiB
ReStructuredText
.. _filters:
|
|
|
|
=======
|
|
Filters
|
|
=======
|
|
|
|
Filters are one of the two types of hooks (the other being :ref:`actions`) that can be used to extend Tutor. Filters allow one to modify the application behavior by transforming data. Each filter has a name, and callback functions can be attached to it. When a filter is applied, these callback functions are called in sequence; the result of each callback function is passed as the first argument to the next callback function. The result of the final callback function is returned to the application as the filter's output.
|
|
|
|
.. autofunction:: tutor.hooks.filters::get
|
|
.. autofunction:: tutor.hooks.filters::get_template
|
|
.. autofunction:: tutor.hooks.filters::add
|
|
.. autofunction:: tutor.hooks.filters::add_item
|
|
.. autofunction:: tutor.hooks.filters::add_items
|
|
.. autofunction:: tutor.hooks.filters::apply
|
|
.. autofunction:: tutor.hooks.filters::apply_from_context
|
|
.. autofunction:: tutor.hooks.filters::iterate
|
|
.. autofunction:: tutor.hooks.filters::iterate_from_context
|
|
.. autofunction:: tutor.hooks.filters::clear
|
|
.. autofunction:: tutor.hooks.filters::clear_all
|
|
|
|
.. autoclass:: tutor.hooks.filters.Filter
|
|
.. autoclass:: tutor.hooks.filters.FilterTemplate
|