Skip to content

Commit 471d38c

Browse files
gmarullcarlescufi
authored andcommitted
[nrf fromtree] doc: extensions: domain: fix inventory on incremental builds
Generated objects.inv would not contain e.g. "zephyr:board" entry on incremental builds, making it impossible to use Intersphinx on other projects when rebuilding the Zephyr docset. It can be verified by inspecting inventory like this: ```python from sphinx.util.inventory import InventoryFile InventoryFile.loads(open("objects.inv", "rb").read(), uri="") inv.data.keys() ``` Signed-off-by: Gerard Marull-Paretas <[email protected]> (cherry picked from commit 6ed584f)
1 parent 6726e9b commit 471d38c

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

doc/_extensions/zephyr/domain/__init__.py

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1164,6 +1164,13 @@ class ZephyrDomain(Domain):
11641164
"has_code_sample_listing": {}, # docname -> bool
11651165
"has_board_catalog": {}, # docname -> bool
11661166
"has_board": {}, # docname -> bool
1167+
# board catalog data (populated by load_board_catalog_into_domain)
1168+
"boards": {},
1169+
"shields": {},
1170+
"vendors": {},
1171+
"socs": {},
1172+
"archs": {},
1173+
"runners": {},
11671174
}
11681175

11691176
def clear_doc(self, docname: str) -> None:
@@ -1185,6 +1192,11 @@ def clear_doc(self, docname: str) -> None:
11851192
self.data["has_board_catalog"].pop(docname, None)
11861193
self.data["has_board"].pop(docname, None)
11871194

1195+
# Clear board docnames for boards documented in this docname
1196+
for board_data in self.data.get("boards", {}).values():
1197+
if board_data.get("docname") == docname:
1198+
board_data.pop("docname", None)
1199+
11881200
def merge_domaindata(self, docnames: list[str], otherdata: dict) -> None:
11891201
self.data["code-samples"].update(otherdata["code-samples"])
11901202
self.data["code-samples-categories"].update(otherdata["code-samples-categories"])
@@ -1382,7 +1394,15 @@ def load_board_catalog_into_domain(app: Sphinx) -> None:
13821394
),
13831395
hw_features_vendor_filter=app.config.zephyr_hw_features_vendor_filter,
13841396
)
1385-
app.env.domaindata["zephyr"]["boards"] = board_catalog["boards"]
1397+
1398+
# Preserve existing docnames when reloading the catalog
1399+
existing_boards = app.env.domaindata.get("zephyr", {}).get("boards", {})
1400+
new_boards = board_catalog["boards"]
1401+
for board_name, board_data in new_boards.items():
1402+
if board_name in existing_boards and "docname" in existing_boards[board_name]:
1403+
board_data["docname"] = existing_boards[board_name]["docname"]
1404+
1405+
app.env.domaindata["zephyr"]["boards"] = new_boards
13861406
app.env.domaindata["zephyr"]["shields"] = board_catalog["shields"]
13871407
app.env.domaindata["zephyr"]["vendors"] = board_catalog["vendors"]
13881408
app.env.domaindata["zephyr"]["socs"] = board_catalog["socs"]

0 commit comments

Comments
 (0)