Commit 5e765356a7

Andrew Kelley <andrew@ziglang.org>
2019-10-09 05:15:47
generated docs: global vars in a table
1 parent ca3250a
Changed files (2)
lib
std
special
lib/std/special/docs/index.html
@@ -22,6 +22,10 @@
         padding:1em;
         overflow-x: auto;
       }
+      code {
+        font-family:"Source Code Pro",monospace;
+        font-size:1em;
+      }
       nav {
         width: 10em;
         position: fixed;
@@ -154,6 +158,12 @@
         vertical-align: top;
       }
 
+      #sectGlobalVars td {
+        vertical-align: top;
+        margin: 0;
+        padding: 0.5em;
+      }
+
       .tok-kw {
           color: #333;
           font-weight: bold;
@@ -310,8 +320,10 @@
     </div>
     <div id="sectGlobalVars" class="hidden">
       <h2>Global Variables</h2>
-      <div id="listGlobalVars">
-      </div>
+      <table>
+        <tbody id="listGlobalVars">
+        </tbody>
+      </table>
     </div>
     <div id="sectFns" class="hidden">
       <h2>Functions</h2>
lib/std/special/docs/main.js
@@ -633,22 +633,27 @@
         }
 
         if (varsList.length !== 0) {
-            resizeDomList(domListGlobalVars, varsList.length, '<div></div>');
+            resizeDomList(domListGlobalVars, varsList.length, '<tr><td></td><td></td><td></td></tr>');
             for (var i = 0; i < varsList.length; i += 1) {
                 var decl = varsList[i];
-                var divDom = domListGlobalVars.children[i];
+                var trDom = domListGlobalVars.children[i];
                 var innerHtml = "";
 
-                innerHtml += '<pre><span class="tok-kw">pub</span> <span class="tok-kw">var</span> <a href="' +
-                    navLinkDecl(decl.name) + '">' + escapeHtml(decl.name) + '</a>: ' +
-                    typeIndexName(decl.type, true, true) + '</pre>';
+                var tdName = trDom.children[0];
+                var tdType = trDom.children[1];
+                var tdDesc = trDom.children[2];
+
+                tdName.innerHTML = '<a href="' +
+                    navLinkDecl(decl.name) + '">' + escapeHtml(decl.name) + '</a>';
+
+                tdType.innerHTML = typeIndexName(decl.type, true, true);
 
                 var docs = zigAnalysis.astNodes[decl.src].docs;
                 if (docs != null) {
-                    innerHtml += markdown(docs);
+                    tdDesc.innerHTML = markdown(docs);
+                } else {
+                    tdDesc.textContent = "";
                 }
-
-                divDom.innerHTML = innerHtml;
             }
             domSectGlobalVars.classList.remove("hidden");
         }