/tags/jsdoc_toolkit-2.0.1/jsdoc-toolkit/app/lib/JSDOC/PluginManager.js

http://jsdoc-toolkit.googlecode.com/ · JavaScript · 33 lines · 14 code · 4 blank · 15 comment · 3 complexity · d5ff4cfe6136435f5755e2c9cd9457a1 MD5 · raw file

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