Skip to content

Commit 78d3bb8

Browse files
committed
pre-commit
1 parent 3e120e4 commit 78d3bb8

File tree

1 file changed

+21
-8
lines changed

1 file changed

+21
-8
lines changed

src/mdio/builder/template_registry.py

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -174,15 +174,29 @@ def __repr__(self) -> str:
174174
def _repr_html_(self) -> str:
175175
"""Return an HTML representation of the registry for Jupyter notebooks."""
176176
template_rows = ""
177+
td_style = "padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);"
177178
for name in sorted(self._templates.keys()):
178179
template = self._templates[name]
179180
template_class = template.__class__.__name__
180-
data_domain = getattr(template, '_data_domain', '—')
181-
template_rows += f"<tr><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{name}</td><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{template_class}</td><td style='padding: 8px; text-align: left; border-bottom: 1px solid rgba(128, 128, 128, 0.2);'>{data_domain}</td></tr>"
182-
183-
html = f"""
184-
<div style="font-family: monospace; border: 1px solid rgba(128, 128, 128, 0.3); border-radius: 5px; padding: 15px; max-width: 1000px;">
185-
<div style="padding: 10px; margin: -15px -15px 15px -15px; border-bottom: 2px solid rgba(128, 128, 128, 0.3);">
181+
data_domain = getattr(template, "_data_domain", "—")
182+
template_rows += (
183+
f"<tr><td style='{td_style}'>{name}</td>"
184+
f"<td style='{td_style}'>{template_class}</td>"
185+
f"<td style='{td_style}'>{data_domain}</td></tr>"
186+
)
187+
188+
box_style = (
189+
"font-family: monospace; border: 1px solid rgba(128, 128, 128, 0.3); "
190+
"border-radius: 5px; padding: 15px; max-width: 1000px;"
191+
)
192+
header_style = (
193+
"padding: 10px; margin: -15px -15px 15px -15px; border-bottom: 2px solid rgba(128, 128, 128, 0.3);"
194+
)
195+
no_templates = '<tr><td colspan="3" style="padding: 10px; opacity: 0.5; text-align: center;">No templates registered</td></tr>' # noqa: E501
196+
197+
return f"""
198+
<div style="{box_style}">
199+
<div style="{header_style}">
186200
<strong style="font-size: 1.1em;">TemplateRegistry</strong>
187201
<span style="margin-left: 15px; opacity: 0.7;">({len(self._templates)} templates)</span>
188202
</div>
@@ -195,12 +209,11 @@ def _repr_html_(self) -> str:
195209
</tr>
196210
</thead>
197211
<tbody>
198-
{template_rows if template_rows else '<tr><td colspan="3" style="padding: 10px; opacity: 0.5; text-align: center;">No templates registered</td></tr>'}
212+
{template_rows if template_rows else no_templates}
199213
</tbody>
200214
</table>
201215
</div>
202216
"""
203-
return html
204217

205218

206219
# Global convenience functions

0 commit comments

Comments
 (0)