From 94a7d5b8a56fd70fc7a3afe9c010a2b9cdb07b14 Mon Sep 17 00:00:00 2001 From: Krzysztof Wolicki Date: Mon, 22 May 2023 00:55:51 +0200 Subject: [PATCH] autodoc: Links to private decls now lead to source files --- lib/docs/main.js | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/lib/docs/main.js b/lib/docs/main.js index 48b48a208e..63a1e54c0d 100644 --- a/lib/docs/main.js +++ b/lib/docs/main.js @@ -572,7 +572,7 @@ const NAV_MODES = { for (let i = 0; i < curNav.declNames.length; i += 1) { let childDecl = findSubDecl(currentType, curNav.declNames[i]); window.last_decl = childDecl; - if (childDecl == null) { + if (childDecl == null || childDecl.is_private === true) { return render404(); } lastDecl = childDecl; @@ -995,9 +995,15 @@ const NAV_MODES = { return navLink(curNav.modNames, declPath); } - if (findSubDecl(curDecl, declName) != null) { - const declPath = curNav.declNames.slice(0, i).concat([declName]); - return navLink(curNav.modNames, declPath); + const subDecl = findSubDecl(curDecl, declName); + + if (subDecl != null) { + if (subDecl.is_private === true) { + return sourceFileLink(subDecl); + } else { + const declPath = curNav.declNames.slice(0, i).concat([declName]); + return navLink(curNav.modNames, declPath); + } } } @@ -3318,6 +3324,25 @@ const NAV_MODES = { } } + if (parentType.privDecls) { + for (let i = 0; i < parentType.privDecls.length; i += 1) { + let declIndex = parentType.privDecls[i]; + let childDecl = getDecl(declIndex); + if (childDecl.name === childName) { + childDecl.find_subdecl_idx = declIndex; + childDecl.is_private = true; + return childDecl; + } else if (childDecl.is_uns) { + let declValue = resolveValue(childDecl.value); + if (!("type" in declValue.expr)) continue; + let uns_container = getType(declValue.expr.type); + let uns_res = findSubDecl(uns_container, childName); + uns_res.is_private = true; + if (uns_res !== null) return uns_res; + } + } + } + return null; }