Commit 31ef8d78 by Bartosz Sokorski Committed by GitHub

docs: rephrase plugin configuration in docs (#6557)

Co-authored-by: Bjorn Neergaard <bjorn@neersighted.com>
Co-authored-by: Mathieu Kniewallner <mathieu.kniewallner@gmail.com>
parent e64eb9e2
...@@ -50,7 +50,7 @@ demo = "poetry_demo_plugin.plugin:MyPlugin" ...@@ -50,7 +50,7 @@ demo = "poetry_demo_plugin.plugin:MyPlugin"
Every plugin has to supply a class which implements the `poetry.plugins.Plugin` interface. Every plugin has to supply a class which implements the `poetry.plugins.Plugin` interface.
The `activate()` method of the plugin is called after the plugin is loaded The `activate()` method of the plugin is called after the plugin is loaded
and receives an instance of `Poetry` as well as an instance of `cleo.io.IO`. and receives an instance of `Poetry` as well as an instance of `cleo.io.io.IO`.
Using these two objects all configuration can be read Using these two objects all configuration can be read
and all public internal objects and state can be manipulated as desired. and all public internal objects and state can be manipulated as desired.
...@@ -78,7 +78,7 @@ If you want to add commands or options to the `poetry` script you need ...@@ -78,7 +78,7 @@ If you want to add commands or options to the `poetry` script you need
to create an application plugin which implements the `poetry.plugins.ApplicationPlugin` interface. to create an application plugin which implements the `poetry.plugins.ApplicationPlugin` interface.
The `activate()` method of the application plugin is called after the plugin is loaded The `activate()` method of the application plugin is called after the plugin is loaded
and receives an instance of `console.Application`. and receives an instance of `poetry.console.Application`.
```python ```python
from cleo.commands.command import Command from cleo.commands.command import Command
...@@ -119,7 +119,7 @@ This will help keep the performances of Poetry good. ...@@ -119,7 +119,7 @@ This will help keep the performances of Poetry good.
{{% /note %}} {{% /note %}}
The plugin also must be declared in the `pyproject.toml` file of the plugin package The plugin also must be declared in the `pyproject.toml` file of the plugin package
as an `application.plugin` plugin: as a `poetry.application.plugin` plugin:
```toml ```toml
[tool.poetry.plugins."poetry.application.plugin"] [tool.poetry.plugins."poetry.application.plugin"]
...@@ -135,7 +135,7 @@ A plugin **must not** remove or modify in any way the core commands of Poetry. ...@@ -135,7 +135,7 @@ A plugin **must not** remove or modify in any way the core commands of Poetry.
Plugins can also listen to specific events and act on them if necessary. Plugins can also listen to specific events and act on them if necessary.
These events are fired by [Cleo](https://github.com/sdispater/cleo) These events are fired by [Cleo](https://github.com/python-poetry/cleo)
and are accessible from the `cleo.events.console_events` module. and are accessible from the `cleo.events.console_events` module.
- `COMMAND`: this event allows attaching listeners before any command is executed. - `COMMAND`: this event allows attaching listeners before any command is executed.
......
...@@ -414,15 +414,27 @@ Dependencies listed in [dependency groups]({{< relref "managing-dependencies#dep ...@@ -414,15 +414,27 @@ Dependencies listed in [dependency groups]({{< relref "managing-dependencies#dep
## `plugins` ## `plugins`
Poetry supports arbitrary plugins which work similarly to Poetry supports arbitrary plugins, which are exposed as the ecosystem-standard [entry points](https://packaging.python.org/en/latest/specifications/entry-points/) and discoverable using `importlib.metadata`. This is similar to (and compatible with) the entry points feature of `setuptools`.
[setuptools entry points](http://setuptools.readthedocs.io/en/latest/setuptools.html). The syntax for registering a plugin is:
To match the example in the setuptools documentation, you would use the following:
```toml ```toml
[tool.poetry.plugins] # Optional super table [tool.poetry.plugins] # Optional super table
[tool.poetry.plugins."blogtool.parsers"] [tool.poetry.plugins."A"]
".rst" = "some_module:SomeClass" "B" = "C:D"
```
Which are:
- `A` - type of the plugin, for example `poetry.plugin` or `flake8.extension`
- `B` - name of the plugin
- `C` - python module import path
- `D` - the entry point of the plugin (a function or class)
Example (from [`poetry-plugin-export`](http://github.com/python-poetry/poetry-plugin-export)):
```toml
[tool.poetry.plugins."poetry.application.plugin"]
export = "poetry_plugin_export.plugins:ExportApplicationPlugin"
``` ```
## `urls` ## `urls`
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment