Skip to content

Commit

Permalink
Initial ocumentation for core events, refs #2240
Browse files Browse the repository at this point in the history
  • Loading branch information
simonw committed Jan 31, 2024
1 parent 36be512 commit f9f7b6f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
22 changes: 22 additions & 0 deletions datasette/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,38 @@ def properties(self):

@dataclass
class LoginEvent(Event):
"""
Event name: ``login``
A user (represented by ``event.actor``) has logged in.
"""
name = "login"


@dataclass
class LogoutEvent(Event):
"""
Event name: ``logout``
A user (represented by ``event.actor``) has logged out.
"""
name = "logout"


@dataclass
class CreateTableEvent(Event):
"""
Event name: ``create-table``
A new table has been created in the database.
:ivar database: The name of the database where the table was created.
:type database: str
:ivar table: The name of the table that was created
:type table: str
:ivar schema: The SQL schema definition for the new table.
:type schema: str
"""
name = "create-table"
database: str
table: str
Expand Down
2 changes: 2 additions & 0 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@
if not os.environ.get("DISABLE_SPHINX_INLINE_TABS"):
extensions += ["sphinx_inline_tabs"]

autodoc_member_order = "bysource"

extlinks = {
"issue": ("https://github.com/simonw/datasette/issues/%s", "#%s"),
}
Expand Down
12 changes: 12 additions & 0 deletions docs/events.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Events
======

Datasette includes a mechanism for tracking events that occur while the software is running. This is primarily intended to be used by plugins, which can both trigger events and listen for events.

The core Datasette application triggers events when certain things happen. This page describes those events.

Plugins can listen for events using the :ref:`plugin_hook_track_event` plugin hook.

.. automodule:: datasette.events
:members:
:exclude-members: Event
1 change: 1 addition & 0 deletions docs/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,6 @@ Contents
plugin_hooks
testing_plugins
internals
events
contributing
changelog

0 comments on commit f9f7b6f

Please sign in to comment.