summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-09-30 21:05:07 -0300
committerGabriel Schneider <[email protected]>2026-10-01 00:12:17 -0300
commitdb2a259a18b9247edc23b1128dcfda703858f120 (patch)
tree11a877ab15b552be8fe7d79a4f1402a54b9f3d58 /build.zig
parent68dd567218505838814d73473460a0c0ff8e97b3 (diff)
downloadpardes-db2a259a18b9247edc23b1128dcfda703858f120.tar.gz
pardes-db2a259a18b9247edc23b1128dcfda703858f120.zip
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 <[email protected]>
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig13
1 files changed, 13 insertions, 0 deletions
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 <prefix>/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(