summaryrefslogtreecommitdiffstatshomepage
path: root/docs/plugins/writing/transformers.rst
diff options
context:
space:
mode:
authorWolfgang Müller2024-03-05 18:08:09 +0100
committerWolfgang Müller2024-03-05 19:25:59 +0100
commitd1d654ebac2d51e3841675faeb56480e440f622f (patch)
tree56ef123c1a15a10dfd90836e4038e27efde950c6 /docs/plugins/writing/transformers.rst
downloadhircine-d1d654ebac2d51e3841675faeb56480e440f622f.tar.gz
Initial commit0.1.0
Diffstat (limited to 'docs/plugins/writing/transformers.rst')
-rw-r--r--docs/plugins/writing/transformers.rst31
1 files changed, 31 insertions, 0 deletions
diff --git a/docs/plugins/writing/transformers.rst b/docs/plugins/writing/transformers.rst
new file mode 100644
index 0000000..045058d
--- /dev/null
+++ b/docs/plugins/writing/transformers.rst
@@ -0,0 +1,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