37 lines
2.2 KiB
Django/Jinja
37 lines
2.2 KiB
Django/Jinja
{% macro type(attribute) %}{%- if attribute.type is mapping %}
|
|
{%- if attribute.type.members[0].value is string %}string{%- endif %}
|
|
{%- if attribute.type.members[0].value is int %}int{%- endif %}
|
|
{%- if attribute.type.members[0].value is float %}double{%- endif %}
|
|
{%- elif attribute.type == "template[boolean]" %}boolean
|
|
{%- elif attribute.type == "template[int]" %}int
|
|
{%- elif attribute.type == "template[double]" %}double
|
|
{%- elif attribute.type == "template[string]" %}string
|
|
{%- elif attribute.type == "template[boolean[]]" %}boolean[]
|
|
{%- elif attribute.type == "template[int[]]" %}int[]
|
|
{%- elif attribute.type == "template[double[]]" %}double[]
|
|
{%- elif attribute.type == "template[string[]]" %}string[]
|
|
{%- else %}{{ attribute.type | trim }}{%- endif %}{% endmacro %}
|
|
|
|
{% macro name(attribute) %}{%- if attribute.type is startingwith("template[") %}`{{ attribute.name }}.<key>`
|
|
{%- else %}`{{ attribute.name }}`{%- endif %}{% endmacro %}
|
|
|
|
{% macro find_lineage(attr_id, lineage) %}{% if attr_id in lineage %}{{lineage[attr_id].source_group}}{% endif %}{% endmacro %}
|
|
|
|
{% macro name_with_link(attribute, attribute_registry_base_url, lineage_attributes) %}[{{name(attribute)}}]({{attribute_registry_base_url}}/{{ find_lineage(attribute.name, lineage_attributes) | split_id | list | reject("eq", "registry")| first | kebab_case }}.md){% endmacro %}
|
|
|
|
{% macro print_examples(examples) %}{%- for e in examples %}{%if loop.first == false %}; {% endif %}`{{ e | trim }}`{%- endfor %}{% endmacro %}
|
|
|
|
{% macro examples(attribute) %}{%- if attribute.examples %}
|
|
{%- if "[]" in attribute.type and "template" not in attribute.type %}
|
|
{%- if attribute.examples is sequence %}
|
|
{%- if attribute.examples | select("sequence") | length == 0 %}`{{ attribute.examples | trim }}`
|
|
{%- else %}{{ print_examples(attribute.examples) }}
|
|
{%- endif %}
|
|
{%- else %}`[{{ attribute.examples | trim }}]`
|
|
{%- endif %}
|
|
{%- elif attribute.examples is sequence %}{{ print_examples(attribute.examples) }}
|
|
{%- else %}`{{ attribute.examples | trim }}`
|
|
{%- endif %}{%- elif attribute.type is mapping %}
|
|
{%- for e in attribute.type.members %}{% if loop.index0 < 3 %}{% if loop.first == false %}; {% endif %}`{{ e.value | trim }}`{% endif %}{%- endfor %}
|
|
{%- endif %}{% endmacro %}
|