Browse Source

Added docs for the HookManager

sh4nks 11 years ago
parent
commit
502856c113
1 changed files with 23 additions and 1 deletions
  1. 23 1
      flaskbb/plugins/__init__.py

+ 23 - 1
flaskbb/plugins/__init__.py

@@ -107,7 +107,29 @@ class Plugin(object):
 
 
 class HookManager(object):
-    """Manages all available hooks."""
+    """Manages all available hooks.
+
+    A new hook can be created either that way::
+
+        hooks.new("testHook")
+
+    or like this::
+
+        hooks.add("testHook", test_callback)
+
+    If you want to use the last method, you'd also need to pass a callback over
+    to the ``add`` method.
+    Then you might want to add somewhere in your code the ``caller`` where all
+    registered callbacks for the specified hook are going to be called.
+    For example::
+
+        def hello():
+            do_stuff_here()
+
+            hooks.call("testHook")
+
+            do_more_stuff_here()
+    """
 
     def __init__(self):
         self.hooks = {}