Skip to content

Commit

Permalink
doc/common/extensions: Basic styling.
Browse files Browse the repository at this point in the history
Turns it into a table with images, using builtin RTD classes for CSS.
  • Loading branch information
laurensvalk committed Jul 26, 2021
1 parent 2036197 commit be0903d
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 27 deletions.
56 changes: 30 additions & 26 deletions doc/common/extensions/requirements.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,36 +35,40 @@ def run(self):
# Get requirements from sphinx-directive.
requirements = set(self.arguments)

# Check compatibility for all hubs.
compatible = {
hub: requirements <= features
# Cell with image of a hub.
hub_cell = """
<th><div class="align-default">
<img alt="" src="../_images/{0}.png">
</div></th>
"""

# Table row with hub images.
hub_row = "".join([hub_cell.format(hub) for hub in HUB_FEATURES])

# Cell with checkmark or cross.
compat_cell = """<td><div style="text-align: center;">{0}</div></td>"""

# Table row with checkmark or cross.
compat_row = "".join([
compat_cell.format("✔️" if requirements <= features else "❌")
for hub, features in HUB_FEATURES.items()
}

# Table cells with hub images.
hub_cells = ["<th>{0}</th>".format(hub) for hub in compatible]

# Table cells with checkmark or cross.
compat_cells = [
"<td>✔️</td>" if compat else "<td>❌</td>"
for hub, compat in compatible.items()
]
])

# Generate full table.
html = """
<table>
<thead>
<tr>
{0}
</tr>
</thead>
<tbody>
<tr>
{1}
</tr>
</tbody>
</table>
""".format("".join(hub_cells), "".join(compat_cells))
<div class="wy-table-responsive">
<table class="docutils align-default">
<tbody>
<tr>
{0}
</tr>
<tr>
{1}
<tr/>
</tbody>
</table>
</div>
""".format(hub_row, compat_row)

# Return the node.
node = nodes.raw('', html, format="html")
Expand Down
4 changes: 3 additions & 1 deletion doc/main/micropython/umath.rst
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
:mod:`umath <umath>` -- Math functions
============================================================

This MicroPython module is similar to the `math module`_ in Python.
It is available on these hubs:

.. pybricks-requirements:: stm32-extra stm32-float

This MicroPython module is similar to the `math module`_ in Python.

.. module:: umath

Expand Down

0 comments on commit be0903d

Please sign in to comment.