Skip to content

Commit 1243fdd

Browse files
gmarulldanieldegrasse
authored andcommitted
doc: extensions: kconfig: make location permalink optional
If setting is not present, extension will render broken links. Let's just skip rendering the <a> element if GH base url is unset. Signed-off-by: Gerard Marull-Paretas <gerard.marull@nordicsemi.no>
1 parent d7e7839 commit 1243fdd

File tree

1 file changed

+13
-5
lines changed

1 file changed

+13
-5
lines changed

doc/_extensions/zephyr/kconfig/static/kconfig.mjs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ function showProgress(message) {
6868
* @returns {string} - The generated GitHub URL.
6969
*/
7070
function getGithubLink(path, line, mode = "blob", revision = "main") {
71+
if (!zephyr_gh_base_url) {
72+
return;
73+
}
74+
7175
let url = [
7276
zephyr_gh_base_url,
7377
mode,
@@ -307,14 +311,18 @@ function renderKconfigEntry(entry) {
307311
renderKconfigPropList(props, 'Choices', entry.choices, false);
308312

309313
/* symbol location with permalink */
310-
const locationPermalink = document.createElement('a');
311-
locationPermalink.href = getGithubLink(entry.filename, entry.linenr, "blob", zephyr_version);
312-
313314
const locationElement = document.createTextNode(`${entry.filename}:${entry.linenr}`);
314315
locationElement.class = "pre";
315-
locationPermalink.appendChild(locationElement);
316316

317-
renderKconfigPropLiteralElement(props, 'Location', locationPermalink);
317+
let locationPermalink = getGithubLink(entry.filename, entry.linenr, "blob", zephyr_version);
318+
if (locationPermalink) {
319+
const locationPermalink = document.createElement('a');
320+
locationPermalink.href = locationPermalink;
321+
locationPermalink.appendChild(locationElement);
322+
renderKconfigPropLiteralElement(props, 'Location', locationPermalink);
323+
} else {
324+
renderKconfigPropLiteralElement(props, 'Location', locationElement);
325+
}
318326

319327
renderKconfigPropLiteral(props, 'Menu path', entry.menupath);
320328

0 commit comments

Comments
 (0)