Skip to content

Commit f4755e9

Browse files
committed
Refresh docs for extraction method registration
1 parent 0cebe28 commit f4755e9

File tree

1 file changed

+18
-15
lines changed

1 file changed

+18
-15
lines changed

docs/messages.rst

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -184,12 +184,12 @@ example above.)
184184
Referencing Extraction Methods
185185
------------------------------
186186

187-
To be able to use short extraction method names such as “genshi”, you need to
188-
have `pkg_resources`_ installed, and the package implementing that extraction
189-
method needs to have been installed with its meta data (the `egg-info`_).
187+
Generally, packages publish Babel extractors as Python entry points,
188+
and so you can use a short name such as “genshi” to refer to them.
190189

191-
If this is not possible for some reason, you need to map the short names to
192-
fully qualified function names in an extract section in the mapping
190+
If the package implementing an extraction method has not been installed in a
191+
way that has kept its entry point mapping intact, you need to map the short
192+
names to fully qualified function names in an extract section in the mapping
193193
configuration. For example:
194194

195195
.. code-block:: ini
@@ -202,12 +202,9 @@ configuration. For example:
202202
[custom: **.ctm]
203203
some_option = foo
204204
205-
Note that the builtin extraction methods ``python`` and ``ignore`` are available
206-
by default, even if `pkg_resources`_ is not installed. You should never need to
207-
explicitly define them in the ``[extractors]`` section.
208-
209-
.. _`egg-info`: http://peak.telecommunity.com/DevCenter/PythonEggs
210-
.. _`pkg_resources`: http://peak.telecommunity.com/DevCenter/PkgResources
205+
Note that the builtin extraction methods ``python`` and ``ignore`` are always
206+
available, and you should never need to explicitly define them in the
207+
``[extractors]`` section.
211208

212209

213210
--------------------------
@@ -240,10 +237,9 @@ need to implement a function that complies with the following interface:
240237
is the job of the extractor implementation to do the decoding to
241238
``unicode`` objects.
242239

243-
Next, you should register that function as an entry point. This requires your
244-
``setup.py`` script to use `setuptools`_, and your package to be installed with
245-
the necessary metadata. If that's taken care of, add something like the
246-
following to your ``setup.py`` script:
240+
Next, you should register that function as an `entry point`_.
241+
If using ``setup.py``, add something like the following to your ``setup.py``
242+
script:
247243

248244
.. code-block:: python
249245
@@ -254,6 +250,13 @@ following to your ``setup.py`` script:
254250
xxx = your.package:extract_xxx
255251
""",
256252
253+
If using a ``pyproject.toml`` file, add something like the following:
254+
255+
.. code-block:: toml
256+
257+
[project.entry-points."babel.extractors"]
258+
xxx = "your.package:extract_xxx"
259+
257260
That is, add your extraction method to the entry point group
258261
``babel.extractors``, where the name of the entry point is the name that people
259262
will use to reference the extraction method, and the value being the module and

0 commit comments

Comments
 (0)