The Plugin Specification File

The Plugin Specification File (PSF) is a file which describes the contents and the characteristics of a plugin. It’s written in YAML format, must be called plugin.yaml and be placed inside the plugin’s directory.

The PSF contains a single hash, whose entries can be divided in two logical sections: an introduction which only contains generic information, such as the plugin name, its description, which plugins it depends on and so on, and a detailed description containing, for example, the files to require before loading the plugin, the options provided by the plugin and so on.

Here’s a complete list of the PSF entries. Keys can be either symbols or strings, and will be converted to strings upon reading (the same is true wherever the following description says that something can be either a string or symbol)1. All entries, except those explicitly marked as mandatory, are optional. The default values are given in the description of each entry.

PSF Introduction

name [Mandatory]

The name of the plugin. It can be either a string or symbol and is the name Ruber uses to make the plugin availlable to other components. It’s mostly invisible to users. In theory, it can contain any character, but in practice it’s better to use a symbol which can be entered using the ruby symbol literal syntax (:something). This means it should abide the same restrictions as a method name. The plugin name must be unique.

version [Mandatory]

The plugin version. It’s a string and can have any format, but the x.y.z format is recomanded.

about

A hash with some information about the plugin which can be useful to the user. If missing, an empty hash is used. The following keys are recognized:

deps

An array of strings or symbols with the names of other plugins this one depends from. If the plugin depends only one other plugin, the array can be omitted and this entry can directly contain the name of the dependency. If omitted, Ruber assumes the plugin doesn’t depend on other plugins.

Note that only direct dependencies need to be listed here. If the plugin depends on another plugin A, which in turn depends on the plugin B, you only need to list A here.

PSF Details

require [Mandatory]

An array of strings containing the names of the files to be required before loading the plugin, relative to the plugin directory. In particular, these files must contain all the classes mentioned in other sections of the PSF.

If only one file needs to be required, it doesn’t need to be enclosed in the array.

class

The full name of the class of the plugin object. It must be a class which is availlable after having required all files listed in the require section.

If omitted, it defaults to Ruber::Plugin. This usually only happens if the plugin only needs to add extensions to documents and projects.

ui_file

The path (relative to the plugin directory) of the XML file to be used with KDE::XMLGuiClient to describe the ui of the plugin (in particular, menu entries and toolbars). If the plugin class derives (maybe indirectly) from Ruber::GuiPlugin, this entry is mandatory, otherwise it must not be given.

actions

A hash containing data describing the actions associated with the plugin. It is ignored if the ui_file is missing (that is, for plugins which do not derive from Ruber::GuiPlugin).

The keys of the hash are the names of the actions as they appear in the UI file, while the values are hashes which can have the following entries:

config_options

This entry contains the settings that the plugin adds to the configuration manager and which will be shown in the Configure Ruber dialog.

See Option entries below for a description of the entry.

If this entry is missing, then the plugin will add no global option.

config_widgets

An array of hashes, where each hash describes a widget which should be put in the Configure Ruber dialog. See below for a description of these hashes, keeping in mind that the caption entry of each hash is required. See also SettingsDialog for more information.

If the plugin has only one configuration widget, the array can be omitted and this entry may simply contain the hash describing the widget.

If this entry is omitted, the plugin will have no configuration widget.

project_options

This entry contains the settings which the plugin adds to projects and documents.

See Option entries below for a description of the entry, keeping in mind that each inner hash can also have the entries described in the Rules entries section.

If this entry is missing the plugin will add no option to projects and documents.

project_widgets

An array of hashes, where each hash describes a widget which should be put in the Configure Project and/or Configure Document dialogs. See below for a description of these hashes, keeping in mind that the caption entry of each hash is required and that each hash can also contain the entries described in the Rules entries section. See also SettingsDialog for more information.

tool_widgets

An array of hashes, where each hash represents one of the tool widget provided by the plugin. The hash as the format described in the widget entries section, with both caption and icon mandatory. In addition, it can contain the following entries:

If this entry is missing, the plugin will provide no tool widget.

extensions

A hash describing the extensions provided by the plugin. The hash’s keys are strings or symbols representing the extensions names (which should be uinque), while the values are hashes which describe the extension.

Each hash can have the entries described in the Rules entries section and a mandatory class entry, which is a string with the full name of the class of the extension.

In some situations, it can be useful to use different classes for the same extension, depending on which rule matches (for example, the extension for a document and that for a project may provide the same API, but use different implementations, and thus be of different classes). In this case, the value associated to the extension should be an array containing the hashes for the different rules. For each document or project, the first entry with a matching rule will be used.

If this entry is missing, the plugin will provide no extensions.

Common entries

Option entries

An options entry is a series of nested hashes. The outer one represents the groups the options are divided into. It has the group names as keys and hashes as values.

Each hash in a group represents an option. It has the names of the options as keys and hashes describing each option as values.

Each inner hash describes an option. The recognized entries are:

Besides the above ones, each inner hash can also contain other entries, depending on the exact entry.

Widget entries

A widget entry is a hash which describes a widget. The following entries are recognized:

The caption and pixmap entries may be or not mandatory depending on the exact entry (for example, only the caption entry is mandatory for the config_widgets entry, but are mandatory for the tool_widgets entry).

One and only one of the class and code entries must be specified.

The code entry is useful, for example, to avoid creating a class when the same effect can be obtained with a line of two of code (for instance, if a configuration widget is a single check box, you can set the code entry to Qt::CheckBox.new{|w| w.text = "Something"} instead of creating a new widget class just to set the text of the checkbox)

Rules entries

A rule is a series of properties which tells whether an extension, project option or project widget (which here we’ll call “objects”) should be added to a project or document or not (see Ruber::AbstractProject.match_rule? for more). As described above, extensions, project options and project widgets are represented in the PSF by hashes. A rule is made by several standard entries in those hashes. The entries are:

1 This is one of many examples where the contents of the PSF differ from the internal representation which Ruber uses for them. In the PSF, some entries can be written in a concise way to make life easier for plugin writers, but they’re converted to another format when the PluginSpecification object corresponding to the PSF is created. This also allows to have alternative ways to specify an entry in the PSF while retaining a single internal representation. See the plugin specification object for details about such differences.