mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Utility function for cog for generating YAML/JSON tabs, refs #1153
This commit is contained in:
parent
d7b21a8623
commit
3b336d8071
1 changed files with 13 additions and 0 deletions
13
docs/metadata_doc.py
Normal file
13
docs/metadata_doc.py
Normal file
|
|
@ -0,0 +1,13 @@
|
||||||
|
import json
|
||||||
|
import textwrap
|
||||||
|
import yaml
|
||||||
|
|
||||||
|
|
||||||
|
def metadata_example(cog, example):
|
||||||
|
cog.out("\n.. tab:: YAML\n\n")
|
||||||
|
cog.out(" .. code-block:: yaml\n\n")
|
||||||
|
cog.out(textwrap.indent(yaml.dump(example), " "))
|
||||||
|
cog.out("\n\n.. tab:: JSON\n\n")
|
||||||
|
cog.out(" .. code-block:: json\n\n")
|
||||||
|
cog.out(textwrap.indent(json.dumps(example, indent=2), " "))
|
||||||
|
cog.out("\n")
|
||||||
Loading…
Add table
Add a link
Reference in a new issue