generated docs: more verbose fields

also prevent docs making hyperlinks for integer types
This commit is contained in:
Andrew Kelley 2019-10-09 16:21:34 -04:00
parent 8d5e3a2f33
commit e0ab685467
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
3 changed files with 32 additions and 20 deletions

View File

@ -311,10 +311,8 @@
</div>
<div id="sectFields" class="hidden">
<h2>Fields</h2>
<table>
<tbody id="listFields">
</tbody>
</table>
<div id="listFields">
</div>
</div>
<div id="sectTypes" class="hidden">
<h2>Types</h2>

View File

@ -50,6 +50,8 @@
var typeKindErrSetId;
var typeKindErrUnionId;
var typeKindStructId;
var typeKindUnionId;
var typeKindEnumId;
findTypeKinds();
// for each package, is an array with packages to get to this one
@ -748,27 +750,20 @@
domSectFns.classList.remove("hidden");
}
if (container.fields.length !== 0) {
resizeDomList(domListFields, container.fields.length,
'<tr><td></td><td></td><td></td></tr>');
if (container.fields != null && container.fields.length !== 0) {
resizeDomList(domListFields, container.fields.length, '<div></div>');
for (var i = 0; i < container.fields.length; i += 1) {
var field = container.fields[i];
var trDom = domListFields.children[i];
var divDom = domListFields.children[i];
var tdName = trDom.children[0];
var tdType = trDom.children[1];
var tdDesc = trDom.children[2];
tdName.textContent = field.name;
tdType.innerHTML = typeIndexName(field.type, true, true);
var html = '<pre>' + escapeHtml(field.name) + ": " +
typeIndexName(field.type, true, true) + ',</pre>';
var docs = zigAnalysis.astNodes[field.src].docs;
if (docs != null) {
tdDesc.innerHTML = shortDescMarkdown(docs);
} else {
tdDesc.textContent = "";
html += markdown(docs);
}
divDom.innerHTML = html;
}
domSectFields.classList.remove("hidden");
}
@ -846,6 +841,10 @@
typeKindErrUnionId = i;
} else if (zigAnalysis.typeKinds[i] === "Struct") {
typeKindStructId = i;
} else if (zigAnalysis.typeKinds[i] === "Union") {
typeKindUnionId = i;
} else if (zigAnalysis.typeKinds[i] === "Enum") {
typeKindEnumId = i;
}
}
if (typeKindTypeId == null) {
@ -881,6 +880,12 @@
if (typeKindStructId == null) {
throw new Error("No type kind 'Struct' found");
}
if (typeKindUnionId == null) {
throw new Error("No type kind 'Union' found");
}
if (typeKindEnumId == null) {
throw new Error("No type kind 'Enum' found");
}
}
function findTypeTypeId() {
@ -970,6 +975,13 @@
return list;
}
function declCanRepresentTypeKind(typeKind) {
return typeKind === typeKindErrSetId ||
typeKind === typeKindStructId ||
typeKind === typeKindUnionId ||
typeKind === typeKindEnumId;
}
function computeCanonDeclPaths() {
var list = new Array(zigAnalysis.decls.length);
canonTypeDecls = new Array(zigAnalysis.types.length);
@ -991,7 +1003,9 @@
if (list[mainDeclIndex] != null) continue;
var decl = zigAnalysis.decls[mainDeclIndex];
if (decl.type === typeTypeId) {
if (decl.type === typeTypeId &&
declCanRepresentTypeKind(zigAnalysis.types[decl.value].kind))
{
canonTypeDecls[decl.value] = mainDeclIndex;
}
var declNames = item.declNames.concat([decl.name]);

View File

@ -811,7 +811,7 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {
jw_end_array(jw);
}
{
if (ty->data.structure.src_field_count != 0) {
jw_object_field(jw, "fields");
jw_begin_array(jw);