Repository navigation
feat: a document's node table, through the crate and the C ABI - #19
Merged
Merged
Conversation
`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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
Document::node_table()in thetwigcrate returns the document's node table: the same JSONtwig lang tableprints (pretty-printed, with positions),spellingcolumn included.twig_document_node_tablein the C ABI returns the same bytes. Liketwig_document_ast_json's, they are borrowed from the handle and declared inbindings/c/include/twig.h. Throughtwig_editor_viewit 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 parsedtwig::Document. So a Rust twin test could not compare whole tables the waylang tableandlang check --againstdo.Closes the task
rust-node-table-encoder. It is marked done with a Resolution section and moved todocs/tasks/closed/withprov mv. Movingtwig-quickjs'stests/twins.rsonto the new call is that repo's change.Additive only, so there is no
Behavioural-change:trailer.Verification
node_table_is_what_lang_table_prints_spelling_included(crates/twig/tests/binding.rs) pins a bullet list's table byte for byte againsttwig 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.rspins 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.