Skip to content

Commit 14e4a5d

Browse files
Fix function preview image display
1 parent 61e59f6 commit 14e4a5d

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

web/resources/function.html

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,27 +60,36 @@ <h2>Returns</h2>
6060
{% endif %}
6161
<ul>
6262
{% for item in function[type_name].returns["values"] %}
63-
<li style="margin-bottom: 1em;">{{ item.type }} {{ item.name }}</li>
63+
<li>{{ item.type }} {{ item.name }}</li>
6464
{% endfor %}
6565
</ul>
6666
{% endif %}
6767
{% endif %}
6868
{% endfor %}
6969

7070
<!-- Preview Images -->
71+
{% if function.has_preview_image %}
72+
<h2>Images</h2>
7173
{% for type_name in ['shared', 'client', 'server'] %}
7274
{% if function[type_name] %}
7375

7476
{% if function[type_name].preview_images %}
7577
<div>
78+
<ul>
7679
{% for image in function[type_name].preview_images %}
77-
<p style="margin-top: 1em; margin-bottom: 0.5em;"><em>{{ image.description }}</em></p>
78-
<img style="max-height: 150px;" src="{{ image.path_html }}" alt="{{ image.description }}">
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>
7986
{% endfor %}
87+
</ul>
8088
</div>
8189
{% endif %}
8290
{% endif %}
8391
{% endfor %}
92+
{% endif %}
8493

8594
<!-- Issues -->
8695
{% if function.has_issue %}

web/scripts/builder.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,12 @@ def parse_functions(self):
101101
for issue in type_info['issues']:
102102
issue['description_html'] = utils.to_html(issue['description'], single_paragraph=True)
103103

104+
if 'preview_images' in type_info:
105+
function["has_preview_image"] = True
106+
for preview_img in type_info['preview_images']:
107+
if 'description' in preview_img:
108+
preview_img['description_html'] = utils.to_html(preview_img['description'], single_paragraph=True)
109+
104110
if ('returns' in type_info) and ('description' in type_info['returns']):
105111
type_info['returns']['description_html'] = utils.to_html(type_info['returns']['description'], single_paragraph=True)
106112

@@ -190,17 +196,15 @@ def parse_function_preview_images(self, function):
190196
base_name = os.path.basename(real_path)
191197
output_path = os.path.join(preview_images_folder, base_name)
192198

193-
# Ignore if destination file already exists
194-
if os.path.exists(output_path):
195-
continue
196-
197-
shutil.copyfile(real_path, output_path)
198-
self.logger.info(f"Created function preview image {output_path}")
199+
# Copy only if not already copied
200+
if not os.path.exists(output_path):
201+
shutil.copyfile(real_path, output_path)
202+
self.logger.info(f"Created function preview image {output_path}")
199203

200204
preview_images[type_name].append({
201205
'real_path': real_path,
202206
'path_html': f"/function_images/{base_name}",
203-
'description': preview_img.get('description'),
207+
'description': preview_img.get('description', ''),
204208
})
205209
type_info['preview_images'] = preview_images[type_name]
206210

0 commit comments

Comments
 (0)