plugin
- compas.plugins.plugin(method=None, category=None, requires=None, tryfirst=False, trylast=False, pluggable_name=None, domain='https://plugins.compas.dev/')[source]
Decorator to declare a plugin.
A plugin decorator marks a method as a plugin for a specified
pluggable()
extension point. Plugins are matched to their pluggable counterparts by a combination of the name of the plugin method, the category and the domain specified. These 3 parts form the extension point URL used for matching.- Parameters:
- methodcallable
The method to decorate as
plugin
.- categorystr, optional
An optional string to group or categorize plugins.
- requireslist, optional
Optionally defines a list of requirements that should be fulfilled for this plugin to be used. The requirement can either be a package name (
str
) or acallable
with a boolean return value, in which any arbitrary check can be implemented.- tryfirstbool, optional
Plugins can declare a preferred priority by setting this to
True
. By defaultFalse
.- trylastbool, optional
Alternatively, a plugin can demote itself to be least preferable setting
trylast
toTrue
. By defaultFalse
.- pluggable_namestr, optional
Usually, the name of the decorated plugin method matches that of the pluggable interface. When that is not the case, the pluggable name can be specified via this parameter.
- domainstr, optional
Domain name that “owns” the pluggable extension point. This is useful to disambiguate name collisions between extension points of different packages.