authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-10 19:21:56-04:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2019-10-10 19:21:56-04:00
logbc393eefa1d80e7e85735d9ccbde13fb52144fcd
treeb02f9bf1052f8541882466f93e5084ccc435bf12
parentd15a71afc95f148966be2f5fd9f66b8396e8293d
signaturelock-open Commit is signed but in an unrecognized format.

generated docs: better rendering of unknown decls


2 files changed, 31 insertions(+), 9 deletions(-)

lib/std/special/docs/index.html+11-4
...@@ -289,6 +289,17 @@...@@ -289,6 +289,17 @@
289 <pre id="fnProtoCode"></pre>289 <pre id="fnProtoCode"></pre>
290 </div>290 </div>
291 <h1 id="hdrName" class="hidden"></h1>291 <h1 id="hdrName" class="hidden"></h1>
292 <div id="fnExamples" class="hidden"></div>
293 <div id="fnNoExamples" class="hidden">
294 <p>This function is not tested or referenced.</p>
295 </div>
296 <div id="declNoRef" class="hidden">
297 <p>
298 This declaration is not tested or referenced, and it has therefore not been included in
299 semantic analysis, which means the only documentation available is whatever is in the
300 doc comments.
301 </p>
302 </div>
292 <div id="fnDocs" class="hidden"></div>303 <div id="fnDocs" class="hidden"></div>
293 <div id="sectFnErrors" class="hidden">304 <div id="sectFnErrors" class="hidden">
294 <h2>Errors</h2>305 <h2>Errors</h2>
...@@ -297,10 +308,6 @@...@@ -297,10 +308,6 @@
297 </div>308 </div>
298 <div id="tableFnErrors"><dl id="listFnErrors"></dl></div>309 <div id="tableFnErrors"><dl id="listFnErrors"></dl></div>
299 </div>310 </div>
300 <div id="fnExamples" class="hidden"></div>
301 <div id="fnNoExamples" class="hidden">
302 <p>This function is not tested or referenced.</p>
303 </div>
304 <div id="sectSearchResults" class="hidden">311 <div id="sectSearchResults" class="hidden">
305 <h2>Search Results</h2>312 <h2>Search Results</h2>
306 <ul id="listSearchResults"></ul>313 <ul id="listSearchResults"></ul>
lib/std/special/docs/main.js+20-5
...@@ -27,6 +27,7 @@...@@ -27,6 +27,7 @@
27 var domFnErrorsAnyError = document.getElementById("fnErrorsAnyError");27 var domFnErrorsAnyError = document.getElementById("fnErrorsAnyError");
28 var domFnExamples = document.getElementById("fnExamples");28 var domFnExamples = document.getElementById("fnExamples");
29 var domFnNoExamples = document.getElementById("fnNoExamples");29 var domFnNoExamples = document.getElementById("fnNoExamples");
30 var domDeclNoRef = document.getElementById("declNoRef");
30 var domSearch = document.getElementById("search");31 var domSearch = document.getElementById("search");
31 var domSectSearchResults = document.getElementById("sectSearchResults");32 var domSectSearchResults = document.getElementById("sectSearchResults");
32 var domListSearchResults = document.getElementById("listSearchResults");33 var domListSearchResults = document.getElementById("listSearchResults");
...@@ -112,6 +113,7 @@...@@ -112,6 +113,7 @@
112 domSectFnErrors.classList.add("hidden");113 domSectFnErrors.classList.add("hidden");
113 domFnExamples.classList.add("hidden");114 domFnExamples.classList.add("hidden");
114 domFnNoExamples.classList.add("hidden");115 domFnNoExamples.classList.add("hidden");
116 domDeclNoRef.classList.add("hidden");
115 domFnErrorsAnyError.classList.add("hidden");117 domFnErrorsAnyError.classList.add("hidden");
116 domTableFnErrors.classList.add("hidden");118 domTableFnErrors.classList.add("hidden");
117 domSectGlobalVars.classList.add("hidden");119 domSectGlobalVars.classList.add("hidden");
...@@ -160,7 +162,12 @@...@@ -160,7 +162,12 @@
160 renderNav();162 renderNav();
161163
162 var lastDecl = curNav.declObjs[curNav.declObjs.length - 1];164 var lastDecl = curNav.declObjs[curNav.declObjs.length - 1];
163 if (lastDecl.kind === 'var') {165 if (lastDecl.pubDecls != null) {
166 renderContainer(lastDecl);
167 }
168 if (lastDecl.kind == null) {
169 return renderUnknownDecl(lastDecl);
170 } else if (lastDecl.kind === 'var') {
164 return renderVar(lastDecl);171 return renderVar(lastDecl);
165 } else if (lastDecl.kind === 'const' && lastDecl.type != null) {172 } else if (lastDecl.kind === 'const' && lastDecl.type != null) {
166 var typeObj = zigAnalysis.types[lastDecl.type];173 var typeObj = zigAnalysis.types[lastDecl.type];
...@@ -169,13 +176,21 @@...@@ -169,13 +176,21 @@
169 } else {176 } else {
170 return renderValue(lastDecl);177 return renderValue(lastDecl);
171 }178 }
172 }179 } else {
173 if (lastDecl.kind != null) {
174 renderType(lastDecl);180 renderType(lastDecl);
175 }181 }
176 if (lastDecl.pubDecls != null) {182 }
177 renderContainer(lastDecl);183
184 function renderUnknownDecl(decl) {
185 domDeclNoRef.classList.remove("hidden");
186
187 var docs = zigAnalysis.astNodes[decl.src].docs;
188 if (docs != null) {
189 domFnDocs.innerHTML = markdown(docs);
190 } else {
191 domFnDocs.innerHTML = '<p>There are no doc comments for this declaration.</p>';
178 }192 }
193 domFnDocs.classList.remove("hidden");
179 }194 }
180195
181 function typeIsErrSet(typeIndex) {196 function typeIsErrSet(typeIndex) {