Skip to content

Commit

Permalink
Add disabled, notes and version to function
Browse files Browse the repository at this point in the history
  • Loading branch information
Fernando-A-Rocha committed Jan 23, 2025
1 parent 4d67bbe commit 6558c50
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 32 deletions.
104 changes: 75 additions & 29 deletions web/resources/function.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,20 @@

<!-- Title -->
<div class="function-type-title" style="color: {{type_colors[function.type_name]}};">{{ function.type_name|capitalize }} function</div>
<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>

<h1 style="border-bottom: 3px solid {{type_colors[function.type_name]}}; padding-bottom: 0.2em;">
<span {% if function.disabled %}style="text-decoration: line-through;"{% endif %}>{{ function.name }}</span>
<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>

<!-- Disabled Warning -->
{% if function.disabled %}
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid #FF0000; border-radius: 5px; background-color: rgba(255, 0, 0, 0.1);">
<h2>This function is disabled!</h2>
{% if function.disabled != true %}
<h3>{{ function.disabled }}</h3>
{% endif %}
</div>
{% endif %}

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

<!-- Version -->
{% for type_name in ['shared', 'client', 'server'] %}
{% if function[type_name] %}
{% if function[type_name].version %}
{% set version = function[type_name].version %}
<div style="display:inline-block; padding: 0.5em; margin-bottom: 0.5em; border: 1px solid {{ info_color }}; border-radius: 5px;">
{% if version.added %}
Added in <strong>{{ version.added }}</strong>
{% endif %}
{% if version.removed %}
Removed in <strong>{{ version.removed }}</strong>
{% endif %}
{% if version.deprecated %}
Deprecated in <strong>{{ version.deprecated }}</strong>
{% endif %}
{% if version.replacement %}
Replaced by <a href="/{{ version.replacement }}">{{ version.replacement }}</a>
{% endif %}
</div>
{% endif %}
{% endif %}
{% endfor %}

<!-- Issues -->
{% for type_name in ['shared', 'client', 'server'] %}
{% if function[type_name] %}

{% if function[type_name].issues %}
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px; background-color: rgba(255, 255, 0, 0.1);">
<ul>
{% for issue in function[type_name].issues %}
<li>
<a target="_blank" href="https://github.com/multitheftauto/mtasa-blue/issues/{{ issue.id }}">
Issue mtasa-blue #{{ issue.id }}
</a>: {{ issue.description_html }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}

{% endif %}
{% endfor %}

<!-- Notes -->
{% for type_name in ['shared', 'client', 'server'] %}
{% if function[type_name] %}

{% if function[type_name].notes %}
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px; background-color: rgba(0, 255, 0, 0.1);">
<ul>
{% for note in function[type_name].notes %}
<li>{{ note }}</li>
{% endfor %}
</ul>
</div>
{% endif %}

{% endif %}
{% endfor %}

<!-- Syntax -->
<h2 id="syntax">Syntax <a href="#syntax"><i class="fa-solid fa-link"></i></a></h2>
{% if function.syntaxes.single %}
Expand Down Expand Up @@ -99,8 +172,6 @@ <h4>Returns:</h4>
{% endif %}

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

Expand All @@ -117,31 +188,6 @@ <h2 id="images">Preview images <a href="#images"><i class="fa-solid fa-link"></i
{% endif %}
{% endif %}
{% endfor %}
{% endif %}

<!-- Issues -->
{% if function.has_issue %}
<h2 id="issues">Issues <a href="#issues"><i class="fa-solid fa-link"></i></a></h2>
{% for type_name in ['shared', 'client', 'server'] %}
{% if function[type_name] %}

{% if function[type_name].issues %}
<div style="padding-left: 1em; margin-top: 1em; border: 1px solid {{ info_color }}; border-radius: 5px;">
<ul>
{% for issue in function[type_name].issues %}
<li>
<a target="_blank" href="https://github.com/multitheftauto/mtasa-blue/issues/{{ issue.id }}">
mtasa-blue #{{ issue.id }}
</a>: {{ issue.description_html }}
</li>
{% endfor %}
</ul>
</div>
{% endif %}

{% endif %}
{% endfor %}
{% endif %}

<!-- Examples -->
<h2 id="examples">Examples <a href="#examples"><i class="fa-solid fa-link"></i></a></h2>
Expand Down
12 changes: 9 additions & 3 deletions web/scripts/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,15 @@ def parse_functions(self):

function = self.parse_function_preview_images(function)

# Parse markdown to HTML in function
for type_name in ['shared', 'client', 'server']:
type_info = function.get(type_name, {})
if not type_info:
continue

# Is disabled? May be string message
function["disabled"] = type_info.get('disabled', False)

# Parse markdown to HTML in function

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

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

if 'notes' in type_info:
for note in type_info['notes']:
note = utils.to_html(note, single_paragraph=True)

if 'preview_images' in type_info:
function["has_preview_image"] = True
for preview_img in type_info['preview_images']:
if 'description' in preview_img:
preview_img['description_html'] = utils.to_html(preview_img['description'], single_paragraph=True)
Expand Down

0 comments on commit 6558c50

Please sign in to comment.