mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
Autodoc usingnamespace (#15216)
* autodoc: init support for usingnamespace decls * autodoc: don't build autodoc when building zig2.c * autodoc: usingnamespace decls support in frontend (#15203) * autodoc: init support for usingnamespace decls * autodoc: usingnamespace decls support in frontend --------- Co-authored-by: Krzysztof Wolicki <46651553+der-teufel-programming@users.noreply.github.com>
This commit is contained in:
parent
52d552f118
commit
602029bb2f
4 changed files with 641 additions and 424 deletions
|
|
@ -2586,7 +2586,8 @@ const NAV_MODES = {
|
|||
fnsList,
|
||||
varsList,
|
||||
valsList,
|
||||
testsList
|
||||
testsList,
|
||||
unsList
|
||||
) {
|
||||
for (let i = 0; i < decls.length; i += 1) {
|
||||
let decl = getDecl(decls[i]);
|
||||
|
|
@ -2644,6 +2645,10 @@ const NAV_MODES = {
|
|||
valsList.push(decl);
|
||||
}
|
||||
}
|
||||
|
||||
if (decl.is_uns) {
|
||||
unsList.push(decl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -2669,6 +2674,8 @@ const NAV_MODES = {
|
|||
|
||||
let testsList = [];
|
||||
|
||||
let unsList = [];
|
||||
|
||||
categorizeDecls(
|
||||
container.pubDecls,
|
||||
typesList,
|
||||
|
|
@ -2677,7 +2684,8 @@ const NAV_MODES = {
|
|||
fnsList,
|
||||
varsList,
|
||||
valsList,
|
||||
testsList
|
||||
testsList,
|
||||
unsList
|
||||
);
|
||||
if (curNav.showPrivDecls)
|
||||
categorizeDecls(
|
||||
|
|
@ -2688,9 +2696,40 @@ const NAV_MODES = {
|
|||
fnsList,
|
||||
varsList,
|
||||
valsList,
|
||||
testsList
|
||||
testsList,
|
||||
unsList
|
||||
);
|
||||
|
||||
while (unsList.length > 0) {
|
||||
let uns = unsList.shift();
|
||||
let declValue = resolveValue(uns.value);
|
||||
if (!("type" in declValue.expr)) continue;
|
||||
let uns_container = getType(declValue.expr.type);
|
||||
categorizeDecls(
|
||||
uns_container.pubDecls,
|
||||
typesList,
|
||||
namespacesList,
|
||||
errSetsList,
|
||||
fnsList,
|
||||
varsList,
|
||||
valsList,
|
||||
testsList,
|
||||
unsList
|
||||
);
|
||||
if (curNav.showPrivDecls)
|
||||
categorizeDecls(
|
||||
uns_container.privDecls,
|
||||
typesList,
|
||||
namespacesList,
|
||||
errSetsList,
|
||||
fnsList,
|
||||
varsList,
|
||||
valsList,
|
||||
testsList,
|
||||
unsList
|
||||
);
|
||||
}
|
||||
|
||||
typesList.sort(byNameProperty);
|
||||
namespacesList.sort(byNameProperty);
|
||||
errSetsList.sort(byNameProperty);
|
||||
|
|
@ -3090,7 +3129,7 @@ const NAV_MODES = {
|
|||
function findSubDecl(parentTypeOrDecl, childName) {
|
||||
let parentType = parentTypeOrDecl;
|
||||
{
|
||||
// Generic functions / resorlving decls
|
||||
// Generic functions / resolving decls
|
||||
if ("value" in parentType) {
|
||||
const rv = resolveValue(parentType.value);
|
||||
if ("type" in rv.expr) {
|
||||
|
|
@ -3116,20 +3155,35 @@ const NAV_MODES = {
|
|||
}
|
||||
}
|
||||
|
||||
if (!parentType.pubDecls) return null;
|
||||
if (parentType.pubDecls) {
|
||||
for (let i = 0; i < parentType.pubDecls.length; i += 1) {
|
||||
let declIndex = parentType.pubDecls[i];
|
||||
let childDecl = getDecl(declIndex);
|
||||
if (childDecl.name === childName) {
|
||||
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);
|
||||
if (uns_res !== null) return uns_res;
|
||||
}
|
||||
}
|
||||
if (!parentType.privDecls) return null;
|
||||
}
|
||||
|
||||
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) {
|
||||
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);
|
||||
if (uns_res !== null) return uns_res;
|
||||
}
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
|
@ -3908,6 +3962,7 @@ const NAV_MODES = {
|
|||
src: decl[2],
|
||||
value: decl[3],
|
||||
decltest: decl[4],
|
||||
is_uns: decl[5],
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
774
src/Autodoc.zig
774
src/Autodoc.zig
File diff suppressed because it is too large
Load diff
|
|
@ -2052,7 +2052,7 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void
|
|||
return;
|
||||
}
|
||||
|
||||
if (!build_options.only_c) {
|
||||
if (!build_options.only_c and !build_options.omit_pkg_fetching_code) {
|
||||
if (comp.emit_docs) |doc_location| {
|
||||
if (comp.bin_file.options.module) |module| {
|
||||
var autodoc = Autodoc.init(module, doc_location);
|
||||
|
|
|
|||
|
|
@ -3667,6 +3667,7 @@ pub const DeclIterator = struct {
|
|||
pub const Item = struct {
|
||||
name: [:0]const u8,
|
||||
sub_index: u32,
|
||||
flags: u4,
|
||||
};
|
||||
|
||||
pub fn next(it: *DeclIterator) ?Item {
|
||||
|
|
@ -3691,6 +3692,7 @@ pub const DeclIterator = struct {
|
|||
return Item{
|
||||
.sub_index = sub_index,
|
||||
.name = name,
|
||||
.flags = flags,
|
||||
};
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue