Skip to content

Commit f3d6148

Browse files
committed
Skip missing third-party inventories in intersphinx mapping
When a third-party inventory file doesn't exist in the cache, skip it from the Sphinx intersphinx_mapping instead of referencing a non-existent file. This prevents Sphinx build errors when third-party inventory downloads fail.
1 parent f9ed2bd commit f3d6148

1 file changed

Lines changed: 20 additions & 11 deletions

File tree

devel-common/src/docs/utils/conf_constants.py

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -274,10 +274,23 @@ def get_autodoc_mock_imports() -> list[str]:
274274
]
275275

276276

277+
def _get_third_party_mapping(pkg_names: list[str]) -> dict[str, tuple[str, tuple[str]]]:
278+
"""Build intersphinx mapping for third-party packages, skipping those without cached inventories."""
279+
mapping: dict[str, tuple[str, tuple[str]]] = {}
280+
for pkg_name in pkg_names:
281+
inv_path = INVENTORY_CACHE_DIR / pkg_name / "objects.inv"
282+
if not inv_path.exists():
283+
continue
284+
mapping[pkg_name] = (
285+
f"{THIRD_PARTY_INDEXES[pkg_name]}/",
286+
(str(inv_path),),
287+
)
288+
return mapping
289+
290+
277291
def get_intersphinx_mapping() -> dict[str, tuple[str, tuple[str]]]:
278-
return {
279-
pkg_name: (f"{THIRD_PARTY_INDEXES[pkg_name]}/", (f"{INVENTORY_CACHE_DIR}/{pkg_name}/objects.inv",))
280-
for pkg_name in [
292+
return _get_third_party_mapping(
293+
[
281294
"boto3",
282295
"celery",
283296
"docker",
@@ -289,16 +302,12 @@ def get_intersphinx_mapping() -> dict[str, tuple[str, tuple[str]]]:
289302
"requests",
290303
"sqlalchemy",
291304
]
292-
}
305+
)
293306

294307

295308
def get_google_intersphinx_mapping() -> dict[str, tuple[str, tuple[str]]]:
296-
return {
297-
pkg_name: (
298-
f"{THIRD_PARTY_INDEXES[pkg_name]}/",
299-
(f"{INVENTORY_CACHE_DIR}/{pkg_name}/objects.inv",),
300-
)
301-
for pkg_name in [
309+
return _get_third_party_mapping(
310+
[
302311
"google-api-core",
303312
"google-cloud-automl",
304313
"google-cloud-bigquery",
@@ -324,7 +333,7 @@ def get_google_intersphinx_mapping() -> dict[str, tuple[str, tuple[str]]]:
324333
"google-cloud-videointelligence",
325334
"google-cloud-vision",
326335
]
327-
}
336+
)
328337

329338

330339
BASIC_AUTOAPI_IGNORE_PATTERNS = [

0 commit comments

Comments
 (0)