1+ {% set type_colors = {
2+ 'shared': '#7575ff',
3+ 'client': '#FF0000',
4+ 'server': '#FF7F00'
5+ } %}
6+ {% set info_color = '#ccc' %}
7+
18<!-- Title & Description -->
2- {% if function.type_name == 'shared' %}
3- <div class="function-type-title" style="color: #7575ff;">Shared function</div>
4- <h1 style="border-bottom: 3px solid #7575ff; padding-bottom: 0.1em;">{{ function.name }}</h1>
5- {{ function['shared'].description_html }}
6- {% elif function.type_name == 'client' %}
7- <div class="function-type-title" style="color: #FF0000;">Client-side function</div>
8- <h1 style="border-bottom: 3px solid #FF0000;">{{ function.name }}</h1>
9- {{ function['client'].description_html }}
10- {% elif function.type_name == 'server' %}
11- <div class="function-type-title" style="color: #FF7F00;">Server-side function</div>
12- <h1 style="border-bottom: 3px solid #FF7F00;">{{ function.name }}</h1>
13- {{ function['server'].description_html }}
14- {% endif %}
9+ <div class="function-type-title" style="color: {{type_colors[function.type_name]}};">{{ function.type_name|capitalize }} function</div>
10+ <h1 style="border-bottom: 3px solid {{type_colors[function.type_name]}}; padding-bottom: 0.1em;">{{ function.name }}</h1>
11+
12+ {{ function[function.type_name].description_html }}
1513
1614<!-- Syntax -->
1715<h2>Syntax</h2>
18- {% for type_name in ['shared', 'client', 'server'] %}
19- {% if function[type_name] %}
20- {% if function[type_name].returns %}
21- {% set return_type = function[type_name].returns["values"][0].type %}
22- {% else %}
23- {% set return_type = 'void' %}
16+ {% if function.syntaxes.single %}
17+ {% set syntax = function.syntaxes.single %}
18+ <div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;">
19+
20+ <pre><code class="language-lua">{{ syntax.returns.values_type or 'void' }} {{ function.name }} ( {% for parameter in syntax.arguments.required %}{{ parameter.type }} {{ parameter.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% for parameter in syntax.arguments.optional %}{% if syntax.arguments.required %}, {% endif %}{% if loop.first %}[ {% endif %}{{ parameter.type }} {{ parameter.name }} = {{ parameter.default }}{% if loop.last %} ]{% endif %}{% endfor %} )</code></pre>
21+
22+ {% if syntax.arguments.required %}
23+ <h3>Required arguments:</h3>
24+ <ul>
25+ {% for item in syntax.arguments.required %}
26+ <li>{{ item.type }} <strong>{{ item.name }}</strong> : {{ item.description_html }}</li>
27+ {% endfor %}
28+ </ul>
29+ {% endif %}
30+
31+ {% if syntax.arguments.optional %}
32+ <h3>Optional arguments:</h3>
33+ <ul>
34+ {% for item in syntax.arguments.optional %}
35+ <li>{{ item.type }} <strong>{{ item.name }}</strong> (default: <em>{{ item.default }}</em>) : {{ item.description_html }}</li>
36+ {% endfor %}
37+ </ul>
38+ {% endif %}
39+
40+ <h3>Returns:</h3>
41+ {% if syntax.returns.description_html %}
42+ <p>{{ syntax.returns.description_html }}</p>
2443 {% endif %}
44+ <ul>
45+ {% for item in syntax.returns['values'] %}
46+ <li>{{ item.type }} {{ item.name }}</li>
47+ {% endfor %}
48+ </ul>
2549
26- {% if function[type_name].parameters %}
27- <pre><code class="language-lua">{{ return_type }} {{ function[type_name].name }} ( {% set first_optional = true %}{% for item in function[type_name].parameters %}{% if item.default is defined %}{% if first_optional %}[ {% set first_optional = false %}{% endif %}{{ item.type }} {{ item.name }}{% if item.default is defined %} = {{ item.default }}{% endif %}{% if not loop.last %}, {% endif %}{% if loop.last %} ]{% endif %}{% else %}{{ item.type }} {{ item.name }}{% if not loop.last %}, {% endif %}{% endif %}{% endfor %} )</code></pre>
28- {% set required_arguments = function[type_name].parameters | selectattr('default', 'equalto', undefined) | list %}
29- {% set optional_arguments = function[type_name].parameters | selectattr('default', 'ne', undefined) | list %}
50+ </div>
51+ {% else %}
52+ {% for type_name in ['server', 'client'] %}
53+ {% set syntax = function.syntaxes[type_name] %}
54+ {% if syntax %}
55+ <div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ type_colors[type_name] }}; border-radius: 5px;">
56+ <h3 style="color: {{ type_colors[type_name] }};">{{ type_name|capitalize }}:</h3>
3057
31- {% if required_arguments %}
32- <h3>Required arguments:</h3>
58+ <pre><code class="language-lua">{{ syntax.returns.values_type or 'void' }} {{ function.name }} ( {% for parameter in syntax.arguments.required %}{{ parameter.type }} {{ parameter.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% for parameter in syntax.arguments.optional %}{% if syntax.arguments.required %}, {% endif %}{% if loop.first %}[ {% endif %}{{ parameter.type }} {{ parameter.name }} = {{ parameter.default }}{% if loop.last %} ]{% endif %}{% endfor %} )</code></pre>
59+
60+ {% if syntax.arguments.required %}
61+ <h4>Required arguments:</h4>
3362 <ul>
34- {% for item in required_arguments %}
63+ {% for item in syntax.arguments.required %}
3564 <li>{{ item.type }} <strong>{{ item.name }}</strong> : {{ item.description_html }}</li>
3665 {% endfor %}
3766 </ul>
3867 {% endif %}
3968
40- {% if optional_arguments %}
41- <h3 >Optional arguments:</h3 >
69+ {% if syntax.arguments.optional %}
70+ <h4 >Optional arguments:</h4 >
4271 <ul>
43- {% for item in optional_arguments %}
72+ {% for item in syntax.arguments.optional %}
4473 <li>{{ item.type }} <strong>{{ item.name }}</strong> (default: <em>{{ item.default }}</em>) : {{ item.description_html }}</li>
4574 {% endfor %}
4675 </ul>
4776 {% endif %}
48- {% endif %}
4977
50- {% endif %}
51- {% endfor %}
52-
53- <!-- Returns -->
54- {% for type_name in ['shared', 'client', 'server'] %}
55- {% if function[type_name ] %}
56- {% if function[type_name].returns %}
57- <h2>Returns</h2>
58- {% if function[type_name].returns.description_html %}
59- <p>{{ function[type_name].returns.description_html }}</p >
78+ <h4>Returns:</h4>
79+ {% if syntax.returns.description_html %}
80+ <p>{{ syntax.returns.description_html }}</p>
81+ {% endif %}
82+ <ul>
83+ {% for item in syntax.returns['values' ] %}
84+ <li>{{ item.type }} {{ item.name }}</li>
85+ {% endfor %}
86+ </ul>
87+ </div >
6088 {% endif %}
61- <ul>
62- {% for item in function[type_name].returns["values"] %}
63- <li>{{ item.type }} {{ item.name }}</li>
64- {% endfor %}
65- </ul>
66- {% endif %}
89+ {% endfor %}
6790{% endif %}
68- {% endfor %}
6991
7092<!-- Preview Images -->
7193{% if function.has_preview_image %}
72- <h2>Images</h2>
7394{% for type_name in ['shared', 'client', 'server'] %}
7495 {% if function[type_name] %}
7596
7697 {% if function[type_name].preview_images %}
77- <div>
78- <ul>
98+ <div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;">
7999 {% for image in function[type_name].preview_images %}
80- <li>
81- {% if image.description_html %}
82- <p>{{ image.description_html }}</p>
83- {% endif %}
84- <img style="max-height: 150px;" src="{{ image.path_html }}">
85- </li>
100+ {% if image.description_html %}
101+ <p>{{ image.description_html }}</p>
102+ {% endif %}
103+ <img style="max-height: 150px;" src="{{ image.path_html }}">
86104 {% endfor %}
87105 </ul>
88106 </div>
@@ -98,7 +116,7 @@ <h2>Issues</h2>
98116 {% if function[type_name] %}
99117
100118 {% if function[type_name].issues %}
101- <div>
119+ <div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;" >
102120 <ul>
103121 {% for issue in function[type_name].issues %}
104122 <li>
@@ -121,25 +139,15 @@ <h2>Examples</h2>
121139 {% if function[type_name] %}
122140
123141 {% if function[type_name].examples %}
124- <ul>
125142 {% for example in function[type_name].examples %}
126- <li><h3>Example {{ example.number }}
127- {% if type_name == 'client' %}
128- <span style="color: #FF0000;">(Client-side)</span>
129- {% elif type_name == 'server' %}
130- <span style="color: #FF7F00;">(Server-side)</span>
131- {% else %}
132- <span style="color: #7575ff;">(Shared)</span>
133- {% endif %}
134- </h3></li>
135- <div style="margin-left: 1em;">
143+ <div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ type_colors[type_name] }}; border-radius: 5px;">
144+ <h3>Example {{ example.number }} <span style="color: {{ type_colors[type_name] }};">({{ type_name|capitalize }})</span></h3>
136145 {% if example.description_html %}
137146 {{ example.description_html }}
138147 {% endif %}
139148 <pre><code class="language-lua">{{ example.code }}</code></pre>
140149 </div>
141150 {% endfor %}
142- </ul>
143151 {% endif %}
144152 {% endif %}
145153{% endfor %}
0 commit comments