import sys import os import json ext_libs_path=os.path.join(os.path.dirname(os.path.realpath(__file__)),'../python/ext-libs') sys.path.append(ext_libs_path) import jinja2 with open(sys.argv[1]) as function_file: json_params = json.load(function_file) if not 'variants' in json_params: #convert single variant shortcut to a expanded variant v = {} for i in json_params: v[i] = json_params[i] json_params['variants'] = [v] template = jinja2.Template('''

{{f.function}}

{{f.description}}

{% for v in f.variants %} {% if f.variants|length > 1 %}

{{v.variant}}

{{v.variant_description}}

{% endif %}

Syntax

{{f.function}}{% if not f.function[0] =='$' %}({% for a in v.arguments if not a.descOnly %}{{ a.arg }}{% if not loop.last or v.variableLenArguments%}, {% endif %}{% endfor %}{% if v.variableLenArguments %}...{% endif %}){% endif %}
{% if v.arguments %}

Arguments

{% for a in v.arguments if not a.syntaxOnly %} {% endfor %}
{{ a.arg }}{{ a.description }}
{% endif %} {% if v.examples %}

Examples

{% endif %} {% if v.notes %}

Notes

{{v.notes}}

{% endif %} {% endfor %} ''') print template.render(f=json_params)