{#
Tables
#}
{% macro code_table(headings, rows, title=None) - %}
{% if title %}
{{ title }}
{% endif %}
{% for heading in headings %}
{{ heading|markdown|safe }}
{% endfor %}
{% for row in rows %}
{% for col in row %}
{{ col|markdown|safe }}
{% endfor %}
{% endfor %}
{% - endmacro %}
{% macro options_table(rows, title=None) - %}
{{ code_table(("Option Name", "Type", "Default", "Description"), rows, title) }}
{% - endmacro %}
{% macro events_table(rows, title=None) - %}
{{ code_table(("Event", "Parameters", "Description"), rows, title) }}
{% - endmacro %}
{% macro methods_table(rows, title=None) - %}
{{ code_table(("Name", "Parameters", "Return", "Description"), rows, title) }}
{% - endmacro %}
{#
{% macro classes_table(rows, title=None) - %}
{{ code_table(("Property Name", "Default CSS", "Description"), rows, title) }}
{% - endmacro %}
#}
{#
Labels
#}
{% macro code_label(type, val=None) %}
{% set type_label_mapping = {
"object": {
"link": "",
},
"array": {
"link": "",
},
"function": {
"link": ""
},
"integer": {
"link": ""
},
"string": {
"link": ""
},
"boolean": {
"link": ""
},
"htmlelement": {
"link": ""
},
"qq.promise": {
"link": ""
},
"xmlhttprequest": {
"link": ""
},
"undefined": {
"link": ""
},
"null": {
"link": ""
},
"other": {
"link": ""
}
} %}
{% if "," in type %}
{% set label_types = type.split(",") %}
{% if val == None %}
{% for label_type in label_types %}
{% if loop.first %}
{{ code_label(label_type.strip(" "), val)}}
or
{% else %}
{{ code_label(label_type)}}
{% endif %}
{% endfor %}
{% else %}
{{ code_label(label_types[0], val)}}
{% endif %}
{% elif " or " in type %}
{% set label_types = type.split(" or ") %}
{% if val == None %}
{% for label_type in label_types %}
{% if loop.first %}
{{ code_label(label_type.strip(" "), val)}}
or
{% else %}
{{ code_label(label_type)}}
{% endif %}
{% endfor %}
{% else %}
{{ code_label(label_types[0], val)}}
{% endif %}
{% else %}
{% set label_type = type_label_mapping.get(type.lower(), 'other') %}
{% set text = type if val == None else val %}
{{ text|safe }}
{% endif %}
{% endmacro %}
{#
api_param
This macro will generate the correct HTML structure to document an API
method as found on api/methods.jmd and api/methods-ui.jmd
#}
{#
api_param
This macro will generate the correct HTML structure for a parameter in
the api_methods documentation.
#}
{% macro api_param(name, type, description) - %}
{{ code_label(type)}}
{{ name }}
{% markdown %}{{ description }}{% endmarkdown %}
{% - endmacro %}
{#
api_return
This macro will generate the correct HTML structure for a return in
the api_methods documentation.
#}
{% macro api_return(type, description) - %}
{% for param in params %}
{% if param is mapping %}
{{ api_param(param.name, param.type, param.description) }}
{% else %}
{% for sub_params in param %}
{{ api_param(sub_params.name, sub_params.type, sub_params.description) }}
{% if not loop.last %}
{% for option in options %}
{% if "-" in option %}
{% set option_type = option.split("-")[1] %}
{% set option = option.split("-")[0] %}
{% if option_type == "ui" %}
{% for method in methods %}
{% if "-" in method %}
{% set method_type = method.split("-")[1] %}
{% set method = method.split("-")[0] %}
{% if method_type == "ui" %}
{% for event in events %}
{% if "-" in event %}
{% set event_type = event.split("-")[1] %}
{% set event = event.split("-")[0] %}
{% if event_type == "ui" %}