[Doc] Some more documentation

This commit is contained in:
Ferdinand Thiessen 2020-11-01 16:25:54 +01:00
parent 425eb1c849
commit 2f9446be2f
2 changed files with 25 additions and 0 deletions

View File

@ -2,6 +2,9 @@ _hook_dict = {}
class Hook(object):
"""Decorator for Hooks
Use to decorate system hooks where plugins should be able to hook in
"""
def __init__(self, function):
self.function = function
@ -12,6 +15,7 @@ class Hook(object):
class HookCall(object):
"""Decorator for functions to be called if a Hook is called"""
def __init__(self, name):
self.name = name

View File

@ -4,11 +4,27 @@ from werkzeug.exceptions import MethodNotAllowed
from flaschengeist.hook import HookCall
send_message_hook = HookCall("send_message")
"""Hook for sending messages, register to send the message
Args:
message: Message object to send
"""
update_user_hook = HookCall("update_user")
"""When ever an user update is done, this is called before.
Args:
user: User object
"""
class Plugin:
"""Base class for all Plugins"""
def __init__(self, config=None, blueprint=None, permissions=[]):
"""Constructor called by create_app
Args:
config: Dict configuration containing the plugin section
blueprint: A flask blueprint containing all plugin routes
permissions: List of permissions of this Plugin
"""
self.blueprint = blueprint
self.permissions = permissions
self.version = pkg_resources.get_distribution(self.__module__.split(".")[0]).version
@ -20,6 +36,11 @@ class Plugin:
pass
def serialize(self):
"""Serialize a plugin into a dict
Returns:
Dict containing version and permissions of the plugin
"""
return {"version": self.version, "permissions": self.permissions}