mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Action() is kw_only, abbr= is optional, closes #2571
This commit is contained in:
parent
7e09e1bf1b
commit
063bf7a96f
4 changed files with 10 additions and 9 deletions
|
|
@ -905,7 +905,7 @@ The fields of the ``Action`` dataclass are as follows:
|
|||
The name of the action, e.g. ``view-document``. This should be unique across all plugins.
|
||||
|
||||
``abbr`` - string or None
|
||||
An abbreviation of the action, e.g. ``vdoc``. This is optional. Since this needs to be unique across all installed plugins it's best to choose carefully or use ``None``.
|
||||
An abbreviation of the action, e.g. ``vdoc``. This is optional. Since this needs to be unique across all installed plugins it's best to choose carefully or omit it entirely (same as setting it to ``None``.)
|
||||
|
||||
``description`` - string or None
|
||||
A human-readable description of what the action allows you to do.
|
||||
|
|
|
|||
|
|
@ -63,23 +63,21 @@ def register_actions(datasette):
|
|||
return [
|
||||
Action(
|
||||
name="explain-sql",
|
||||
abbr=None,
|
||||
description="Explain SQL queries",
|
||||
resource_class=DatabaseResource,
|
||||
),
|
||||
Action(
|
||||
name="annotate-rows",
|
||||
abbr=None,
|
||||
description="Annotate rows",
|
||||
resource_class=TableResource,
|
||||
),
|
||||
Action(
|
||||
name="view-debug-info",
|
||||
abbr=None,
|
||||
description="View debug information",
|
||||
),
|
||||
]
|
||||
```
|
||||
The `abbr=` is now optional and defaults to `None`.
|
||||
|
||||
For actions that apply to specific resources (like databases or tables), specify the `resource_class` instead of `takes_parent` and `takes_child`. Note that `view-debug-info` does not specify a `resource_class` because it applies globally.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue