authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-09 16:21:34-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-09 16:31:20-04:00
loge0ab685467567f6da02be865654a2c4dc5f8c3a9
tree1479ab33d0a24e39c2c8f14588e6153a1ae6a55d
parent8d5e3a2f332e1fb09da8b221888c87a6fbf18f8e
signaturelock-open Commit is signed but in an unrecognized format.

generated docs: more verbose fields

also prevent docs making hyperlinks for integer types

3 files changed, 32 insertions(+), 20 deletions(-)

lib/std/special/docs/index.html+2-4
...@@ -311,10 +311,8 @@...@@ -311,10 +311,8 @@
311 </div>311 </div>
312 <div id="sectFields" class="hidden">312 <div id="sectFields" class="hidden">
313 <h2>Fields</h2>313 <h2>Fields</h2>
314 <table>314 <div id="listFields">
315 <tbody id="listFields">315 </div>
316 </tbody>
317 </table>
318 </div>316 </div>
319 <div id="sectTypes" class="hidden">317 <div id="sectTypes" class="hidden">
320 <h2>Types</h2>318 <h2>Types</h2>
lib/std/special/docs/main.js+29-15
...@@ -50,6 +50,8 @@...@@ -50,6 +50,8 @@
50 var typeKindErrSetId;50 var typeKindErrSetId;
51 var typeKindErrUnionId;51 var typeKindErrUnionId;
52 var typeKindStructId;52 var typeKindStructId;
53 var typeKindUnionId;
54 var typeKindEnumId;
53 findTypeKinds();55 findTypeKinds();
5456
55 // for each package, is an array with packages to get to this one57 // for each package, is an array with packages to get to this one
...@@ -748,27 +750,20 @@...@@ -748,27 +750,20 @@
748 domSectFns.classList.remove("hidden");750 domSectFns.classList.remove("hidden");
749 }751 }
750752
751 if (container.fields.length !== 0) {753 if (container.fields != null && container.fields.length !== 0) {
752 resizeDomList(domListFields, container.fields.length,754 resizeDomList(domListFields, container.fields.length, '<div></div>');
753 '<tr><td></td><td></td><td></td></tr>');
754 for (var i = 0; i < container.fields.length; i += 1) {755 for (var i = 0; i < container.fields.length; i += 1) {
755 var field = container.fields[i];756 var field = container.fields[i];
756 var trDom = domListFields.children[i];757 var divDom = domListFields.children[i];
757758
758 var tdName = trDom.children[0];759 var html = '<pre>' + escapeHtml(field.name) + ": " +
759 var tdType = trDom.children[1];760 typeIndexName(field.type, true, true) + ',</pre>';
760 var tdDesc = trDom.children[2];
761
762 tdName.textContent = field.name;
763
764 tdType.innerHTML = typeIndexName(field.type, true, true);
765761
766 var docs = zigAnalysis.astNodes[field.src].docs;762 var docs = zigAnalysis.astNodes[field.src].docs;
767 if (docs != null) {763 if (docs != null) {
768 tdDesc.innerHTML = shortDescMarkdown(docs);764 html += markdown(docs);
769 } else {
770 tdDesc.textContent = "";
771 }765 }
766 divDom.innerHTML = html;
772 }767 }
773 domSectFields.classList.remove("hidden");768 domSectFields.classList.remove("hidden");
774 }769 }
...@@ -846,6 +841,10 @@...@@ -846,6 +841,10 @@
846 typeKindErrUnionId = i;841 typeKindErrUnionId = i;
847 } else if (zigAnalysis.typeKinds[i] === "Struct") {842 } else if (zigAnalysis.typeKinds[i] === "Struct") {
848 typeKindStructId = i;843 typeKindStructId = i;
844 } else if (zigAnalysis.typeKinds[i] === "Union") {
845 typeKindUnionId = i;
846 } else if (zigAnalysis.typeKinds[i] === "Enum") {
847 typeKindEnumId = i;
849 }848 }
850 }849 }
851 if (typeKindTypeId == null) {850 if (typeKindTypeId == null) {
...@@ -881,6 +880,12 @@...@@ -881,6 +880,12 @@
881 if (typeKindStructId == null) {880 if (typeKindStructId == null) {
882 throw new Error("No type kind 'Struct' found");881 throw new Error("No type kind 'Struct' found");
883 }882 }
883 if (typeKindUnionId == null) {
884 throw new Error("No type kind 'Union' found");
885 }
886 if (typeKindEnumId == null) {
887 throw new Error("No type kind 'Enum' found");
888 }
884 }889 }
885890
886 function findTypeTypeId() {891 function findTypeTypeId() {
...@@ -970,6 +975,13 @@...@@ -970,6 +975,13 @@
970 return list;975 return list;
971 }976 }
972977
978 function declCanRepresentTypeKind(typeKind) {
979 return typeKind === typeKindErrSetId ||
980 typeKind === typeKindStructId ||
981 typeKind === typeKindUnionId ||
982 typeKind === typeKindEnumId;
983 }
984
973 function computeCanonDeclPaths() {985 function computeCanonDeclPaths() {
974 var list = new Array(zigAnalysis.decls.length);986 var list = new Array(zigAnalysis.decls.length);
975 canonTypeDecls = new Array(zigAnalysis.types.length);987 canonTypeDecls = new Array(zigAnalysis.types.length);
...@@ -991,7 +1003,9 @@...@@ -991,7 +1003,9 @@
991 if (list[mainDeclIndex] != null) continue;1003 if (list[mainDeclIndex] != null) continue;
9921004
993 var decl = zigAnalysis.decls[mainDeclIndex];1005 var decl = zigAnalysis.decls[mainDeclIndex];
994 if (decl.type === typeTypeId) {1006 if (decl.type === typeTypeId &&
1007 declCanRepresentTypeKind(zigAnalysis.types[decl.value].kind))
1008 {
995 canonTypeDecls[decl.value] = mainDeclIndex;1009 canonTypeDecls[decl.value] = mainDeclIndex;
996 }1010 }
997 var declNames = item.declNames.concat([decl.name]);1011 var declNames = item.declNames.concat([decl.name]);
src/dump_analysis.cpp+1-1
...@@ -811,7 +811,7 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {...@@ -811,7 +811,7 @@ static void anal_dump_type(AnalDumpCtx *ctx, ZigType *ty) {
811 jw_end_array(jw);811 jw_end_array(jw);
812 }812 }
813813
814 {814 if (ty->data.structure.src_field_count != 0) {
815 jw_object_field(jw, "fields");815 jw_object_field(jw, "fields");
816 jw_begin_array(jw);816 jw_begin_array(jw);
817817