Skip to content

Commit 84ddb17

Browse files
authored
Merge pull request #5054 from jepler/rmatrix
docs: Add list of supported board to each module's page
2 parents 17ff891 + 94a4090 commit 84ddb17

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

conf.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import sys
2525
import urllib.parse
2626
import time
27+
from collections import defaultdict
2728

2829
from sphinx.transforms import SphinxTransform
2930
from docutils import nodes
@@ -47,9 +48,15 @@
4748

4849
#modules_support_matrix = shared_bindings_matrix.support_matrix_excluded_boards()
4950
modules_support_matrix = shared_bindings_matrix.support_matrix_by_board()
51+
modules_support_matrix_reverse = defaultdict(list)
52+
for board, modules in modules_support_matrix.items():
53+
for module in modules:
54+
modules_support_matrix_reverse[module].append(board)
55+
modules_support_matrix_reverse = dict((module, sorted(boards)) for module, boards in modules_support_matrix_reverse.items())
5056

5157
html_context = {
52-
'support_matrix': modules_support_matrix
58+
'support_matrix': modules_support_matrix,
59+
'support_matrix_reverse': modules_support_matrix_reverse
5360
}
5461

5562
# -- General configuration ------------------------------------------------
@@ -94,6 +101,8 @@
94101
autoapi_python_class_content = "both"
95102
autoapi_python_use_implicit_namespaces = True
96103
autoapi_root = "shared-bindings"
104+
def autoapi_prepare_jinja_env(jinja_env):
105+
jinja_env.globals['support_matrix_reverse'] = modules_support_matrix_reverse
97106

98107
redirects_file = 'docs/redirects.txt'
99108

docs/autoapi/templates/python/module.rst

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,22 @@
1414

1515
{% endif %}
1616

17+
{% if support_matrix_reverse[obj.name] is defined %}
18+
.. raw:: html
19+
20+
<p>
21+
<details>
22+
<summary>Available on these boards</summary>
23+
<ul>
24+
{% for board in support_matrix_reverse[obj.name] %}
25+
<li> {{ board }}
26+
{% endfor %}
27+
</ul>
28+
</details>
29+
</p>
30+
31+
{% endif %}
32+
1733
{% block subpackages %}
1834
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
1935
{% if visible_subpackages %}

0 commit comments

Comments
 (0)