Skip to content

Commit a5ee9f2

Browse files
committed
doc: document pytest.{hookspec,hookimpl} in the API Reference
Makes sense for them to be there; also allows for Sphinx refs.
1 parent cd269f0 commit a5ee9f2

File tree

2 files changed

+23
-6
lines changed

2 files changed

+23
-6
lines changed

doc/en/how-to/writing_hook_functions.rst

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -59,10 +59,6 @@ The remaining hook functions will not be called in this case.
5959
hook wrappers: executing around other hooks
6060
-------------------------------------------------
6161

62-
.. currentmodule:: _pytest.core
63-
64-
65-
6662
pytest plugins can implement hook wrappers which wrap the execution
6763
of other hook implementations. A hook wrapper is a generator function
6864
which yields exactly once. When pytest invokes hooks it first executes
@@ -165,6 +161,7 @@ Here is the order of execution:
165161
It's possible to use ``tryfirst`` and ``trylast`` also on hook wrappers
166162
in which case it will influence the ordering of hook wrappers among each other.
167163

164+
.. _`declaringhooks`:
168165

169166
Declaring new hooks
170167
------------------------

doc/en/reference/reference.rst

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,10 +612,30 @@ Hooks
612612

613613
**Tutorial**: :ref:`writing-plugins`
614614

615-
.. currentmodule:: _pytest.hookspec
616-
617615
Reference to all hooks which can be implemented by :ref:`conftest.py files <localplugin>` and :ref:`plugins <plugins>`.
618616

617+
@pytest.hookimpl
618+
~~~~~~~~~~~~~~~~
619+
620+
.. function:: pytest.hookimpl
621+
:decorator:
622+
623+
pytest's decorator for marking functions as hook implementations.
624+
625+
See :ref:`writinghooks` and :func:`pluggy.HookimplMarker`.
626+
627+
@pytest.hookspec
628+
~~~~~~~~~~~~~~~~
629+
630+
.. function:: pytest.hookspec
631+
:decorator:
632+
633+
pytest's decorator for marking functions as hook specifications.
634+
635+
See :ref:`declaringhooks` and :func:`pluggy.HookspecMarker`.
636+
637+
.. currentmodule:: _pytest.hookspec
638+
619639
Bootstrapping hooks
620640
~~~~~~~~~~~~~~~~~~~
621641

0 commit comments

Comments
 (0)