kopia lustrzana https://github.com/simonw/datasette
Utility function for cog for generating YAML/JSON tabs, refs #1153
rodzic
d7b21a8623
commit
3b336d8071
|
@ -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")
|
Ładowanie…
Reference in New Issue