Merge pull request #5054 from jepler/rmatrix

docs: Add list of supported board to each module's page
This commit is contained in:
Dan Halbert 2021-07-27 15:05:47 -04:00 committed by GitHub
commit 84ddb17c78
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 26 additions and 1 deletions

11
conf.py
View File

@ -24,6 +24,7 @@ import subprocess
import sys import sys
import urllib.parse import urllib.parse
import time import time
from collections import defaultdict
from sphinx.transforms import SphinxTransform from sphinx.transforms import SphinxTransform
from docutils import nodes from docutils import nodes
@ -47,9 +48,15 @@ subprocess.check_output(["make", "stubs"])
#modules_support_matrix = shared_bindings_matrix.support_matrix_excluded_boards() #modules_support_matrix = shared_bindings_matrix.support_matrix_excluded_boards()
modules_support_matrix = shared_bindings_matrix.support_matrix_by_board() modules_support_matrix = shared_bindings_matrix.support_matrix_by_board()
modules_support_matrix_reverse = defaultdict(list)
for board, modules in modules_support_matrix.items():
for module in modules:
modules_support_matrix_reverse[module].append(board)
modules_support_matrix_reverse = dict((module, sorted(boards)) for module, boards in modules_support_matrix_reverse.items())
html_context = { html_context = {
'support_matrix': modules_support_matrix 'support_matrix': modules_support_matrix,
'support_matrix_reverse': modules_support_matrix_reverse
} }
# -- General configuration ------------------------------------------------ # -- General configuration ------------------------------------------------
@ -94,6 +101,8 @@ autoapi_template_dir = 'docs/autoapi/templates'
autoapi_python_class_content = "both" autoapi_python_class_content = "both"
autoapi_python_use_implicit_namespaces = True autoapi_python_use_implicit_namespaces = True
autoapi_root = "shared-bindings" autoapi_root = "shared-bindings"
def autoapi_prepare_jinja_env(jinja_env):
jinja_env.globals['support_matrix_reverse'] = modules_support_matrix_reverse
redirects_file = 'docs/redirects.txt' redirects_file = 'docs/redirects.txt'

View File

@ -14,6 +14,22 @@
{% endif %} {% endif %}
{% if support_matrix_reverse[obj.name] is defined %}
.. raw:: html
<p>
<details>
<summary>Available on these boards</summary>
<ul>
{% for board in support_matrix_reverse[obj.name] %}
<li> {{ board }}
{% endfor %}
</ul>
</details>
</p>
{% endif %}
{% block subpackages %} {% block subpackages %}
{% set visible_subpackages = obj.subpackages|selectattr("display")|list %} {% set visible_subpackages = obj.subpackages|selectattr("display")|list %}
{% if visible_subpackages %} {% if visible_subpackages %}