From e480909ecc4293d49ee2546c101fa3118430933b Mon Sep 17 00:00:00 2001 From: Gerard Marull-Paretas Date: Tue, 3 Jun 2025 16:59:29 +0200 Subject: [PATCH] [nrf fromtree] doc: extensions: kconfig: make location permalink optional If setting is not present, extension will render broken links. Let's just skip rendering the element if GH base url is unset. Signed-off-by: Gerard Marull-Paretas (cherry picked from commit 1243fdd316809c3db920007e71d0e102183e646b) --- .../zephyr/kconfig/static/kconfig.mjs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/doc/_extensions/zephyr/kconfig/static/kconfig.mjs b/doc/_extensions/zephyr/kconfig/static/kconfig.mjs index f76bf8baa92..4f175f4c1cc 100644 --- a/doc/_extensions/zephyr/kconfig/static/kconfig.mjs +++ b/doc/_extensions/zephyr/kconfig/static/kconfig.mjs @@ -68,6 +68,10 @@ function showProgress(message) { * @returns {string} - The generated GitHub URL. */ function getGithubLink(path, line, mode = "blob", revision = "main") { + if (!zephyr_gh_base_url) { + return; + } + let url = [ zephyr_gh_base_url, mode, @@ -307,14 +311,18 @@ function renderKconfigEntry(entry) { renderKconfigPropList(props, 'Choices', entry.choices, false); /* symbol location with permalink */ - const locationPermalink = document.createElement('a'); - locationPermalink.href = getGithubLink(entry.filename, entry.linenr, "blob", zephyr_version); - const locationElement = document.createTextNode(`${entry.filename}:${entry.linenr}`); locationElement.class = "pre"; - locationPermalink.appendChild(locationElement); - renderKconfigPropLiteralElement(props, 'Location', locationPermalink); + let locationPermalink = getGithubLink(entry.filename, entry.linenr, "blob", zephyr_version); + if (locationPermalink) { + const locationPermalink = document.createElement('a'); + locationPermalink.href = locationPermalink; + locationPermalink.appendChild(locationElement); + renderKconfigPropLiteralElement(props, 'Location', locationPermalink); + } else { + renderKconfigPropLiteralElement(props, 'Location', locationElement); + } renderKconfigPropLiteral(props, 'Menu path', entry.menupath);