Browse Source

Working on some docs

Work in progress..
Peter Justin 7 years ago
parent
commit
605b0774dd
3 changed files with 65 additions and 157 deletions
  1. 0 123
      docs/events.rst
  2. 47 0
      docs/hooks.rst
  3. 18 34
      docs/plugins.rst

+ 0 - 123
docs/events.rst

@@ -1,123 +0,0 @@
-.. _events:
-
-Events
-======
-
-In order to extend FlaskBB you will need to connect your callbacks with
-events.
-
-.. admonition:: Additional events
-
-    If you miss an event, feel free to open a new issue or create a pull
-    request. The pull request should always contain a entry in this document
-    with a small example.
-
-    An event can be created by placing a :func:`~flask_plugins.emit_event`
-    function at specific places in the code which then can modify the behavior
-    of FlaskBB. The same thing applies for template events.
-
-    Python Event:
-
-    .. sourcecode:: python
-
-        def foobar(data)
-            somedata = "foobar"
-            emit_event("your-newly-contributed-event", somedata)
-
-
-    Template Event:
-
-    .. sourcecode:: html+jinja
-
-        {{ emit_event("your-newly-contributed-template-event") }}
-
-
-Python Events
--------------
-
-None at the moment.
-
-
-Template Events
----------------
-
-Template events, which are used in forms, are usually rendered after the
-hidden CSRF token field and before an submit field.
-
-
-.. data:: before-first-navigation-element
-
-    in ``templates/layout.html``
-
-    This event inserts a navigation link **before** the **first** navigation
-    element is rendered.
-
-    .. sourcecode:: python
-
-        def inject_navigation_element():
-            return render_template("navigation_element_snippet.html")
-
-        connect_event("before-first-navigation-element", inject_navigation_element)
-
-
-.. data:: after-last-navigation-element
-
-    in ``templates/layout.html``
-
-    This event inserts a navigation link **after** the **last** navigation
-    element is rendered.
-
-    .. sourcecode:: python
-
-        def inject_navigation_element():
-            return render_template("navigation_element_snippet.html")
-
-        connect_event("after-last-navigation-element", inject_navigation_element)
-
-
-.. data:: before-registration-form
-
-    in ``templates/auth/register.html``
-
-    This event is emitted in the Registration form **before** the first
-    input field but after the hidden CSRF token field.
-
-    .. sourcecode:: python
-
-        connect_event("before-registration-form", do_before_register_form)
-
-
-.. data:: after-registration-form
-
-    in ``templates/auth/register.html``
-
-    This event is emitted in the Registration form **after** the last
-    input field but before the submit field.
-
-    .. sourcecode:: python
-
-            connect_event("after-registration-form", do_after_register_form)
-
-
-.. data:: before-update-user-details
-
-    in ``templates/user/change_user_details.html``
-
-    This event is emitted in the Change User Details form **before** an
-    input field is rendered.
-
-    .. sourcecode:: python
-
-        connect_event("before-update-user-details", do_before_update_user_form)
-
-
-.. data:: after-update-user-details
-
-    in ``templates/user/change_user_details.html``
-
-    This event is emitted in the Change User Details form **after** the last
-    input field has been rendered but before the submit field.
-
-    .. sourcecode:: python
-
-        connect_event("after-update-user-details", do_after_update_user_form)

+ 47 - 0
docs/hooks.rst

@@ -0,0 +1,47 @@
+.. _hooks:
+
+Hooks
+=====
+
+In order to extend FlaskBB you will need to connect your callbacks with
+events.
+
+.. admonition:: Additional hooks
+
+    If you miss a hook, feel free to open a new issue or create a pull
+    request. The pull request should always contain a entry in this document
+    with a small example.
+
+    A hook needs a hook specification which are defined in
+    :mod:`flaskbb.plugins.spec`. All hooks have to be prefixed with
+    ``flaskbb_`` and template hooks with ``flaskbb_tpl_``.
+
+
+.. currentmodule:: flaskbb.plugins.spec
+
+.. autofunction:: flaskbb_extensions
+.. autofunction:: flaskbb_load_translations
+.. autofunction:: flaskbb_load_migrations
+.. autofunction:: flaskbb_load_blueprints
+.. autofunction:: flaskbb_request_processors
+.. autofunction:: flaskbb_errorhandlers
+.. autofunction:: flaskbb_jinja_directives
+.. autofunction:: flaskbb_additional_setup
+.. autofunction:: flaskbb_cli
+
+
+Template Hooks
+--------------
+
+.. note::
+
+    Template events, which are used in forms, are usually rendered after the
+    hidden CSRF token field and before an submit field.
+
+
+.. autofunction:: flaskbb_tpl_before_navigation
+.. autofunction:: flaskbb_tpl_after_navigation
+.. autofunction:: flaskbb_tpl_before_registration_form
+.. autofunction:: flaskbb_tpl_after_registration_form
+.. autofunction:: flaskbb_tpl_before_update_user_details
+.. autofunction:: flaskbb_tpl_after_update_user_details

+ 18 - 34
docs/plugins.rst

@@ -71,14 +71,9 @@ your plugins database migrations:
 Deactivating
 ~~~~~~~~~~~~
 
-The only way to disable a plugin without removing it is, to add a ``DISABLED``
-file in the plugin's root folder. You need to reload your application in order
-to have the plugin fully disabled. A disabled plugin could look like this::
+You can either deactivate the plugin via the Admin Panel or by running::
 
-    my_plugin
-    |-- DISABLED    # Just add a empty file named "DISABLED" to disable a plugin
-    |-- info.json
-    |-- __init__.py
+    flaskbb plugins disable <plugin_name>
 
 .. important:: Restart the server.
 
@@ -89,8 +84,12 @@ to have the plugin fully disabled. A disabled plugin could look like this::
 Activating
 ~~~~~~~~~~
 
-Simply remove the ``DISABLED`` file in the plugin directory and restart the
-server.
+All plugins are activated by default. To activate a deactivated plugin you
+either have to activate it via the Admin Panel again or by running the
+activation command::
+
+    flaskbb plugins enable <plugin_name>
+
 
 
 Example Plugin
@@ -138,8 +137,11 @@ section below.
 Metadata
 ~~~~~~~~
 
-In order to get a working plugin, following metadata should be defined
-in a ``info.json`` file.
+A proper plugin should have at least put the following metadata into
+the ``setup.py`` file.
+
+https://docs.python.org/3.6/distutils/setupscript.html#additional-meta-data
+https://github.com/pypa/sampleproject/blob/master/setup.py
 
 ``identifier`` : **required**
     The plugin's identifier. It should be a Python identifier (starts with a
@@ -176,27 +178,9 @@ in a ``info.json`` file.
     whether or not to show this, though.
 
 
-Events
-------
-
-A full list with events can be found here :doc:`events`.
-
-
-Plugin Class
-------------
-
-.. autoclass:: FlaskBBPlugin
-
-  .. autoattribute:: settings_key
-
-  .. autoattribute:: has_settings
-
-  .. autoattribute:: installed
-
-  .. automethod:: setup
-
-  .. automethod:: install
-
-  .. automethod:: uninstall
+Hooks
+-----
 
-  .. automethod:: register_blueprint
+FlaskBB uses so called 'Hooks' ...
+Under the hood we use `pluggy`...
+A full list of hooks can be found here :doc:`hooks`.