summaryrefslogtreecommitdiffstatshomepage
path: root/docs/plugins/writing/transformers.rst
blob: 045058d725b8ce56d6d3c538f369f77cccbb0b0a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
Transformers
============

**hircine** supports modification of scraper results by the use of
transformers. Transformers are functions that hook into the scraping process
and may freely modify any :ref:`scraped-data` before it is shown to the user.

A transformer is specified by decorating a generator function with the
:func:`~hircine.plugins.transformer` decorator.

.. autodecorator:: hircine.plugins.transformer

.. autoclass:: hircine.scraper.ScraperInfo

Registering transformers
------------------------

To register transformers, place them into a module in the
``hircine.transformer`` :ref:`entry point group <packaging:entry-points>`. For
example, put the following in a ``pyproject.toml`` file:

.. code-block:: toml

   [project.entry-points.'hircine.transformer']
   my_transformers = 'mytransformers.transformers'

Example
-------

.. literalinclude:: /_examples/example_transformer.py
   :language: python