From db2a259a18b9247edc23b1128dcfda703858f120 Mon Sep 17 00:00:00 2001 From: Gabriel Schneider Date: Wed, 30 Sep 2026 21:05:07 -0300 Subject: A one-page A4 cheatsheet, the first file of a Typst docs corpus in docs/typ docs/typ/cheatsheet.typ holds the facts as semantic calls (#key, #btn, #chord, #word, #tag, #addr, #file, #cmd, #doc); docs/typ/style.typ defines those once, drawing them for paged output and emitting HTML elements under --features html; docs/typ/cheatsheet-a4.typ is the page. `zig build cheatsheet` renders it when typst is on PATH. A config.zig test reads every .typ in docs/typ and fails when one names a builtin, key binding or default tag pardes no longer has. Co-Authored-By: Claude Opus 5.5 --- build.zig | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'build.zig') diff --git a/build.zig b/build.zig index eef05b44..c6f9dc2a 100644 --- a/build.zig +++ b/build.zig @@ -114,6 +114,17 @@ pub fn build(b: *std.Build) void { else requested_optimize; const test_build = b.step("test-build", "compile unit-test programs without running them"); + const doc_typ_opts = b.addOptions(); + doc_typ_opts.addOption([]const u8, "dir", b.pathFromRoot("docs/typ")); + const cheatsheet_step = b.step("cheatsheet", "render docs/typ/cheatsheet-a4.typ to /share/doc/pardes/cheatsheet.pdf (needs typst)"); + if (b.findProgram(&.{"typst"}, &.{})) |typst| { + const render = b.addSystemCommand(&.{ typst, "compile", "--ignore-system-fonts" }); + render.addFileArg(b.path("docs/typ/cheatsheet-a4.typ")); + const pdf = render.addOutputFileArg("cheatsheet.pdf"); + render.addFileInput(b.path("docs/typ/cheatsheet.typ")); + render.addFileInput(b.path("docs/typ/style.typ")); + cheatsheet_step.dependOn(&b.addInstallFile(pdf, "share/doc/pardes/cheatsheet.pdf").step); + } else |_| cheatsheet_step.dependOn(&b.addFail("zig build cheatsheet needs typst on PATH").step); const test_nonce: ?*std.Build.Module = if (b.option(bool, "test-rebuild", "force fresh Zig test compilation while retaining cached C dependencies") orelse false) blk: { const files = b.addTempFiles(); const source = files.add("test_nonce.zig", b.fmt("pub const nonce = {d};\n", .{std.Io.Clock.awake.now(b.graph.io).nanoseconds})); @@ -931,6 +942,8 @@ pub fn build(b: *std.Build) void { iso_on.addOption(bool, "isolated", true); for (core_mods, core_shells) |mod, shell| { + // config.zig's test checks the words and keys docs/typ names exist. + mod.addOptions("doc_typ", doc_typ_opts); mod.addOptions("pardes_config", if (also_gui and shell == .gui) gui_opts.? else opts); mod.addOptions("pardes_isolation", if (isolated_mod == mod) iso_on else iso_off); if (shell == .gui) for (gui_shaders) |name| mod.addAnonymousImport( -- cgit v1.3