Autodoc: report errors in user interface

Also includes panics by virtue of the previous commit, checking one item off #19249.
This commit is contained in:
Ian Johnson 2025-02-15 16:57:04 -05:00
parent b745a96d20
commit 75ccdcc356
2 changed files with 36 additions and 0 deletions

View file

@ -6,6 +6,9 @@
<title>Zig Documentation</title>
<link rel="icon" href="data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCAxNTMgMTQwIj48ZyBmaWxsPSIjRjdBNDFEIj48Zz48cG9seWdvbiBwb2ludHM9IjQ2LDIyIDI4LDQ0IDE5LDMwIi8+PHBvbHlnb24gcG9pbnRzPSI0NiwyMiAzMywzMyAyOCw0NCAyMiw0NCAyMiw5NSAzMSw5NSAyMCwxMDAgMTIsMTE3IDAsMTE3IDAsMjIiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyIvPjxwb2x5Z29uIHBvaW50cz0iMzEsOTUgMTIsMTE3IDQsMTA2Ii8+PC9nPjxnPjxwb2x5Z29uIHBvaW50cz0iNTYsMjIgNjIsMzYgMzcsNDQiLz48cG9seWdvbiBwb2ludHM9IjU2LDIyIDExMSwyMiAxMTEsNDQgMzcsNDQgNTYsMzIiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyIvPjxwb2x5Z29uIHBvaW50cz0iMTE2LDk1IDk3LDExNyA5MCwxMDQiLz48cG9seWdvbiBwb2ludHM9IjExNiw5NSAxMDAsMTA0IDk3LDExNyA0MiwxMTcgNDIsOTUiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyIvPjxwb2x5Z29uIHBvaW50cz0iMTUwLDAgNTIsMTE3IDMsMTQwIDEwMSwyMiIvPjwvZz48Zz48cG9seWdvbiBwb2ludHM9IjE0MSwyMiAxNDAsNDAgMTIyLDQ1Ii8+PHBvbHlnb24gcG9pbnRzPSIxNTMsMjIgMTUzLDExNyAxMDYsMTE3IDEyMCwxMDUgMTI1LDk1IDEzMSw5NSAxMzEsNDUgMTIyLDQ1IDEzMiwzNiAxNDEsMjIiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyIvPjxwb2x5Z29uIHBvaW50cz0iMTI1LDk1IDEzMCwxMTAgMTA2LDExNyIvPjwvZz48L2c+PC9zdmc+">
<style type="text/css">
*, *::before, *::after {
box-sizing: border-box;
}
body {
font-family: system-ui, -apple-system, Roboto, "Segoe UI", sans-serif;
color: #000000;
@ -157,6 +160,23 @@
cursor: default;
}
#errors {
background-color: #faa;
position: fixed;
left: 0;
bottom: 0;
width: 100%;
max-height: min(20em, 50vh);
padding: 0.5em;
overflow: auto;
}
#errors h1 {
font-size: 1.5em;
}
#errors pre {
background-color: #fcc;
}
#listSearchResults li.selected {
background-color: #93e196;
}
@ -252,6 +272,14 @@
#listSearchResults li.selected a {
color: #fff;
}
#errors {
background-color: #800;
color: #fff;
}
#errors pre {
background-color: #a00;
color: #fff;
}
dl > div {
border-color: #373737;
}
@ -414,6 +442,10 @@
<dl><dt><kbd></kbd></dt><dd>Move down in search results</dd></dl>
<dl><dt><kbd></kbd></dt><dd>Go to active search result</dd></dl>
</div>
<div id="errors" class="hidden">
<h1>Errors</h1>
<pre id="errorsText"></pre>
</div>
<script src="main.js"></script>
</body>
</html>

View file

@ -53,6 +53,8 @@
const domStatus = document.getElementById("status");
const domTableFnErrors = document.getElementById("tableFnErrors");
const domTldDocs = document.getElementById("tldDocs");
const domErrors = document.getElementById("errors");
const domErrorsText = document.getElementById("errorsText");
var searchTimer = null;
@ -94,6 +96,8 @@
switch (level) {
case LOG_err:
console.error(msg);
domErrorsText.textContent += msg + "\n";
domErrors.classList.remove("hidden");
break;
case LOG_warn:
console.warn(msg);