forked from open-telemetry/semantic-conventions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathattribute_macros.j2
28 lines (23 loc) · 1.87 KB
/
attribute_macros.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
{% import 'examples_macros.j2' as examples %}
{% 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 display_name(group) %}
{%- if 'display_name' in group %}{{ group.display_name }}
{%- else %}{{ group.id | split_id | list | reject("eq", "registry") | join(" ") | title_case | acronym }} Attributes
{%- endif %}{% endmacro %}
{% macro heading_link_fragments(title) %}{{ title | trim | lower | replace(" ", "-") | replace("(", "") | replace(")", "") | replace("/", "") | replace("\\", "") | replace(".", "") | replace("!", "") | replace("?", "") | replace("~", "") | replace("#", "")}}{% endmacro %}