Skip to content

Commit 8049158

Browse files
committed
shields: doc: allow to indicate supported hw features
Shield authors can now indicate an optional list of hardware features that the shield supports, in the form of the same kind of "binding type" already used for boards. Signed-off-by: Benjamin Cabé <benjamin@zephyrproject.org>
1 parent c26f394 commit 8049158

File tree

5 files changed

+26
-2
lines changed

5 files changed

+26
-2
lines changed

doc/_extensions/zephyr/domain/templates/shield-card.html

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@
1313
aria-label="Open the documentation page for {{ shield.full_name }}"
1414
data-name="{{ shield.full_name}}"
1515
data-vendor="{{ shield.vendor }}"
16-
tabindex="0">
16+
data-supported-features="
17+
{%- set feature_types = [] -%}
18+
{%- for feature in shield.supported_features -%}
19+
{%- if feature not in feature_types -%}
20+
{%- set _ = feature_types.append(feature) -%}
21+
{%- endif -%}
22+
{%- endfor -%}
23+
{{- feature_types|join(' ') -}}
24+
" tabindex="0">
1725
<div class="vendor">{{ vendors[shield.vendor] }}</div>
1826
{% if shield.image -%}
1927
<img alt="A picture of the {{ shield.full_name }} shield"

doc/_scripts/gen_boards_catalog.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -416,6 +416,7 @@ def get_catalog(generate_hw_features=False, hw_features_vendor_filter=None):
416416
"vendor": shield.vendor or "others",
417417
"doc_page": doc_page_path,
418418
"image": guess_image(shield),
419+
"supported_features": shield.supported_features or [],
419420
}
420421

421422
return {

doc/hardware/porting/shields.rst

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ These files provides shield configuration as follows:
3333
* ``name``: Name of the shield used in Kconfig and build system (required)
3434
* ``full_name``: Full commercial name of the shield (required)
3535
* ``vendor``: Manufacturer/vendor of the shield (required)
36+
* ``supported_features``: List of hardware features the shield supports (optional). In order to
37+
help users identify the features a shield supports without having to dig into its overlay file,
38+
the ``supported_features`` field can be used to list the types of features the shield supports.
39+
The values should be the same as the ones defined in the
40+
:zephyr_file:`dts/bindings/binding-types.txt` file.
3641

3742
Example:
3843

@@ -41,6 +46,9 @@ These files provides shield configuration as follows:
4146
name: foo_shield
4247
full_name: Foo Shield for Arduino
4348
vendor: acme
49+
supported_features:
50+
- display
51+
- input
4452
4553
* **<shield>.overlay**: This file provides a shield description in devicetree
4654
format that is merged with the board's :ref:`devicetree <dt-guide>`

scripts/list_shields.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Shield:
3939
dir: Path
4040
full_name: str | None = None
4141
vendor: str | None = None
42+
supported_features: list[str] | None = None
4243

4344
def shield_key(shield):
4445
return shield.name
@@ -49,7 +50,8 @@ def process_shield_data(shield_data, shield_dir):
4950
name=shield_data['name'],
5051
dir=shield_dir,
5152
full_name=shield_data.get('full_name'),
52-
vendor=shield_data.get('vendor')
53+
vendor=shield_data.get('vendor'),
54+
supported_features=shield_data.get('supported_features', []),
5355
)
5456

5557
def find_shields(args):

scripts/schemas/shield-schema.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,11 @@ schema;shield-schema:
2121
required: true
2222
type: str
2323
desc: Manufacturer/vendor of the shield
24+
supported_features:
25+
required: false
26+
sequence:
27+
- type: str
28+
desc: A hardware feature the shield supports (see dts/bindings/binding-types.txt)
2429

2530
type: map
2631
range:

0 commit comments

Comments
 (0)