From 1f423790899f2867cb24f3705f4afdef363f01f1 Mon Sep 17 00:00:00 2001 From: Simon Willison Date: Sun, 21 Jun 2020 17:52:58 -0700 Subject: [PATCH] Improved intro on plugin_hooks.rst page, refs #687 https://datasette.readthedocs.io/en/latest/plugin_hooks.html --- docs/plugin_hooks.rst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/docs/plugin_hooks.rst b/docs/plugin_hooks.rst index 19f076b9..44797d92 100644 --- a/docs/plugin_hooks.rst +++ b/docs/plugin_hooks.rst @@ -3,7 +3,13 @@ Plugin hooks ============ -When you implement a plugin hook you can accept any or all of the parameters that are documented as being passed to that hook. For example, you can implement a ``render_cell`` plugin hook like this even though the hook definition defines more parameters than just ``value`` and ``column``: +Datasette :ref:`plugins ` use *plugin hooks* to customize Datasette's behavior. These hooks are powered by the `pluggy `__ plugin system. + +Each plugin can implement one or more hooks using the ``@hookimpl`` decorator against a function named that matches one of the hooks documented on this page. + +When you implement a plugin hook you can accept any or all of the parameters that are documented as being passed to that hook. + +For example, you can implement the ``render_cell`` plugin hook like thiseven though the full documented hook signature is ``render_cell(value, column, table, database, datasette)``: .. code-block:: python @@ -12,7 +18,8 @@ When you implement a plugin hook you can accept any or all of the parameters tha if column == "stars": return "*" * int(value) -The full list of available plugin hooks is as follows. +.. contents:: List of plugin hooks + :local: .. _plugin_hook_prepare_connection: