From 2f9446be2ff4fee1ed6c5a7178119e7756982b00 Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Sun, 1 Nov 2020 16:25:54 +0100 Subject: [PATCH] [Doc] Some more documentation --- flaschengeist/hook.py | 4 ++++ flaschengeist/plugins/__init__.py | 21 +++++++++++++++++++++ 2 files changed, 25 insertions(+) diff --git a/flaschengeist/hook.py b/flaschengeist/hook.py index e855341..067d4e5 100644 --- a/flaschengeist/hook.py +++ b/flaschengeist/hook.py @@ -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 diff --git a/flaschengeist/plugins/__init__.py b/flaschengeist/plugins/__init__.py index bfc73fe..f329472 100644 --- a/flaschengeist/plugins/__init__.py +++ b/flaschengeist/plugins/__init__.py @@ -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}