autodoc: added basic support for @import

This commit is contained in:
Loris Cro
2022-02-11 19:11:03 +01:00
committed by Andrew Kelley
parent 4a868fa2be
commit ee16eddecf
2 changed files with 120 additions and 115 deletions

View File

@@ -264,15 +264,10 @@
}
var childDeclValue = resolveValue(childDecl.value);
if ("type" in childDeclValue &&
zigAnalysis.types[childDeclValue.type].kind !== typeKinds.Fn){
if (i + 1 === curNav.declNames.length) {
curNav.declObjs.push(zigAnalysis.types[childDeclValue.type]);
break;
} else {
return render404();
}
if ("type" in childDeclValue) {
childDecl = zigAnalysis.types[childDeclValue.type];
}
currentType = childDecl;
curNav.declObjs.push(currentType);
}
@@ -1458,7 +1453,7 @@
}
function findSubDecl(parentType, childName) {
if (!parentType.pubDecls) throw new Error("parent object has no public decls");
if (!parentType.pubDecls) return null;
for (var i = 0; i < parentType.pubDecls.length; i += 1) {
var declIndex = parentType.pubDecls[i];
var childDecl = zigAnalysis.decls[declIndex];
@@ -1523,24 +1518,25 @@
if (list[mainDeclIndex] != null) continue;
var decl = zigAnalysis.decls[mainDeclIndex];
var declValTypeId = resolveDeclValueTypeId(decl);
if (declValTypeId === typeTypeId &&
declCanRepresentTypeKind(zigAnalysis.types[declValTypeId].kind))
{
canonTypeDecls[declValTypeId] = mainDeclIndex;
}
var declVal = resolveValue(decl.value);
var declNames = item.declNames.concat([decl.name]);
list[mainDeclIndex] = {
pkgNames: pkgNames,
declNames: declNames,
};
if ("type" in declVal) {
var value = zigAnalysis.types[declVal.type];
if (declCanRepresentTypeKind(value.kind))
{
canonTypeDecls[declVal.type] = mainDeclIndex;
}
var declType = zigAnalysis.types[declValTypeId];
if (isContainerType(declType)) {
stack.push({
declNames: declNames,
type: declType,
});
if (isContainerType(value)) {
stack.push({
declNames: declNames,
type:value,
});
}
}
}
}