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 @@
289289 <pre id="fnProtoCode"></pre>
290290 </div>
291291 <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>
292303 <div id="fnDocs" class="hidden"></div>
293304 <div id="sectFnErrors" class="hidden">
294305 <h2>Errors</h2>
......@@ -297,10 +308,6 @@
297308 </div>
298309 <div id="tableFnErrors"><dl id="listFnErrors"></dl></div>
299310 </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>
304311 <div id="sectSearchResults" class="hidden">
305312 <h2>Search Results</h2>
306313 <ul id="listSearchResults"></ul>
lib/std/special/docs/main.js+20-5
......@@ -27,6 +27,7 @@
2727 var domFnErrorsAnyError = document.getElementById("fnErrorsAnyError");
2828 var domFnExamples = document.getElementById("fnExamples");
2929 var domFnNoExamples = document.getElementById("fnNoExamples");
30 var domDeclNoRef = document.getElementById("declNoRef");
3031 var domSearch = document.getElementById("search");
3132 var domSectSearchResults = document.getElementById("sectSearchResults");
3233 var domListSearchResults = document.getElementById("listSearchResults");
......@@ -112,6 +113,7 @@
112113 domSectFnErrors.classList.add("hidden");
113114 domFnExamples.classList.add("hidden");
114115 domFnNoExamples.classList.add("hidden");
116 domDeclNoRef.classList.add("hidden");
115117 domFnErrorsAnyError.classList.add("hidden");
116118 domTableFnErrors.classList.add("hidden");
117119 domSectGlobalVars.classList.add("hidden");
......@@ -160,7 +162,12 @@
160162 renderNav();
161163
162164 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') {
164171 return renderVar(lastDecl);
165172 } else if (lastDecl.kind === 'const' && lastDecl.type != null) {
166173 var typeObj = zigAnalysis.types[lastDecl.type];
......@@ -169,13 +176,21 @@
169176 } else {
170177 return renderValue(lastDecl);
171178 }
172 }
173 if (lastDecl.kind != null) {
179 } else {
174180 renderType(lastDecl);
175181 }
176 if (lastDecl.pubDecls != null) {
177 renderContainer(lastDecl);
182 }
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>';
178192 }
193 domFnDocs.classList.remove("hidden");
179194 }
180195
181196 function typeIsErrSet(typeIndex) {