1
+ {% set type_colors = {
2
+ 'shared': '#7575ff',
3
+ 'client': '#FF0000',
4
+ 'server': '#FF7F00'
5
+ } %}
6
+ {% set info_color = '#ccc' %}
7
+
1
8
<!-- 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 }}
15
13
16
14
<!-- Syntax -->
17
15
< 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 >
24
43
{% endif %}
44
+ < ul >
45
+ {% for item in syntax.returns['values'] %}
46
+ < li > {{ item.type }} {{ item.name }}</ li >
47
+ {% endfor %}
48
+ </ ul >
25
49
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 >
30
57
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 >
33
62
< ul >
34
- {% for item in required_arguments %}
63
+ {% for item in syntax.arguments.required %}
35
64
< li > {{ item.type }} < strong > {{ item.name }}</ strong > : {{ item.description_html }}</ li >
36
65
{% endfor %}
37
66
</ ul >
38
67
{% endif %}
39
68
40
- {% if optional_arguments %}
41
- < h3 > Optional arguments:</ h3 >
69
+ {% if syntax.arguments.optional %}
70
+ < h4 > Optional arguments:</ h4 >
42
71
< ul >
43
- {% for item in optional_arguments %}
72
+ {% for item in syntax.arguments.optional %}
44
73
< li > {{ item.type }} < strong > {{ item.name }}</ strong > (default: < em > {{ item.default }}</ em > ) : {{ item.description_html }}</ li >
45
74
{% endfor %}
46
75
</ ul >
47
76
{% endif %}
48
- {% endif %}
49
77
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 >
60
88
{% 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 %}
67
90
{% endif %}
68
- {% endfor %}
69
91
70
92
<!-- Preview Images -->
71
93
{% if function.has_preview_image %}
72
- < h2 > Images</ h2 >
73
94
{% for type_name in ['shared', 'client', 'server'] %}
74
95
{% if function[type_name] %}
75
96
76
97
{% 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; ">
79
99
{% 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 }} ">
86
104
{% endfor %}
87
105
</ ul >
88
106
</ div >
@@ -98,7 +116,7 @@ <h2>Issues</h2>
98
116
{% if function[type_name] %}
99
117
100
118
{% if function[type_name].issues %}
101
- < div >
119
+ < div style =" padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px; " >
102
120
< ul >
103
121
{% for issue in function[type_name].issues %}
104
122
< li >
@@ -121,25 +139,15 @@ <h2>Examples</h2>
121
139
{% if function[type_name] %}
122
140
123
141
{% if function[type_name].examples %}
124
- < ul >
125
142
{% 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 >
136
145
{% if example.description_html %}
137
146
{{ example.description_html }}
138
147
{% endif %}
139
148
< pre > < code class ="language-lua "> {{ example.code }}</ code > </ pre >
140
149
</ div >
141
150
{% endfor %}
142
- </ ul >
143
151
{% endif %}
144
152
{% endif %}
145
153
{% endfor %}
0 commit comments