Skip to content

Commit 7449b51

Browse files
kartbenhenrikbrixandersen
authored andcommitted
doc: _extensions: show boards as maintained/not actively maintained in docs
This uses the MAINTAINERS file to determine if a board is maintained or not, stores the information in the catalog and shows this in the "wikipedia sidebar" of the board documentation (adding filtering based on this is a future enhancement opportunity). Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
1 parent 63878c3 commit 7449b51

File tree

3 files changed

+43
-0
lines changed

3 files changed

+43
-0
lines changed

‎doc/_extensions/zephyr/domain/__init__.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -299,9 +299,23 @@ def convert_node(self, node):
299299
field_list = nodes.field_list()
300300
sidebar += field_list
301301

302+
if node.get("maintained", False):
303+
status_text = nodes.abbreviation(
304+
"Maintained",
305+
"Maintained",
306+
explanation="At least one active maintainer is looking after this board",
307+
)
308+
else:
309+
status_text = nodes.abbreviation(
310+
"Not actively maintained",
311+
"Not actively maintained",
312+
explanation="No active maintainer on file, but contributions are welcome",
313+
)
314+
302315
details = [
303316
("Name", nodes.literal(text=node["id"])),
304317
("Vendor", node["vendor"]),
318+
("Status", status_text),
305319
("Architecture", ", ".join(node["archs"])),
306320
("SoC", ", ".join(node["socs"])),
307321
]
@@ -744,6 +758,7 @@ def run(self):
744758
board_node["supported_runners"] = board["supported_runners"]
745759
board_node["flash_runner"] = board["flash_runner"]
746760
board_node["debug_runner"] = board["debug_runner"]
761+
board_node["maintained"] = board.get("maintained", False)
747762
return [board_node]
748763

749764

‎doc/_extensions/zephyr/domain/templates/board-card.html‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
{%- endfor -%}
3838
{{- all_compatibles|join(' ') -}}
3939
"
40+
data-maintained="{{ board.maintained | tojson }}"
4041
tabindex="0">
4142
<div class="vendor">{{ vendors[board.vendor] }}</div>
4243
{% if board.image -%}

‎doc/_scripts/gen_boards_catalog.py‎

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import yaml
1717
import zephyr_module
1818
from gen_devicetree_rest import VndLookup
19+
from get_maintainer import Maintainers
1920
from runners.core import ZephyrBinaryRunner
2021

2122
ZEPHYR_BASE = Path(__file__).parents[2]
@@ -31,6 +32,31 @@
3132

3233
logger = logging.getLogger(__name__)
3334

35+
# Initialize the Maintainers object for looking up board maintenance status
36+
MAINTAINERS = Maintainers(filename=ZEPHYR_BASE / "MAINTAINERS.yml")
37+
38+
39+
def is_board_maintained(board_doc_path: Path) -> bool:
40+
"""Determine if a board is actively maintained based on whether it is covered by an area with
41+
status 'maintained' in the MAINTAINERS.yml file.
42+
43+
Args:
44+
board_doc_path: A board doc path relative to ZEPHYR_BASE.
45+
46+
Returns:
47+
True if the board is covered by an area with status 'maintained', False otherwise.
48+
"""
49+
50+
# path2areas needs os.getcwd() to be set to ZEPHYR_BASE
51+
original_cwd = os.getcwd()
52+
try:
53+
os.chdir(ZEPHYR_BASE)
54+
areas = MAINTAINERS.path2areas(board_doc_path)
55+
finally:
56+
os.chdir(original_cwd)
57+
58+
return any(area.status == "maintained" for area in areas)
59+
3460

3561
class DeviceTreeUtils:
3662
_compat_description_cache = {}
@@ -399,6 +425,7 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
399425
"supported_features": supported_features,
400426
"compatibles": compatibles,
401427
"image": guess_image(board),
428+
"maintained": is_board_maintained(doc_page_path) if doc_page_path else False,
402429
# runners
403430
"supported_runners": board_runner_info.get("runners", []),
404431
"flash_runner": board_runner_info.get("flash-runner", ""),

0 commit comments

Comments
 (0)