Add initial support for struct fields in the docs
parent
1e59eb3c94
commit
f74c29b49a
|
@ -275,6 +275,11 @@
|
||||||
<h2>No Results Found</h2>
|
<h2>No Results Found</h2>
|
||||||
<p>Press escape to exit search and then '?' to see more options.</p>
|
<p>Press escape to exit search and then '?' to see more options.</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div id="sectFields" class="hidden">
|
||||||
|
<h2>Fields</h2>
|
||||||
|
<ul id="listFields">
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
<div id="sectTypes" class="hidden">
|
<div id="sectTypes" class="hidden">
|
||||||
<h2>Types</h2>
|
<h2>Types</h2>
|
||||||
<ul id="listTypes">
|
<ul id="listTypes">
|
||||||
|
|
|
@ -8,6 +8,8 @@
|
||||||
var domListTypes = document.getElementById("listTypes");
|
var domListTypes = document.getElementById("listTypes");
|
||||||
var domSectFns = document.getElementById("sectFns");
|
var domSectFns = document.getElementById("sectFns");
|
||||||
var domListFns = document.getElementById("listFns");
|
var domListFns = document.getElementById("listFns");
|
||||||
|
var domSectFields = document.getElementById("sectFields");
|
||||||
|
var domListFields = document.getElementById("listFields");
|
||||||
var domFnProto = document.getElementById("fnProto");
|
var domFnProto = document.getElementById("fnProto");
|
||||||
var domFnProtoCode = document.getElementById("fnProtoCode");
|
var domFnProtoCode = document.getElementById("fnProtoCode");
|
||||||
var domFnDocs = document.getElementById("fnDocs");
|
var domFnDocs = document.getElementById("fnDocs");
|
||||||
|
@ -94,6 +96,7 @@
|
||||||
domSectPkgs.classList.add("hidden");
|
domSectPkgs.classList.add("hidden");
|
||||||
domSectTypes.classList.add("hidden");
|
domSectTypes.classList.add("hidden");
|
||||||
domSectFns.classList.add("hidden");
|
domSectFns.classList.add("hidden");
|
||||||
|
domSectFields.classList.add("hidden");
|
||||||
domSectSearchResults.classList.add("hidden");
|
domSectSearchResults.classList.add("hidden");
|
||||||
domSectSearchNoResults.classList.add("hidden");
|
domSectSearchNoResults.classList.add("hidden");
|
||||||
domSectInfo.classList.add("hidden");
|
domSectInfo.classList.add("hidden");
|
||||||
|
@ -545,6 +548,19 @@
|
||||||
}
|
}
|
||||||
domSectFns.classList.remove("hidden");
|
domSectFns.classList.remove("hidden");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (container.fields.length !== 0) {
|
||||||
|
resizeDomList(domListFields, container.fields.length, '<li></li>');
|
||||||
|
for (var i = 0; i < container.fields.length; i += 1) {
|
||||||
|
var liDom = domListFields.children[i];
|
||||||
|
var field = container.fields[i];
|
||||||
|
|
||||||
|
var protoHtml = escapeHtml(field.name) + ": ";
|
||||||
|
protoHtml += typeIndexName(field.type, true, true);
|
||||||
|
liDom.innerHTML = protoHtml;
|
||||||
|
}
|
||||||
|
domSectFields.classList.remove("hidden");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function operatorCompare(a, b) {
|
function operatorCompare(a, b) {
|
||||||
|
|
|
@ -732,6 +732,23 @@ static void anal_dump_pointer_attrs(AnalDumpCtx *ctx, ZigType *ty) {
|
||||||
anal_dump_type_ref(ctx, ty->data.pointer.child_type);
|
anal_dump_type_ref(ctx, ty->data.pointer.child_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void anal_dump_struct_field(AnalDumpCtx *ctx, const TypeStructField *struct_field) {
|
||||||
|
JsonWriter *jw = &ctx->jw;
|
||||||
|
|
||||||
|
jw_begin_object(jw);
|
||||||
|
|
||||||
|
jw_object_field(jw, "name");
|
||||||
|
jw_string(jw, buf_ptr(struct_field->name));
|
||||||
|
|
||||||
|
jw_object_field(jw, "type");
|
||||||
|
anal_dump_type_ref(ctx, struct_field->type_entry);
|
||||||
|
|
||||||
|
jw_object_field(jw, "src");
|
||||||
|
anal_dump_node_ref(ctx, struct_field->decl_node);
|
||||||
|
|
||||||
|
jw_end_object(jw);
|
||||||
|
}
|
||||||
|
|
||||||
static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {
|
static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {
|
||||||
JsonWriter *jw = &ctx->jw;
|
JsonWriter *jw = &ctx->jw;
|
||||||
jw_array_elem(jw);
|
jw_array_elem(jw);
|
||||||
|
@ -794,6 +811,17 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {
|
||||||
jw_end_array(jw);
|
jw_end_array(jw);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
jw_object_field(jw, "fields");
|
||||||
|
jw_begin_array(jw);
|
||||||
|
|
||||||
|
for(size_t i = 0; i < ty->data.structure.src_field_count; i += 1) {
|
||||||
|
jw_array_elem(jw);
|
||||||
|
anal_dump_struct_field(ctx, &ty->data.structure.fields[i]);
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue