doc/common/requirements: Fix image paths.

This ensures that the requirements directive works regardless of the depth of the document in the tree.
This commit is contained in:
Laurens Valk
2021-08-05 12:32:03 +02:00
parent 4945156d9a
commit a0467b8d8e
+10 -2
View File
@@ -57,13 +57,21 @@ class PybricksRequirementsStaticDirective(Directive):
# Cell with image of a hub.
hub_cell = """
<th><div class="align-default">
<img alt="" src="../_images/compat_{0}_{1}_label.png">
<img alt="" src="{0}_images/compat_{1}_{2}_label.png">
</div></th>
"""
# Determine how far up the tree we are to set correct image path.
current_document = env.docname
depth = len(current_document.split("/")) - 1
depth_path = "../" * depth
# Table row with hub images.
compat_row = "".join([
hub_cell.format(hub, "true" if requirements <= features else "false")
hub_cell.format(
depth_path,
hub,
"true" if requirements <= features else "false")
for hub, features in HUB_FEATURES.items()
])