Skip to content

feat: a document's node table, through the crate and the C ABI - #19

Merged
adammharris merged 1 commit into
mainfrom
agent/backlog-rust-node-table-encoder
Oct 25, 2026
Merged

adammharris merged 1 commit into
mainfrom
agent/backlog-rust-node-table-encoder

Conversation

@adammharris

Copy link
Copy Markdown
Member

What changed

  • Document::node_table() in the twig crate returns the document's node table: the same JSON twig lang table prints (pretty-printed, with positions), spelling column included.
  • twig_document_node_table in the C ABI returns the same bytes. Like twig_document_ast_json's, they are borrowed from the handle and declared in bindings/c/include/twig.h. Through twig_editor_view it also works on an editor's current tree.

Why

The encoder (twig::ast::table::encode) was already in the crate, because the CLI prints through it, but nothing reached it from a parsed twig::Document. So a Rust twin test could not compare whole tables the way lang table and lang check --against do.

Closes the task rust-node-table-encoder. It is marked done with a Resolution section and moved to docs/tasks/closed/ with prov mv. Moving twig-quickjs's tests/twins.rs onto the new call is that repo's change.

Additive only, so there is no Behavioural-change: trailer.

Verification

  • Tests first: node_table_is_what_lang_table_prints_spelling_included (crates/twig/tests/binding.rs) pins a bullet list's table byte for byte against twig lang table's output for the same file. node_table_is_what_lang_table_prints (crates/twig-capi/src/tests.rs) covers the C ABI and its invalid-argument cases. api_surface.rs pins the signature. Each test failed to compile before the change.
  • ship ci: all 5 jobs passed (workspace tests, the CLI on wasm32-wasip1, the C ABI header test and the wasm build, version sync). The TypeScript job skipped itself because this machine has no Node 24; this PR doesn't touch the TypeScript bindings.

`twig lang table` printed a document's node table through
`twig::ast::table::encode`, but nothing reached that encoder from a parsed
`twig::Document`, so a Rust twin test could not compare whole tables,
`spelling` column included, the way `lang table` and `lang check --against`
do. `Document::node_table()` returns that encoding with `lang table`'s
options, and `twig_document_node_table` returns the same bytes over the C
ABI, borrowed from the handle like `twig_document_ast_json`'s. Closes the
task rust-node-table-encoder.
@adammharris
adammharris merged commit 4fccb68 into main Oct 25, 2026
5 checks passed
@adammharris
adammharris deleted the agent/backlog-rust-node-table-encoder branch October 30, 2026 01:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant