{# Tables #} {% macro code_table(headings, rows, title=None) - %} {% if title %}

{{ title }}

{% endif %} {% for heading in headings %} {% endfor %} {% for row in rows %} {% for col in row %} {% endfor %} {% endfor %}
{{ heading|markdown|safe }}
{{ col|markdown|safe }}
{% - 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) - %}
Returns:
{{ code_label(type)}}
{{ description }}

{% - endmacro %} {% macro api_method_or_event(type, header, title, description, params=None, returns=None) - %}

{{ title }}

{% markdown %}{{ description }}{% endmarkdown %} {% if params %}
Parameters:
{% 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 %}

or ...

{% endif %} {% endfor %} {% endif %} {% endfor %} {% endif %}
{% if returns %}
{% for return in returns %} {{ api_return(return.type, return.description)}} {% endfor %}
{% endif %} {% if returns is undefined and params is undefined %}
{% endif %}
{% - endmacro %} {% macro api_option(header, title, description, type, default_value) - %}

{{ title }}

{% markdown %}{{ description|safe }}{% endmarkdown %}
Type:
{{ code_label(type)}}
Default Value:
{{ code_label(type, default_value)}}

{% - endmacro %} {% macro api_parent_option(header, title, description, sub_options) - %}

{{ title }}

{% markdown %}{{ description|safe }}{% endmarkdown %} {% for sub_option in sub_options %} {{ api_option(*sub_option) }} {% endfor %}
{% endmacro - %} {% macro api_event(header, title, description, params, returns) %} {{ api_method_or_event('event', header, title, description, params, returns) }} {% endmacro %} {% macro api_method(header, title, description, params, returns) %} {{ api_method_or_event('method', header, title, description, params, returns) }} {% endmacro %} {% macro api_links(options=None, methods=None, events=None) - %} {% if options is not none or methods is not none or events is not none %} {% endif %} {% endmacro - %}