commit 6948d7fce7d39b97d34689d2ba297132255e3f54 (tree)
parent dbb1eaefb50572d3c11129925f3e0fdedf758723
Author: Andrew Kelley <andrew@ziglang.org>
Date: Sat, 19 Oct 2019 16:43:39 -0400
Merge pull request #3429 from Rocknest/docs-local
Design suggestion for generated docs
Diffstat:
1 file changed, 394 insertions(+), 216 deletions(-)
diff --git a/lib/std/special/docs/index.html b/lib/std/special/docs/index.html
@@ -5,62 +5,228 @@
<title>Documentation - Zig</title>
<link rel="icon" href="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAgklEQVR4AWMYWuD7EllJIM4G4g4g5oIJ/odhOJ8wToOxSTXgNxDHoeiBMfA4+wGShjyYOCkG/IGqWQziEzYAoUAeiF9D5U+DxEg14DRU7jWIT5IBIOdCxf+A+CQZAAoopEB7QJwBCBwHiip8UYmRdrAlDpIMgApwQZNnNii5Dq0MBgCxxycBnwEd+wAAAABJRU5ErkJggg==">
<style type="text/css">
- body {
- font-family: system-ui, -apple-system, Roboto, "Segoe UI", sans-serif;
- max-width: 60em;
+ :root {
+ font-size: 1em;
+ --ui: -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji";
+ --mono: "Source Code Pro", monospace;
+ --tx-color: #141414;
+ --bg-color: #ffffff;
+ --link-color: #2A6286;
+ --sidebar-sh-color: rgba(0, 0, 0, 0.09);
+ --sidebar-pkg-bg-color: #f1f1f1;
+ --sidebar-pkglnk-tx-color: #141414;
+ --sidebar-pkglnk-tx-color-hover: #fff;
+ --sidebar-pkglnk-tx-color-active: #000;
+ --sidebar-pkglnk-bg-color: transparent;
+ --sidebar-pkglnk-bg-color-hover: #555;
+ --sidebar-pkglnk-bg-color-active: #FFBB4D;
+ --search-bg-color: #f3f3f3;
+ --search-bg-color-focus: #ffffff;
+ --search-sh-color: rgba(0, 0, 0, 0.18);
+ --help-sh-color: rgba(0, 0, 0, 0.75);
}
+
+ a {
+ text-decoration: none;
+ }
+
+ a:hover {
+ text-decoration: underline;
+ }
+
.hidden {
display: none;
}
- a {
- color: #2A6286;
+
+ /* layout */
+ .canvas {
+ width: 100vw;
+ height: 100vh;
+ overflow: hidden;
+ margin: 0;
+ padding: 0;
+ font-family: var(--ui);
+ color: var(--tx-color);
+ background-color: var(--bg-color);
}
- pre{
- font-family:"Source Code Pro",monospace;
- font-size:1em;
- background-color:#F5F5F5;
- padding:1em;
- overflow-x: auto;
+
+ .flex-main {
+ display: flex;
+ width: 100%;
+ height: 100%;
+ justify-content: center;
+
+ z-index: 100;
}
- code {
- font-family:"Source Code Pro",monospace;
- font-size:1em;
+
+ .flex-filler {
+ flex-grow: 1;
+ flex-shrink: 1;
}
- nav {
- width: 10em;
- position: fixed;
- left: 0;
- top: 0;
- height: 100vh;
+
+ .flex-left {
+ width: 12rem;
+ max-width: 15vw;
+ min-width: 9.5rem;
overflow: auto;
+ overflow-wrap: break-word;
+ flex-shrink: 0;
+ flex-grow: 0;
+
+ z-index: 300;
}
- nav h2 {
- font-size: 1.2em;
- text-decoration: underline;
- margin: 0;
- padding: 0.5em 0;
- text-align: center;
+
+ .flex-right {
+ display: flex;
+ overflow: auto;
+ flex-grow: 1;
+ flex-shrink: 1;
+
+ z-index: 200;
+ }
+
+ .flex-right > .wrap {
+ width: 60rem;
+ max-width: 85vw;
+ flex-shrink: 1;
+ }
+
+ .help-modal {
+ z-index: 400;
+ }
+
+ /* sidebar */
+ .sidebar {
+ font-size: 1rem;
+ background-color: var(--bg-color);
+ box-shadow: 0 0 1rem var(--sidebar-sh-color);
+ }
+
+ .sidebar .logo {
+ padding: 1rem 0.35rem 0.35rem 0.35rem;
+ }
+
+ .sidebar .logo > svg {
+ display: block;
+ overflow: visible;
+ }
+
+ .sidebar h2 {
+ margin: 0.5rem;
+ padding: 0;
+ font-size: 1.2rem;
}
- nav p {
+
+ .sidebar h2 > span {
+ border-bottom: 0.125rem dotted var(--tx-color);
+ }
+
+ .sidebar .packages {
+ list-style-type: none;
margin: 0;
padding: 0;
- text-align: center;
+ background-color: var(--sidebar-pkg-bg-color);
+ }
+
+ .sidebar .packages > li > a {
+ display: block;
+ padding: 0.5rem 1rem;
+ color: var(--sidebar-pkglnk-tx-color);
+ background-color: var(--sidebar-pkglnk-bg-color);
+ text-decoration: none;
+ }
+
+ .sidebar .packages > li > a:hover {
+ color: var(--sidebar-pkglnk-tx-color-hover);
+ background-color: var(--sidebar-pkglnk-bg-color-hover);
+ }
+
+ .sidebar .packages > li > a.active {
+ color: var(--sidebar-pkglnk-tx-color-active);
+ background-color: var(--sidebar-pkglnk-bg-color-active);
+ }
+
+ .sidebar p.str {
+ margin: 0.5rem;
+ font-family: var(--mono);
+ }
+
+ /* docs section */
+ .docs {
+ padding: 1rem 0.7rem 2.4rem 1.4rem;
+ font-size: 1rem;
+ background-color: var(--bg-color);
+ overflow-wrap: break-word;
+ }
+
+ .docs .search {
+ width: 100%;
+ margin-bottom: 0.8rem;
+ padding: 0.5rem;
+ font-size: 1rem;
+ font-family: var(--ui);
+ color: var(--tx-color);
+ background-color: var(--search-bg-color);
+ border-top: 0;
+ border-left: 0;
+ border-right: 0;
+ border-bottom-width: 0.125rem;
+ border-bottom-style: solid;
+ border-bottom-color: var(--tx-color);
+ outline: none;
+ transition: border-bottom-color 0.35s, background 0.35s, box-shadow 0.35s;
+ }
+
+ .docs .search:focus {
+ background-color: var(--search-bg-color-focus);
+ border-bottom-color: #ffbb4d;
+ box-shadow: 0 0.3em 1em 0.125em var(--search-sh-color);
+ }
+
+ .docs .search::placeholder {
+ font-size: 1rem;
+ font-family: var(--ui);
+ color: var(--tx-color);
+ opacity: 0.5;
+ }
+
+ .docs a {
+ color: var(--link-color);
+ }
+
+ .docs p {
+ margin: 0.8rem 0;
+ }
+
+ .docs pre {
+ font-family: var(--mono);
+ font-size:1em;
+ background-color:#F5F5F5;
+ padding:1em;
+ overflow-x: auto;
}
- section {
- margin-left: 10em;
+
+ .docs code {
+ font-family: var(--mono);
+ font-size: 1em;
}
- section h1 {
- border-bottom: 1px dashed;
+
+ .docs h1 {
+ font-size: 1.4em;
+ margin: 0.8em 0;
+ padding: 0;
+ border-bottom: 0.0625rem dashed;
}
- section h2 {
+
+ .docs h2 {
font-size: 1.3em;
margin: 0.5em 0;
padding: 0;
- border-bottom: 1px solid;
+ border-bottom: 0.0625rem solid;
}
#listNav {
list-style-type: none;
- margin: 0.5em 0 0 0;
+ margin: 0;
padding: 0;
overflow: hidden;
background-color: #f1f1f1;
@@ -84,26 +250,14 @@
color: #000;
}
- #listPkgs {
- list-style-type: none;
- margin: 0;
- padding: 0;
- background-color: #f1f1f1;
- }
- #listPkgs li a {
- display: block;
- color: #000;
- padding: 0.5em 1em;
- text-decoration: none;
- }
- #listPkgs li a:hover {
- background-color: #555;
- color: #fff;
+ #listSearchResults li.selected {
+ background-color: #93e196;
}
- #listPkgs li a.active {
- background-color: #FFBB4D;
- color: #000;
+
+ #tableFnErrors dt {
+ font-weight: bold;
}
+
#listFnExamples {
list-style-type: none;
margin: 0;
@@ -114,67 +268,76 @@
white-space: nowrap;
overflow-x: auto;
}
- #logo {
- width: 8em;
- padding: 0.5em 1em;
+
+ .docs td {
+ vertical-align: top;
+ margin: 0;
+ padding: 0.5em;
+ max-width: 27em;
+ text-overflow: ellipsis;
+ overflow-x: hidden;
}
-
- #search {
+
+ /* help dialog */
+ .help-modal {
+ display: flex;
width: 100%;
- }
-
- #helpDialog {
- width: 21em;
- height: 19em;
+ height: 100%;
position: fixed;
top: 0;
left: 0;
- background-color: #333;
+ justify-content: center;
+ align-items: center;
+ background-color: rgba(0, 0, 0, 0.15);
+ backdrop-filter: blur(0.3em);
+ }
+
+ .help-modal > .dialog {
+ max-width: 97vw;
+ max-height: 97vh;
+ overflow: auto;
+ font-size: 1rem;
color: #fff;
- border: 1px solid #fff;
+ background-color: #333;
+ border: 0.125rem solid #000;
+ box-shadow: 0 0.5rem 2.5rem 0.3rem var(--help-sh-color);
}
- #helpDialog h1 {
- text-align: center;
+
+ .help-modal h1 {
+ margin: 0.75em 2.5em 1em 2.5em;
font-size: 1.5em;
+ text-align: center;
}
- #helpDialog dt, #helpDialog dd {
+
+ .help-modal dt, .help-modal dd {
display: inline;
margin: 0 0.2em;
}
- kbd {
+
+ .help-modal dl {
+ margin-left: 0.5em;
+ margin-right: 0.5em;
+ }
+
+ .help-modal kbd {
+ display: inline-block;
+ padding: 0.3em 0.2em;
+ font-size: 1.2em;
+ font-size: var(--mono);
+ line-height: 0.8em;
+ vertical-align: middle;
color: #000;
background-color: #fafbfc;
border-color: #d1d5da;
border-bottom-color: #c6cbd1;
+ border: solid 0.0625em;
+ border-radius: 0.1875em;
box-shadow-color: #c6cbd1;
- display: inline-block;
- padding: 0.3em 0.2em;
- font: 1.2em monospace;
- line-height: 0.8em;
- vertical-align: middle;
- border: solid 1px;
- border-radius: 3px;
- box-shadow: inset 0 -1px 0;
+ box-shadow: inset 0 -0.0625em 0;
cursor: default;
}
-
- #listSearchResults li.selected {
- background-color: #93e196;
- }
-
- #tableFnErrors dt {
- font-weight: bold;
- }
-
- td {
- vertical-align: top;
- margin: 0;
- padding: 0.5em;
- max-width: 27em;
- text-overflow: ellipsis;
- overflow-x: hidden;
- }
-
+
+ /* tokens */
.tok-kw {
color: #333;
font-weight: bold;
@@ -203,16 +366,29 @@
color: #458;
font-weight: bold;
}
-
+
+ /* dark mode */
@media (prefers-color-scheme: dark) {
- body{
- background-color: #111;
- color: #bbb;
+
+ :root {
+ --tx-color: #bbb;
+ --bg-color: #111;
+ --link-color: #88f;
+ --sidebar-sh-color: rgba(128, 128, 128, 0.09);
+ --sidebar-pkg-bg-color: #333;
+ --sidebar-pkglnk-tx-color: #fff;
+ --sidebar-pkglnk-tx-color-hover: #fff;
+ --sidebar-pkglnk-tx-color-active: #000;
+ --sidebar-pkglnk-bg-color: transparent;
+ --sidebar-pkglnk-bg-color-hover: #555;
+ --sidebar-pkglnk-bg-color-active: #FFBB4D;
+ --search-bg-color: #3c3c3c;
+ --search-bg-color-focus: #000;
+ --search-sh-color: rgba(255, 255, 255, 0.28);
+ --help-sh-color: rgba(142, 142, 142, 0.5);
}
- a {
- color: #88f;
- }
- pre{
+
+ .docs pre {
background-color:#2A2A2A;
}
#listNav {
@@ -229,20 +405,6 @@
background-color: #FFBB4D;
color: #000;
}
- #listPkgs {
- background-color: #333;
- }
- #listPkgs li a {
- color: #fff;
- }
- #listPkgs li a:hover {
- background-color: #555;
- color: #fff;
- }
- #listPkgs li a.active {
- background-color: #FFBB4D;
- color: #000;
- }
#listSearchResults li.selected {
background-color: #000;
}
@@ -273,112 +435,128 @@
.tok-type {
color: #68f;
}
+
}
</style>
</head>
- <body>
- <nav>
- <img alt="ZIG" id="logo" src="data:image/svg+xml;base64,PHN2ZyB2ZXJzaW9uPSIxLjEiIHZpZXdCb3g9IjAgMCAxNTAgMTAwIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPjxnIGZpbGw9IiNmN2E0MWQiPjxwYXRoIGQ9Im0wIDEwdjgwaDE5bDYtMTAgMTItMTBoLTE3di00MGgxNXYtMjB6bTQwIDB2MjBoNjJ2LTIwem05MSAwLTYgMTAtMTIgMTBoMTd2NDBoLTE1djIwaDM1di04MHptLTgzIDYwdjIwaDYydi0yMHoiIHNoYXBlLXJlbmRlcmluZz0iY3Jpc3BFZGdlcyIvPjxwYXRoIGQ9Im0zNyA3MC0xOCAyMHYtMTV6Ii8+PHBhdGggZD0ibTExMyAzMCAxOC0yMHYxNXoiLz48cGF0aCBkPSJtOTYuOTggMTAuNjMgMzYuMjgtMTAuNC04MC4yOSA4OS4xNy0zNi4yOCAxMC40eiIvPjwvZz48L3N2Zz4K"></img>
- <div id="sectPkgs" class="hidden">
- <h2>Packages</h2>
- <ul id="listPkgs">
- </ul>
- </div>
- <div id="sectInfo" class="hidden">
- <h2>Zig Version</h2>
- <p id="tdZigVer"></p>
- <h2>Target</h2>
- <p id="tdTarget"></p>
+ <body class="canvas">
+ <div class="flex-main">
+ <div class="flex-filler"></div>
+ <div class="flex-left sidebar">
+ <nav>
+ <div class="logo">
+ <svg version="1.1" viewBox="0 0 150 80" xmlns="http://www.w3.org/2000/svg">
+ <g fill="#f7a41d">
+ <path d="m0,-0.08899l0,80l19,0l6,-10l12,-10l-17,0l0,-40l15,0l0,-20l-35,0zm40,0l0,20l62,0l0,-20l-62,0zm91,0l-6,10l-12,10l17,0l0,40l-15,0l0,20l35,0l0,-80l-19,0zm-83,60l0,20l62,0l0,-20l-62,0z" shape-rendering="crispEdges"></path>
+ <path d="m37,59.91101l-18,20l0,-15l18,-5z"></path>
+ <path d="m113,19.91101l18,-20l0,15l-18,5z"></path>
+ <path d="m96.98,0.54101l36.28,-10.4l-80.29,89.17l-36.28,10.4l80.29,-89.17z"></path>
+ </g>
+ </svg>
+ </div>
+ <div id="sectPkgs" class="hidden">
+ <h2><span>Packages</span></h2>
+ <ul id="listPkgs" class="packages"></ul>
+ </div>
+ <div id="sectInfo" class="hidden">
+ <h2><span>Zig Version</span></h2>
+ <p class="str" id="tdZigVer"></p>
+ <h2><span>Target</span></h2>
+ <p class="str" id="tdTarget"></p>
+ </div>
+ </nav>
</div>
- </nav>
- <section>
- <input type="search" id="search" autocomplete="off" spellcheck="false" placeholder="`s` to search, `?` to see more options">
- <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>
- <h1 id="hdrName" class="hidden"></h1>
- <div id="fnNoExamples" class="hidden">
- <p>This function is not tested or referenced.</p>
- </div>
- <div id="declNoRef" class="hidden">
- <p>
- This declaration is not tested or referenced, and it has therefore not been included in
- semantic analysis, which means the only documentation available is whatever is in the
- doc comments.
- </p>
- </div>
- <div id="fnDocs" class="hidden"></div>
- <div id="sectFnErrors" class="hidden">
- <h2>Errors</h2>
- <div id="fnErrorsAnyError">
- <p><span class="tok-type">anyerror</span> means the error set is known only at runtime.</p>
- </div>
- <div id="tableFnErrors"><dl id="listFnErrors"></dl></div>
- </div>
- <div id="sectSearchResults" class="hidden">
- <h2>Search Results</h2>
- <ul id="listSearchResults"></ul>
- </div>
- <div id="sectSearchNoResults" class="hidden">
- <h2>No Results Found</h2>
- <p>Press escape to exit search and then '?' to see more options.</p>
- </div>
- <div id="sectFields" class="hidden">
- <h2>Fields</h2>
- <div id="listFields">
+ <div class="flex-right">
+ <div class="wrap">
+ <section class="docs">
+ <input type="search" class="search" id="search" autocomplete="off" spellcheck="false" placeholder="`s` to search, `?` to see more options">
+ <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>
+ <h1 id="hdrName" class="hidden"></h1>
+ <div id="fnNoExamples" class="hidden">
+ <p>This function is not tested or referenced.</p>
+ </div>
+ <div id="declNoRef" class="hidden">
+ <p>
+ This declaration is not tested or referenced, and it has therefore not been included in
+ semantic analysis, which means the only documentation available is whatever is in the
+ doc comments.
+ </p>
+ </div>
+ <div id="fnDocs" class="hidden"></div>
+ <div id="sectFnErrors" class="hidden">
+ <h2>Errors</h2>
+ <div id="fnErrorsAnyError">
+ <p><span class="tok-type">anyerror</span> means the error set is known only at runtime.</p>
+ </div>
+ <div id="tableFnErrors"><dl id="listFnErrors"></dl></div>
+ </div>
+ <div id="sectSearchResults" class="hidden">
+ <h2>Search Results</h2>
+ <ul id="listSearchResults"></ul>
+ </div>
+ <div id="sectSearchNoResults" class="hidden">
+ <h2>No Results Found</h2>
+ <p>Press escape to exit search and then '?' to see more options.</p>
+ </div>
+ <div id="sectFields" class="hidden">
+ <h2>Fields</h2>
+ <div id="listFields"></div>
+ </div>
+ <div id="sectTypes" class="hidden">
+ <h2>Types</h2>
+ <ul id="listTypes"></ul>
+ </div>
+ <div id="sectNamespaces" class="hidden">
+ <h2>Namespaces</h2>
+ <ul id="listNamespaces"></ul>
+ </div>
+ <div id="sectGlobalVars" class="hidden">
+ <h2>Global Variables</h2>
+ <table>
+ <tbody id="listGlobalVars"></tbody>
+ </table>
+ </div>
+ <div id="sectFns" class="hidden">
+ <h2>Functions</h2>
+ <table>
+ <tbody id="listFns"></tbody>
+ </table>
+ </div>
+ <div id="sectValues" class="hidden">
+ <h2>Values</h2>
+ <table>
+ <tbody id="listValues"></tbody>
+ </table>
+ </div>
+ <div id="sectErrSets" class="hidden">
+ <h2>Error Sets</h2>
+ <ul id="listErrSets"></ul>
+ </div>
+ <div id="fnExamples" class="hidden">
+ <h2>Examples</h2>
+ <ul id="listFnExamples"></ul>
+ </div>
+ </section>
+ </div>
+ <div class="flex-filler"></div>
</div>
</div>
- <div id="sectTypes" class="hidden">
- <h2>Types</h2>
- <ul id="listTypes">
- </ul>
- </div>
- <div id="sectNamespaces" class="hidden">
- <h2>Namespaces</h2>
- <ul id="listNamespaces">
- </ul>
- </div>
- <div id="sectGlobalVars" class="hidden">
- <h2>Global Variables</h2>
- <table>
- <tbody id="listGlobalVars">
- </tbody>
- </table>
- </div>
- <div id="sectFns" class="hidden">
- <h2>Functions</h2>
- <table>
- <tbody id="listFns">
- </tbody>
- </table>
- </div>
- <div id="sectValues" class="hidden">
- <h2>Values</h2>
- <table>
- <tbody id="listValues">
- </tbody>
- </table>
- </div>
- <div id="sectErrSets" class="hidden">
- <h2>Error Sets</h2>
- <ul id="listErrSets">
- </ul>
- </div>
- <div id="fnExamples" class="hidden">
- <h2>Examples</h2>
- <ul id="listFnExamples"></ul>
- </div>
- </section>
<div id="helpDialog" class="hidden">
- <h1>Keyboard Shortcuts</h1>
- <dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd></dl>
- <dl><dt><kbd>Esc</kbd></dt><dd>Clear focus; close this dialog</dd></dl>
- <dl><dt><kbd>s</kbd></dt><dd>Focus the search field</dd></dl>
- <dl><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd></dl>
- <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 class="help-modal">
+ <div class="dialog">
+ <h1>Keyboard Shortcuts</h1>
+ <dl><dt><kbd>?</kbd></dt><dd>Show this help dialog</dd></dl>
+ <dl><dt><kbd>Esc</kbd></dt><dd>Clear focus; close this dialog</dd></dl>
+ <dl><dt><kbd>s</kbd></dt><dd>Focus the search field</dd></dl>
+ <dl><dt><kbd>↑</kbd></dt><dd>Move up in search results</dd></dl>
+ <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>
</div>
<script src="data.js"></script>
<script src="main.js"></script>