Skip to content

Commit 6558c50

Browse files
Add disabled, notes and version to function
1 parent 4d67bbe commit 6558c50

File tree

2 files changed

+84
-32
lines changed

2 files changed

+84
-32
lines changed

web/resources/function.html

+75-29
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,20 @@
77

88
<!-- Title -->
99
<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.2em;">{{ function.name }} <a class="small-fs" href="#" onclick="copyText('{{ function.name }}', 'copy-{{ function.name }}')"><i class="fa-solid fa-copy"></i> <span id="copy-{{ function.name }}">Copy</span> </a></h1>
11-
10+
<h1 style="border-bottom: 3px solid {{type_colors[function.type_name]}}; padding-bottom: 0.2em;">
11+
<span {% if function.disabled %}style="text-decoration: line-through;"{% endif %}>{{ function.name }}</span>
12+
<a class="small-fs" href="#" onclick="copyText('{{ function.name }}', 'copy-{{ function.name }}')"><i class="fa-solid fa-copy"></i> <span id="copy-{{ function.name }}">Copy</span> </a>
13+
</h1>
14+
15+
<!-- Disabled Warning -->
16+
{% if function.disabled %}
17+
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid #FF0000; border-radius: 5px; background-color: rgba(255, 0, 0, 0.1);">
18+
<h2>This function is disabled!</h2>
19+
{% if function.disabled != true %}
20+
<h3>{{ function.disabled }}</h3>
21+
{% endif %}
22+
</div>
23+
{% endif %}
1224

1325
<!-- Pair -->
1426
{% for type_name in ['shared', 'server', 'client'] %}
@@ -20,6 +32,67 @@ <h3>Pair: <a href="/{{ function[type_name].pair }}">{{ function[type_name].pair
2032
<!-- Description -->
2133
{{ function[function.type_name].description_html }}
2234

35+
<!-- Version -->
36+
{% for type_name in ['shared', 'client', 'server'] %}
37+
{% if function[type_name] %}
38+
{% if function[type_name].version %}
39+
{% set version = function[type_name].version %}
40+
<div style="display:inline-block; padding: 0.5em; margin-bottom: 0.5em; border: 1px solid {{ info_color }}; border-radius: 5px;">
41+
{% if version.added %}
42+
Added in <strong>{{ version.added }}</strong>
43+
{% endif %}
44+
{% if version.removed %}
45+
Removed in <strong>{{ version.removed }}</strong>
46+
{% endif %}
47+
{% if version.deprecated %}
48+
Deprecated in <strong>{{ version.deprecated }}</strong>
49+
{% endif %}
50+
{% if version.replacement %}
51+
Replaced by <a href="/{{ version.replacement }}">{{ version.replacement }}</a>
52+
{% endif %}
53+
</div>
54+
{% endif %}
55+
{% endif %}
56+
{% endfor %}
57+
58+
<!-- Issues -->
59+
{% for type_name in ['shared', 'client', 'server'] %}
60+
{% if function[type_name] %}
61+
62+
{% if function[type_name].issues %}
63+
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px; background-color: rgba(255, 255, 0, 0.1);">
64+
<ul>
65+
{% for issue in function[type_name].issues %}
66+
<li>
67+
<a target="_blank" href="https://github.com/multitheftauto/mtasa-blue/issues/{{ issue.id }}">
68+
Issue mtasa-blue #{{ issue.id }}
69+
</a>: {{ issue.description_html }}
70+
</li>
71+
{% endfor %}
72+
</ul>
73+
</div>
74+
{% endif %}
75+
76+
{% endif %}
77+
{% endfor %}
78+
79+
<!-- Notes -->
80+
{% for type_name in ['shared', 'client', 'server'] %}
81+
{% if function[type_name] %}
82+
83+
{% if function[type_name].notes %}
84+
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px; background-color: rgba(0, 255, 0, 0.1);">
85+
<ul>
86+
{% for note in function[type_name].notes %}
87+
<li>{{ note }}</li>
88+
{% endfor %}
89+
</ul>
90+
</div>
91+
{% endif %}
92+
93+
{% endif %}
94+
{% endfor %}
95+
2396
<!-- Syntax -->
2497
<h2 id="syntax">Syntax <a href="#syntax"><i class="fa-solid fa-link"></i></a></h2>
2598
{% if function.syntaxes.single %}
@@ -99,8 +172,6 @@ <h4>Returns:</h4>
99172
{% endif %}
100173

101174
<!-- Preview Images -->
102-
{% if function.has_preview_image %}
103-
<h2 id="images">Preview images <a href="#images"><i class="fa-solid fa-link"></i></a></h2>
104175
{% for type_name in ['shared', 'client', 'server'] %}
105176
{% if function[type_name] %}
106177

@@ -117,31 +188,6 @@ <h2 id="images">Preview images <a href="#images"><i class="fa-solid fa-link"></i
117188
{% endif %}
118189
{% endif %}
119190
{% endfor %}
120-
{% endif %}
121-
122-
<!-- Issues -->
123-
{% if function.has_issue %}
124-
<h2 id="issues">Issues <a href="#issues"><i class="fa-solid fa-link"></i></a></h2>
125-
{% for type_name in ['shared', 'client', 'server'] %}
126-
{% if function[type_name] %}
127-
128-
{% if function[type_name].issues %}
129-
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;">
130-
<ul>
131-
{% for issue in function[type_name].issues %}
132-
<li>
133-
<a target="_blank" href="https://github.com/multitheftauto/mtasa-blue/issues/{{ issue.id }}">
134-
mtasa-blue #{{ issue.id }}
135-
</a>: {{ issue.description_html }}
136-
</li>
137-
{% endfor %}
138-
</ul>
139-
</div>
140-
{% endif %}
141-
142-
{% endif %}
143-
{% endfor %}
144-
{% endif %}
145191

146192
<!-- Examples -->
147193
<h2 id="examples">Examples <a href="#examples"><i class="fa-solid fa-link"></i></a></h2>

web/scripts/builder.py

+9-3
Original file line numberDiff line numberDiff line change
@@ -81,11 +81,15 @@ def parse_functions(self):
8181

8282
function = self.parse_function_preview_images(function)
8383

84-
# Parse markdown to HTML in function
8584
for type_name in ['shared', 'client', 'server']:
8685
type_info = function.get(type_name, {})
8786
if not type_info:
8887
continue
88+
89+
# Is disabled? May be string message
90+
function["disabled"] = type_info.get('disabled', False)
91+
92+
# Parse markdown to HTML in function
8993

9094
if 'description' in type_info:
9195
type_info['description_html'] = utils.to_html(type_info['description'])
@@ -96,12 +100,14 @@ def parse_functions(self):
96100
example['description_html'] = utils.to_html(example['description'])
97101

98102
if 'issues' in type_info:
99-
function["has_issue"] = True
100103
for issue in type_info['issues']:
101104
issue['description_html'] = utils.to_html(issue['description'], single_paragraph=True)
102105

106+
if 'notes' in type_info:
107+
for note in type_info['notes']:
108+
note = utils.to_html(note, single_paragraph=True)
109+
103110
if 'preview_images' in type_info:
104-
function["has_preview_image"] = True
105111
for preview_img in type_info['preview_images']:
106112
if 'description' in preview_img:
107113
preview_img['description_html'] = utils.to_html(preview_img['description'], single_paragraph=True)

0 commit comments

Comments
 (0)