zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 94a7d5b8a56fd70fc7a3afe9c010a2b9cdb07b14 (tree)
parent 9d4d96ca9b186af2705f88c17b2704096c08e829
Author: Krzysztof Wolicki <der.teufel.mail@gmail.com>
Date:   Mon, 22 May 2023 00:55:51 +0200

autodoc: Links to private decls now lead to source files

Diffstat:
Mlib/docs/main.js | 33+++++++++++++++++++++++++++++----
1 file changed, 29 insertions(+), 4 deletions(-)

diff --git 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; }