generated docs: render functions

This commit is contained in:
Andrew Kelley 2019-10-05 16:18:26 -04:00
parent a82c6453c1
commit 19c2474b34
No known key found for this signature in database
GPG Key ID: 7C5F548F728501A9
2 changed files with 37 additions and 2 deletions

View File

@ -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">

View File

@ -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) {