-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconvert-schema.j2
41 lines (36 loc) · 1.6 KB
/
convert-schema.j2
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
{#
jinja2 template for converting cello cell input schema json files to markdown
this version of the template generates markdown that should render correctly
by the terminal markdown viewer https://pypi.python.org/pypi/mdv/1.0.0
#}
{% macro extras(d) -%}
{% for k in d %}{% if k not in ["description", "type", "default"] %}{{k}}:{{d[k]}} {% endif %}{% endfor %}
{%- endmacro %}
{% macro isreq(p,l) -%}
{% if p in l %} (*) {%endif%}
{%- endmacro %}
{% macro esc(v) -%}
{{v|replace("|","|")}}
{%- endmacro %}
{% macro escc(v) -%}
{{v|capitalize|replace("|","|")}}
{%- endmacro %}
NAME (* DENOTES REQUIRED CONFIGURATION) |DESCRIPTION |TYPE |DEFAULT |CONSTRAINTS
----------------------------------------|------------|-----|--------|-----------
{% for p,v in properties.iteritems() %}
{%if not v.properties %}
{{esc(p)}}{{isreq(p, required)}} |{{ v.description }} |{{ v.type }} |{{ v.default }} |{{ esc(extras(v)) }}
{%else%}
{{escc(v.description)}}{{isreq(p, required)}}||||
{% for pp,vv in v.properties.iteritems() %}
{%if not vv.properties %}
: {{esc(p)}}.{{esc(pp)}}{{isreq(pp, v.required)}} |{{ vv.description }} |{{ vv.type }} |{{ vv.default }} |{{ escc(extras(vv)) }}
{%else%}
- {{ escc(vv.description) }}{{isreq(pp, v.required)}}||||
{% for ppp,vvv in vv.properties.iteritems() %}
:: {{esc(p)}}.{{esc(pp)}}.{{esc(ppp)}}{{isreq(ppp, vv.required)}} |{{ vvv.description }} |{{ vvv.type }} |{{ vvv.default }} |{{ esc(extras(vvv)) }}
{% endfor %}
{%endif %}
{% endfor %}
{%endif %}
{% endfor %}