Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update documentation regarding entry points #1923

Merged
merged 4 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,11 @@


# Example configuration for intersphinx: refer to the Python standard library.
intersphinx_mapping = {"python": ("https://docs.python.org/3/", None)}
intersphinx_mapping = {
"python": ("https://docs.python.org/3/", None),
"packaging": ("https://packaging.python.org/en/latest/", None),
"setuptools": ("https://setuptools.pypa.io/en/latest/", None),
}

extlinks = {
"issue": ("https://github.com/pycqa/flake8/issues/%s", "#%s"),
Expand Down
7 changes: 2 additions & 5 deletions docs/source/plugin-development/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ To get started writing a |Flake8| :term:`plugin` you first need:

Once you've gathered these things, you can get started.

All plugins for |Flake8| must be registered via `entry points`_. In this
All plugins for |Flake8| must be registered via
:external:doc:`entry points<specifications/entry-points>`. In this
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please user the :external+<name>:doc:... syntax for this, e.g, :external+setuptools:

section we cover:

- How to register your plugin so |Flake8| can find it
Expand Down Expand Up @@ -62,7 +63,3 @@ Here's a tutorial which goes over building an ast checking plugin from scratch:
registering-plugins
plugin-parameters
formatters


.. _entry points:
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points
21 changes: 11 additions & 10 deletions docs/source/plugin-development/registering-plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,15 @@ To register any kind of plugin with |Flake8|, you need:

#. A name for your plugin that will (ideally) be unique.

#. A somewhat recent version of setuptools (newer than 0.7.0 but preferably as
recent as you can attain).

|Flake8| relies on functionality provided by setuptools called
`Entry Points`_. These allow any package to register a plugin with |Flake8|
via that package's ``setup.py`` file.
|Flake8| relies on functionality provided by build tools called
:external:doc:`entry points<specifications/entry-points>`. These allow
any package to register a plugin with |Flake8| via that package's metadata.

Let's presume that we already have our plugin written and it's in a module
called ``flake8_example``. We might have a ``setup.py`` that looks something
like:
called ``flake8_example``. We will also assume ``setuptools`` is used as a
:term:`Build Backend`, but be aware that most backends support entry points.

We might have a ``setup.py`` that looks something like:

.. code-block:: python

Expand Down Expand Up @@ -150,5 +149,7 @@ If your plugin is intended to be opt-in, it can set the attribute
:ref:`enable-extensions<option-enable-extensions>` with your plugin's entry
point.

.. _Entry Points:
https://setuptools.readthedocs.io/en/latest/pkg_resources.html#entry-points
.. seealso::

The :external:doc:`setuptools user guide <userguide/entry_point>` about
entry points.