generated docs: show public stuff only

master
Andrew Kelley 2019-10-05 16:38:24 -04:00
parent 19c2474b34
commit 0e40fc46d1
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 42 additions and 18 deletions

View File

@ -90,7 +90,7 @@
renderPkgList(lastPkg); renderPkgList(lastPkg);
var lastDecl = curNav.declObjs[curNav.declObjs.length - 1]; var lastDecl = curNav.declObjs[curNav.declObjs.length - 1];
if (lastDecl.decls != null) { if (lastDecl.pubDecls != null) {
return renderContainer(lastDecl); return renderContainer(lastDecl);
} else if (lastDecl.type != null) { } else if (lastDecl.type != null) {
var typeObj = zigAnalysis.types[lastDecl.type]; var typeObj = zigAnalysis.types[lastDecl.type];
@ -220,8 +220,8 @@
function renderContainer(container) { function renderContainer(container) {
var typesList = []; var typesList = [];
var fnsList = []; var fnsList = [];
for (var i = 0; i < container.decls.length; i += 1) { for (var i = 0; i < container.pubDecls.length; i += 1) {
var decl = zigAnalysis.decls[container.decls[i]]; var decl = zigAnalysis.decls[container.pubDecls[i]];
if (decl.type != null) { if (decl.type != null) {
if (decl.type == typeTypeId) { if (decl.type == typeTypeId) {
typesList.push(decl); typesList.push(decl);
@ -332,9 +332,9 @@
} }
function findSubDecl(parentType, childName) { function findSubDecl(parentType, childName) {
if (parentType.decls == null) throw new Error("parent object has no decls"); if (parentType.pubDecls == null) throw new Error("parent object has no public decls");
for (var i = 0; i < parentType.decls.length; i += 1) { for (var i = 0; i < parentType.pubDecls.length; i += 1) {
var declIndex = parentType.decls[i]; var declIndex = parentType.pubDecls[i];
var childDecl = zigAnalysis.decls[declIndex]; var childDecl = zigAnalysis.decls[declIndex];
if (childDecl.name === childName) { if (childDecl.name === childName) {
return childDecl; return childDecl;

View File

@ -650,7 +650,9 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {
// TODO // TODO
break; break;
} }
jw_object_field(jw, "decls");
{
jw_object_field(jw, "pubDecls");
jw_begin_array(jw); jw_begin_array(jw);
ScopeDecls *decls_scope = ty->data.structure.decls_scope; ScopeDecls *decls_scope = ty->data.structure.decls_scope;
@ -661,11 +663,33 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {
break; break;
Tld *tld = entry->value; Tld *tld = entry->value;
if (tld->visib_mod == VisibModPub) {
jw_array_elem(jw); jw_array_elem(jw);
anal_dump_decl_ref(ctx, tld); anal_dump_decl_ref(ctx, tld);
} }
}
jw_end_array(jw); jw_end_array(jw);
}
{
jw_object_field(jw, "privDecls");
jw_begin_array(jw);
ScopeDecls *decls_scope = ty->data.structure.decls_scope;
auto it = decls_scope->decl_table.entry_iterator();
for (;;) {
auto *entry = it.next();
if (!entry)
break;
Tld *tld = entry->value;
if (tld->visib_mod == VisibModPrivate) {
jw_array_elem(jw);
anal_dump_decl_ref(ctx, tld);
}
}
jw_end_array(jw);
}
if (ty->data.structure.root_struct != nullptr) { if (ty->data.structure.root_struct != nullptr) {
Buf *path_buf = ty->data.structure.root_struct->path; Buf *path_buf = ty->data.structure.root_struct->path;