Commit 94a7d5b8a5

Krzysztof Wolicki <der.teufel.mail@gmail.com>
2023-05-22 00:55:51
autodoc: Links to private decls now lead to source files
1 parent 9d4d96c
Changed files (1)
lib
docs
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;
   }