authorchloe caruso <git@paperclover.net> 2024-10-27 02:25:04-07:00
committergravatar for me@paperdave.netdave caruso <me@paperdave.net> 2024-10-27 13:39:45-07:00
log9c9f440794d6c700dbbcf7bc410d954c694a36c1
treebef24e4da39fdd956011327c252d77bcc1bd8b89
parentfd9bc5492894391c36ce4ee485e103ceb0255f76
signature Commit is signed but in an unrecognized format.

fix: bugs in the manual generator


4 files changed, 39 insertions(+), 33 deletions(-)

CHANGELOG.md+4-2
......@@ -1,11 +1,13 @@
11## 0.1.7
22
3- chore: rename the language to "ix"
3- news: rename the language to "ix"
4- breaking: new CLI interface
45- feat: language manual gets a pleasing redesign
5- feat: add boolean `and` and `or` operator keywords
66- feat: allow any expression as a function body
7- feat: add boolean `and` and `or` operator keywords
78- feat: add `assert` keyword
89- feat: add safety checks for array out of bounds
10- feat(js): block expressions are lowered to comma chains if possible
911- fix: coerce `break` operands and implicit breaks to result type
1012- fix: coerce results when `if` expression branches merge
1113- fix: ensure if branch results to a runtime value when the condition is not compile-time known
src/manual/generate_manual.zig+9-2
......@@ -271,6 +271,8 @@ const CodeExample = struct {
271271 \\</button>
272272 );
273273
274 var next_tab_id: usize = 0;
275
274276 pub fn write(code: CodeExample, w: std.io.AnyWriter) !void {
275277 try w.writeAll("<figure class=\"file\">");
276278 try w.print("<figcaption>{}</figcaption>", .{fmtHtmlEscape(code.filename, false)});
......@@ -283,12 +285,17 @@ const CodeExample = struct {
283285 }
284286 try w.writeAll("</code></pre>");
285287
288 const tab_id = next_tab_id;
289 next_tab_id += 1;
290
286291 if (code.terminal) |terminal| {
287292 try w.writeAll("<section class=\"tabs\">");
293 try w.print("<input class=\"tab-output\"name=\"tab{0d}\"type=\"radio\"id=\"output{0d}\"value=\"output\"checked=true/>", .{tab_id});
294 try w.print("<input class=\"tab-js\"name=\"tab{0d}\"type=\"radio\"id=\"js{0d}\"value=\"js\"/>", .{tab_id});
288295 if (code.javascript != null) {
289296 try w.writeAll("<div role=\"tablist\">");
290 try w.writeAll("<label id=\"output-tab\" role=\"tab\" for=\"output\">Output</label>");
291 try w.writeAll("<label id=\"js-tab\" role=\"tab\" for=\"js\">Compiled JS</label>");
297 try w.print("<label class=\"button-output\"id=\"output-tab\"role=\"tab\"for=\"output{d}\">Output</label>", .{tab_id});
298 try w.print("<label class=\"button-js\"id=\"js-tab\"role=\"tab\"for=\"js{d}\">Compiled JS</label>", .{tab_id});
292299 try w.writeAll("</div>");
293300 } else {
294301 // ???
src/manual/style.css+25-27
......@@ -29,16 +29,21 @@
2929 box-sizing: border-box;
3030}
3131
32html, body {
33 width: 100%;
34 overscroll-behavior-x: none;
35}
36
3237body {
3338 background-color: var(--base);
3439 color: var(--text);
3540 font-family: var(--font-text);
3641 color-scheme: light dark;
3742 display: flex;
43 max-width: 100vw;
3844}
3945
4046main {
41 width: 100%;
4247 max-width: 80ch;
4348 padding: 1rem;
4449 padding-top: 2rem;
......@@ -146,7 +151,7 @@ th, td {
146151}
147152
148153aside {
149 position: sticky;
154 position: fixed;
150155 top: 0;
151156 left: 0;
152157 height: 100dvh;
......@@ -236,13 +241,8 @@ aside a:hover {
236241 margin: 0;
237242}
238243
239#hidden-menu-checkbox, [name="tabs"] {
240 display: block;
241 width: 1px;
242 height: 1px;
243 position: fixed;
244 top: -3px;
245 left: -3px;
244input {
245 display: none;
246246}
247247
248248#menu-btn, #clickable-background {
......@@ -292,8 +292,17 @@ main a:active {
292292 top: -0.125em;
293293}
294294
295/* Desktop layout */
296@media (min-width: 1001px) {
297 .aside-spacer {
298 content: " ";
299 display: block;
300 flex: 0 0 40ch;
301 }
302}
303
295304/* Tablet/small screen layout */
296@media screen and (max-width: 1000px) {
305@media (max-width: 1000px) {
297306 html {
298307 scroll-padding-top: 5rem;
299308 }
......@@ -374,7 +383,7 @@ main a:active {
374383}
375384
376385/* Mobile layout */
377@media screen and (max-width: 600px) {
386@media (max-width: 600px) {
378387 main {
379388 padding: 3rem 1rem;
380389 }
......@@ -478,6 +487,7 @@ pre, code {
478487 overflow-y: scroll;
479488 color: var(--text);
480489 position: relative;
490 white-space: pre-wrap;
481491}
482492
483493.file pre.terminal {
......@@ -506,25 +516,13 @@ pre, code {
506516 display: none;
507517}
508518
509[name="tabs"][value="output"]:checked ~ main .file .tabs .output {
510 display: block;
511}
512
513[name="tabs"][value="output"]:checked
514 ~ main
515 .file
516 .tabs
517 [role="tab"][for="output"] {
518 font-weight: bold;
519 background-color: var(--base);
520 border-top: 2px solid var(--accent);
521}
522
523[name="tabs"][value="js"]:checked ~ main .file .tabs .js {
519.tab-output:checked ~ .output,
520.tab-js:checked ~ .js {
524521 display: block;
525522}
526523
527[name="tabs"][value="js"]:checked ~ main .file .tabs [role="tab"][for="js"] {
524.tab-js:checked ~ div .button-js,
525.tab-output:checked ~ div .button-output {
528526 font-weight: bold;
529527 border-top: 2px solid var(--accent);
530528 background-color: var(--base);
src/manual/template.html+1-2
......@@ -9,8 +9,6 @@
99 </head>
1010 <body>
1111 <input type="checkbox" id="hidden-menu-checkbox" />
12 <input name="tabs" type="radio" id="output" value="output" checked="true" />
13 <input name="tabs" type="radio" id="js" value="js" />
1412 <aside>
1513 <div id="top-part">
1614 <label
......@@ -77,6 +75,7 @@
7775
7876 <label id="clickable-background" for="hidden-menu-checkbox"></label>
7977 </aside>
78 <div class="aside-spacer"></div>
8079 <main id="main">
8180 {contents}
8281 </main>