aboutsummaryrefslogtreecommitdiff
path: root/lib/std
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2019-10-05 16:18:26 -0400
committerAndrew Kelley <andrew@ziglang.org>2019-10-05 16:38:42 -0400
commit19c2474b342aa8f4e6f3dc846f3475016d713329 (patch)
treef4ae2ecfaed4ab6bcf6a5a9dd7f470238707cb9f /lib/std
parenta82c6453c1553ce89ec24803d4192030639d79ab (diff)
downloadzig-19c2474b342aa8f4e6f3dc846f3475016d713329.tar.gz
zig-19c2474b342aa8f4e6f3dc846f3475016d713329.zip
generated docs: render functions
Diffstat (limited to 'lib/std')
-rw-r--r--lib/std/special/doc/index.html14
-rw-r--r--lib/std/special/doc/main.js25
2 files changed, 37 insertions, 2 deletions
diff --git a/lib/std/special/doc/index.html b/lib/std/special/doc/index.html
index 4fadc35e18..db80ec9550 100644
--- a/lib/std/special/doc/index.html
+++ b/lib/std/special/doc/index.html
@@ -14,6 +14,12 @@
a {
color: #2A6286;
}
+ pre{
+ font-family:"Source Code Pro",monospace;
+ font-size:1em;
+ background-color:#F5F5F5;
+ padding:1em;
+ }
#listNav {
list-style-type: none;
margin: 0;
@@ -46,12 +52,18 @@
a {
color: #88f;
}
+ pre{
+ background-color:#2A2A2A;
+ }
}
</style>
</head>
<body>
- <div id="sectNav"><ul id="listNav"></ul></div>
<p id="status">Loading...</p>
+ <div id="sectNav" class="hidden"><ul id="listNav"></ul></div>
+ <div id="fnProto" class="hidden">
+ <pre id="fnProtoCode"></pre>
+ </div>
<div id="sectPkgs" class="hidden">
<h2>Packages</h2>
<ul id="listPkgs">
diff --git a/lib/std/special/doc/main.js b/lib/std/special/doc/main.js
index 4de26fe4bb..e39173034f 100644
--- a/lib/std/special/doc/main.js
+++ b/lib/std/special/doc/main.js
@@ -8,6 +8,8 @@
var domListTypes = document.getElementById("listTypes");
var domSectFns = document.getElementById("sectFns");
var domListFns = document.getElementById("listFns");
+ var domFnProto = document.getElementById("fnProto");
+ var domFnProtoCode = document.getElementById("fnProtoCode");
var typeKindTypeId;
var typeKindFnId;
@@ -47,6 +49,7 @@
function render() {
domStatus.classList.add("hidden");
+ domFnProto.classList.add("hidden");
renderTitle();
@@ -89,11 +92,28 @@
var lastDecl = curNav.declObjs[curNav.declObjs.length - 1];
if (lastDecl.decls != null) {
return renderContainer(lastDecl);
- } else {
+ } else if (lastDecl.type != null) {
+ var typeObj = zigAnalysis.types[lastDecl.type];
+ if (typeObj.kind === typeKindFnId) {
+ return renderFn(lastDecl);
+ }
throw new Error("docs for this decl which is not a container");
+ } else {
+ throw new Error("docs for this decl which is a type");
}
}
+ function renderFn(fnDecl) {
+ domSectPkgs.classList.add("hidden");
+ domSectTypes.classList.add("hidden");
+ domSectFns.classList.add("hidden");
+
+ var typeObj = zigAnalysis.types[fnDecl.type];
+ domFnProtoCode.textContent = "fn " + fnDecl.name + typeObj.name.substring(2);
+
+ domFnProto.classList.remove("hidden");
+ }
+
function renderNav() {
var len = curNav.pkgNames.length + curNav.declNames.length;
resizeDomList(domListNav, len, '<li><a href="#"></a></li>');
@@ -126,6 +146,8 @@
aDom.classList.remove("active");
}
}
+
+ domSectNav.classList.remove("hidden");
}
function render404() {
@@ -134,6 +156,7 @@
domSectPkgs.classList.add("hidden");
domSectTypes.classList.add("hidden");
domSectFns.classList.add("hidden");
+ domFnProto.classList.add("hidden");
}
function renderPkgList(pkg) {