Skip to content

Commit

Permalink
[server/plugins/docs] document Plugin class
Browse files Browse the repository at this point in the history
  • Loading branch information
spalger committed Feb 19, 2016
1 parent d72a94e commit 4193985
Showing 1 changed file with 36 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/server/plugins/Plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,42 @@ const defaultConfigSchema = Joi.object({
enabled: Joi.boolean().default(true)
}).default();

/**
* The server plugin class, used to extend the server
* and add custom behavior. A "scoped" plugin class is
* created by the PluginApi class and provided to plugin
* providers that automatically binds all but the `opts`
* arguments.
*
* @class Plugin
* @param {KbnServer} kbnServer - the KbnServer this plugin
* belongs to.
* @param {String} path - the path from which the plugin hails
* @param {Object} pkg - the value of package.json for the plugin
* @param {Objects} opts - the options for this plugin
* @param {String} [opts.id=pkg.name] - the id for this plugin.
* @param {Object} [opts.uiExports] - a mapping of UiExport types
* to UI modules or metadata about
* the UI module
* @param {Array} [opts.require] - the other plugins that this plugin
* requires. These plugins must exist and
* be enabled for this plugin to function.
* The require'd plugins will also be
* initialized first, in order to make sure
* that dependencies provided by these plugins
* are available
* @param {String} [opts.version=pkg.version] - the version of this plugin
* @param {Function} [opts.init] - A function that will be called to initialize
* this plugin at the appropriate time.
* @param {Function} [opts.config] - A function that produces a configuration
* schema using Joi, which is passed as its
* first argument.
* @param {String|False} [opts.publicDir=path + '/public']
* - the public directory for this plugin. The final directory must
* have the name "public", though it can be located somewhere besides
* the root of the plugin. Set this to false to disable exposure of a
* public directory
*/
module.exports = class Plugin {
constructor(kbnServer, path, pkg, opts) {
this.kbnServer = kbnServer;
Expand All @@ -18,7 +54,6 @@ module.exports = class Plugin {
this.uiExportsSpecs = opts.uiExports || {};
this.requiredIds = opts.require || [];
this.version = opts.version || pkg.version;
this.externalCondition = opts.initCondition || _.constant(true);
this.externalInit = opts.init || _.noop;
this.getConfigSchema = opts.config || _.noop;
this.init = _.once(this.init);
Expand Down

0 comments on commit 4193985

Please sign in to comment.