|
519
|
1 |
/** |
|
|
2 |
@namespace Holds functionality related to running plugins. |
|
|
3 |
*/ |
|
|
4 |
JSDOC.PluginManager = { |
|
|
5 |
} |
|
|
6 |
|
|
|
7 |
/** |
|
|
8 |
@param name A unique name that identifies that plugin. |
|
|
9 |
@param handlers A collection of named functions. The names correspond to hooks in the core code. |
|
|
10 |
*/ |
|
|
11 |
JSDOC.PluginManager.registerPlugin = function(/**String*/name, /**Object*/handlers) { |
|
|
12 |
if (!defined(JSDOC.PluginManager.plugins)) |
|
|
13 |
/** The collection of all plugins. Requires a unique name for each. |
|
|
14 |
*/ |
|
|
15 |
JSDOC.PluginManager.plugins = {}; |
|
|
16 |
|
|
|
17 |
|
|
|
18 |
JSDOC.PluginManager.plugins[name] = handlers; |
|
|
19 |
} |
|
|
20 |
|
|
|
21 |
/** |
|
|
22 |
@param hook The name of the hook that is being caught. |
|
|
23 |
@param target Any object. This will be passed as the only argument to the handler whose |
|
|
24 |
name matches the hook name. Handlers cannot return a value, so must modify the target |
|
|
25 |
object to have an effect. |
|
|
26 |
*/ |
|
|
27 |
JSDOC.PluginManager.run = function(/**String*/hook, /**Mixed*/target) { |
|
|
28 |
for (var name in JSDOC.PluginManager.plugins) { |
|
|
29 |
if (defined(JSDOC.PluginManager.plugins[name][hook])) { |
|
|
30 |
JSDOC.PluginManager.plugins[name][hook](target); |
|
|
31 |
} |
|
|
32 |
} |
|
|
33 |
} |