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
  • method (callable) – The method to decorate as plugin.

  • category (str, optional) – An optional string to group or categorize plugins.

  • requires (list, 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 a callable with a boolean return value, in which any arbitrary check can be implemented.

  • tryfirst (bool, optional) – Plugins can declare a preferred priority by setting this to True. By default False.

  • trylast (bool, optional) – Alternatively, a plugin can demote itself to be least preferable setting trylast to True. By default False.

  • pluggable_name (str, 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.

  • domain (str, optional) – Domain name that “owns” the pluggable extension point. This is useful to disambiguate name collisions between extension points of different packages.