summaryrefslogtreecommitdiff
path: root/build.zig
diff options
context:
space:
mode:
authorGabriel Schneider <[email protected]>2026-11-21 05:49:06 -0300
committerGabriel Schneider <[email protected]>2026-11-21 05:56:16 -0300
commitbf16b1c2b461f4d7db17efb6de912799a5bf78ac (patch)
tree0df6f9681fd7a353c1689c0a67f054579197d19c /build.zig
parented0103e9738e3cf5a7c7a91aec5adf0be2fc409a (diff)
downloadpardes-bf16b1c2b461f4d7db17efb6de912799a5bf78ac.tar.gz
pardes-bf16b1c2b461f4d7db17efb6de912799a5bf78ac.zip
library: a language's browser module formats one file's diff with that file's text: `patchFile(text, len, file, file_len)` beside `highlight` (xit writes its `@@` with nothing after it, so a hunk had no context at all; toilet has the file's blob), the same header and records as `patch`, with the declaration rows formatPatch stacks when it has a source (kind 3, as git's words are: a declaration's `path:line` row, its code_start its whole length, then its header's lines); the text is the first section's file, new or old (formatPatch finds each hunk on either side and numbers the labels as that side; tested both), a hunk the text does not hold and the diff's other files stack as with no text (tested: the same rows as `patch`); only abi/wasm.zig (the export, a `Given` source answering for the first path asked, `start` shared with highlight), build.zig (the export's name, the option named `language`) and the docs: formatPatch is unchanged; +7,031 bytes on rust's module (1,290,182 -> 1,297,213; about 7 KB on each language's), 18 ms against patch's 4 for a 28-hunk diff of a 1,100-line Zig file under node (the file's parse); test/consumer's node run calls it on a bare-`@@` rust diff with the new text, the old, another text and a second file
Co-Authored-By: Claude Opus <[email protected]> Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'build.zig')
-rw-r--r--build.zig6
1 files changed, 3 insertions, 3 deletions
diff --git a/build.zig b/build.zig
index 69ada42f..add0aaf7 100644
--- a/build.zig
+++ b/build.zig
@@ -415,7 +415,7 @@ pub fn build(b: *std.Build) void {
/// pardes's highlighter; or, with no language, the patch view alone, with
/// no tree-sitter in it. Its exports are abi/wasm.zig's (`memory`,
/// `_initialize`, `reserve`, `release`, `patch`, and with a language
-/// `highlight`), the same in every module; docs/typ/building.typ has their
+/// `highlight` and `patchFile`), the same in every module; docs/typ/building.typ has their
/// layouts and the WASI imports a page stubs. The package's dependency on
/// pardes is named "pardes". A name the manifest does not have fails the
/// configure, as `.languages` does.
@@ -429,7 +429,7 @@ pub fn wasmModule(b: *std.Build, options: struct {
else
b.dependency("pardes", .{ .target = target, .optimize = options.optimize, .grammars = .none });
const exports = b.addOptions();
- exports.addOption(bool, "highlight", options.language != null);
+ exports.addOption(bool, "language", options.language != null);
const module = b.addExecutable(.{
.name = b.fmt("pardes-{s}", .{options.language orelse "patch"}),
.root_module = b.createModule(.{
@@ -445,7 +445,7 @@ pub fn wasmModule(b: *std.Build, options: struct {
module.entry = .disabled;
module.wasi_exec_model = .reactor;
// Its own functions alone: tree-sitter's and libc's stay inside.
- module.root_module.export_symbol_names = if (options.language != null) &.{ "reserve", "release", "patch", "highlight" } else &.{ "reserve", "release", "patch" };
+ module.root_module.export_symbol_names = if (options.language != null) &.{ "reserve", "release", "patch", "highlight", "patchFile" } else &.{ "reserve", "release", "patch" };
return module;
}