mirror of
https://github.com/simonw/datasette.git
synced 2026-06-12 12:06:57 +02:00
Document table JSON extras from metadata
This commit is contained in:
parent
17bbe6855c
commit
111eeaf370
3 changed files with 133 additions and 0 deletions
20
docs/json_api_doc.py
Normal file
20
docs/json_api_doc.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
def table_extras(cog):
|
||||
from datasette.extras import ExtraScope
|
||||
from datasette.views.table_extras import table_extra_registry
|
||||
|
||||
cog.out("\n.. list-table::\n")
|
||||
cog.out(" :header-rows: 1\n\n")
|
||||
cog.out(" * - Extra\n")
|
||||
cog.out(" - Description\n")
|
||||
for cls in table_extra_registry.public_classes_for_scope(ExtraScope.TABLE):
|
||||
description = cls.description or ""
|
||||
notes = []
|
||||
if cls.expensive:
|
||||
notes.append("May execute additional queries.")
|
||||
if cls.docs_note:
|
||||
notes.append(cls.docs_note)
|
||||
if notes:
|
||||
description = "{} ({})".format(description, " ".join(notes)).strip()
|
||||
cog.out(" * - ``{}``\n".format(cls.key()))
|
||||
cog.out(" - {}\n".format(description))
|
||||
cog.out("\n")
|
||||
Loading…
Add table
Add a link
Reference in a new issue