diff options
| author | Gabriel Schneider <[email protected]> | 2026-11-20 04:42:01 -0300 |
|---|---|---|
| committer | Gabriel Schneider <[email protected]> | 2026-11-20 04:42:01 -0300 |
| commit | a403340ec5c90238b136ca85fc64d65809b29a65 (patch) | |
| tree | 1e5311bd482462ed004157adf9e688a8768daba1 /docs/typ | |
| parent | 403b46922af6e4e2012cd15f5f3f5a5702eef7e7 (diff) | |
| download | pardes-a403340ec5c90238b136ca85fc64d65809b29a65.tar.gz pardes-a403340ec5c90238b136ca85fc64d65809b29a65.zip | |
docs: the manual's library section is a consumer's build.zig lines and what each option selects, as build.zig's head comment says them, word for word (pardes-build-2 item 6): docs/typ/building.typ's "As a library" opens with the head comment's prose and its two shapes (`pardes-syntax` with `.grammars = .minimal`; `pardes-editor` with `.grammars = .none, .editor = true` and a grammar of the program's own), checked line by line against build.zig's `//!` lines; the syntax's table under its own heading, the paragraph after it no longer saying the option a second way; the editor's subsection no longer repeating a dependency line, saying instead what `.grammars = .none` means for it (a program links its grammar's parser and hands it in, as test/consumer does with C's); the head comment's dependency calls one field a line, as the manual's code blocks are, so a page's width holds them; `zig build book site cheatsheet` builds (138/138 steps)
Co-Authored-By: Claude Opus <[email protected]>
Claude-Session: https://claude.ai/code/session_016Y9MNBECMWcJD5pdS4SR6T
Diffstat (limited to 'docs/typ')
| -rw-r--r-- | docs/typ/building.typ | 75 |
1 files changed, 44 insertions, 31 deletions
diff --git a/docs/typ/building.typ b/docs/typ/building.typ index 8d14374d..d73543e1 100644 --- a/docs/typ/building.typ +++ b/docs/typ/building.typ @@ -92,15 +92,12 @@ moves an anchor fails that file's step. Each table says why, edit by edit. == As a library <library> -A Zig package that depends on pardes is given one module and nothing of -the editor: `pardes-syntax` (`core/lib_syntax.zig`), for a program that -draws source text itself and wants it parsed and coloured as pardes has -it. +As `build.zig`'s head comment says it, word for word: + +A package that depends on pardes is given its syntax, `pardes-syntax` +(`core/lib_syntax.zig`): ``` -// build.zig.zon -.pardes = .{ .path = "../pardes" }, -// build.zig const pardes = b.dependency("pardes", .{ .target = target, .optimize = optimize, @@ -109,6 +106,36 @@ const pardes = b.dependency("pardes", .{ exe.root_module.addImport("pardes-syntax", pardes.module("pardes-syntax")); ``` +and, when it asks, the text pane, `pardes-editor` +(`core/lib_editor.zig`), here with a grammar of its own handed in at +run time: + +``` +const pardes = b.dependency("pardes", .{ + .target = target, + .optimize = optimize, + .grammars = .none, + .editor = true, +}); +exe.root_module.addImport("pardes-editor", pardes.module("pardes-editor")); +``` + +`.grammars`: the tree-sitter grammars compiled in: `none` (the runtime +alone), `minimal` (C, C++ and Zig) or `full` (all of them; the default). +`.editor`: exports `pardes-editor` besides `pardes-syntax`, and with it +fetches uucode, mvzr and vaxis. + +Every dependency but tree-sitter's runtime is lazy in the manifest, so +such a package fetches what it asked for and nothing else. +`pardes-editor` has `pardes-syntax` in it as `.syntax`: a file belongs +to one module, so a package imports one of the two. `test/consumer` is +such a package, with both shapes; `lib-test`, which `unit-test` runs, +builds and runs it. + +`build.zig.zon` names pardes by its path: `.pardes = .{ .path = "../pardes" }`. + +=== The syntax + It is the editor's own code under the names it has there. A language is told by a path's extension, as in the editor, and `pathFor` gives a path for a language's name. @@ -122,35 +149,21 @@ for a language's name. [`start`, `stop`], [tree-sitter's allocator, and the end of the parsers kept per language], ) -The `grammars` option is the build's own: `none` (the runtime alone), -`minimal` (C, C++ and Zig) or `full` (all of them; the default). Every dependency but tree-sitter's -runtime is lazy in the manifest, so the package fetches the runtime and -its set's grammars and compiles those alone; pardes's own build asks for -what it is missing in one round. Zig still unpacks a lazy package whose -archive its global cache already holds; `--pkg-dir` (or `ZIG_LOCAL_PKG_DIR`) -at pardes's `zig-pkg` shares the one copy. What a pane measures stays -out: a cell's width is vaxis's and uucode's, and a tab is -`config.tab_width` cells wherever it stands. `test/consumer` is such a -package, and `zig build lib-test` builds and runs it. +pardes's own build takes `-Dgrammars` too, and asks for what it is +missing in one round. Zig still unpacks a lazy package whose archive its +global cache already holds; `--pkg-dir` (or `ZIG_LOCAL_PKG_DIR`) at +pardes's `zig-pkg` shares the one copy. What a pane measures stays out: a +cell's width is vaxis's and uucode's, and a tab is `config.tab_width` +cells wherever it stands. === The editor `pardes-editor` (`core/lib_editor.zig`) is the text pane as a library: helix's keys on a text kept in memory, no files, commands, builtins, -prompts or views. A package asks for it, and is then given uucode, mvzr -and vaxis's grapheme width besides; one that does not fetches nothing more. -It has `pardes-syntax` in it as `.syntax`: a file belongs to one module, so -a package imports one of the two. - -``` -const pardes = b.dependency("pardes", .{ - .target = target, - .optimize = optimize, - .grammars = .minimal, - .editor = true, -}); -exe.root_module.addImport("pardes-editor", pardes.module("pardes-editor")); -``` +prompts or views. Of vaxis it takes the grapheme width alone. With +`.grammars = .none` it has no grammar of pardes's: a program hands its +own in at run time (`Language`, below), linking the grammar's parser +itself, as `test/consumer` does with C's. The editor is a value of plain data, `Editor(capacity)`: no pointer, no allocator, every capacity in its type, so a program keeps it where it |
