|
| 1 | +# Copyright (c) 2026 Nordic Semiconductor ASA |
| 2 | +# |
| 3 | +# SPDX-License-Identifier: LicenseRef-Nordic-5-Clause |
| 4 | +# |
| 5 | +# Sphinx configuration overlay used by the documentation links check |
| 6 | +# (scripts/matter_sample_checker/checks/docs/check_doc_links.py). |
| 7 | +# This file must be named conf.py because Sphinx requires that name in -c DIR. |
| 8 | +# Imports the production conf.py, then enables strict cross-reference checking |
| 9 | +# and optional intersphinx mappings to locally built NCS docset inventories. |
| 10 | + |
| 11 | +from __future__ import annotations |
| 12 | + |
| 13 | +import sys |
| 14 | +from pathlib import Path |
| 15 | + |
| 16 | +DOCS_DIR = Path(__file__).resolve().parents[1] |
| 17 | +sys.path.insert(0, str(DOCS_DIR)) |
| 18 | +sys.path.insert(0, str(DOCS_DIR / "_extensions")) |
| 19 | + |
| 20 | +from conf import * # noqa: F401,F403 |
| 21 | + |
| 22 | +extensions = list(extensions) |
| 23 | +if "sphinx.ext.intersphinx" not in extensions: |
| 24 | + extensions.append("sphinx.ext.intersphinx") |
| 25 | + |
| 26 | +# Paths in conf.py are relative to docs/, but Sphinx resolves some settings against |
| 27 | +# the -c directory (docs/checks/). Re-root those entries for link-check builds. |
| 28 | +html_extra_path = [str(DOCS_DIR / "versions.json")] |
| 29 | +templates_path = [str(DOCS_DIR / "_templates")] |
| 30 | +breathe_projects = {"ncs-matter": str(DOCS_DIR / "_build_doxygen" / "xml")} |
| 31 | + |
| 32 | +# Do not suppress missing :ref:, :doc:, or :option: warnings during link checks. |
| 33 | +suppress_warnings = [] |
| 34 | + |
| 35 | +NCS_ROOT = DOCS_DIR.parent.parent |
| 36 | +intersphinx_mapping: dict[str, tuple[str, str]] = {} |
| 37 | + |
| 38 | +_DOCSET_INVENTORIES = ( |
| 39 | + ("nrf", "nrf/doc/_build/html/nrf/objects.inv"), |
| 40 | + ("zephyr", "nrf/doc/_build/html/zephyr/objects.inv"), |
| 41 | + ("kconfig", "nrf/doc/_build/html/kconfig/objects.inv"), |
| 42 | + ("nrfxlib", "nrf/doc/_build/html/nrfxlib/objects.inv"), |
| 43 | + ("mcuboot", "nrf/doc/_build/html/mcuboot/objects.inv"), |
| 44 | + ("tfm", "nrf/doc/_build/html/tfm/objects.inv"), |
| 45 | + ("matter", "nrf/doc/_build/html/matter/objects.inv"), |
| 46 | +) |
| 47 | + |
| 48 | +for docset, rel_path in _DOCSET_INVENTORIES: |
| 49 | + inventory = NCS_ROOT / rel_path |
| 50 | + if inventory.is_file(): |
| 51 | + intersphinx_mapping[docset] = (f"../{docset}", str(inventory)) |
| 52 | + |
| 53 | +# Align with sdk-nrf linkcheck defaults where practical. |
| 54 | +linkcheck_ignore = [ |
| 55 | + # Relative links resolved by intersphinx or Doxygen. |
| 56 | + r"\.\.(\\|/)", |
| 57 | + # Redirecting and used in release notes. |
| 58 | + r"https://github\.com/nrfconnect/nrfxlib", |
| 59 | + # Local preview URL used in examples. |
| 60 | + "http://localhost:8000/latest/index.html", |
| 61 | + # SES download links. |
| 62 | + r"https://(www\.)?segger\.com/downloads/embedded-studio/embeddedstudio_arm_nordic_.+(_x\d+)?", |
| 63 | + # Requires login. |
| 64 | + "https://portal.azure.com/", |
| 65 | + "https://threadgroup.atlassian.net/wiki/spaces/", |
| 66 | + # Used as example in Doxygen. |
| 67 | + "https://google.com:443", |
| 68 | +] |
| 69 | + |
| 70 | +linkcheck_anchors_ignore = [r"page="] |
| 71 | +linkcheck_timeout = 30 |
| 72 | +linkcheck_retries = 2 |
| 73 | +linkcheck_workers = 5 |
0 commit comments