Skip to content

Commit f2b9e98

Browse files
committed
docs: Add list of supported board to module page
1 parent fa90635 commit f2b9e98

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-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, ", ".join(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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,18 @@
1414

1515
{% endif %}
1616

17+
{% if support_matrix_reverse[obj.name] is defined %}
18+
.. raw:: html
19+
20+
<p>
21+
<details>
22+
<summary>Module Availability</summary>
23+
Available on: {{ support_matrix_reverse[obj.name] }}
24+
</details>
25+
</p>
26+
27+
{% endif %}
28+
1729
{% block subpackages %}
1830
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
1931
{% if visible_subpackages %}

0 commit comments

Comments
 (0)