feat: configure focused Cirru previews - #41
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds a backward-compatible, configurable API for generating focused/folded Cirru “preview” trees, allowing callers to customize markers, preserve a root signature prefix, and tune fold limits while keeping focus_cirru_preview defaults unchanged.
Changes:
- Introduces
CirruFocusOptionsandfocus_cirru_preview_with_optionsfor configurable focused previews, while preserving existingfocus_cirru_previewbehavior. - Updates crate exports to expose the new API from the crate root.
- Adds documentation and examples (README + runnable example) and extends unit tests for the new options.
Reviewed changes
Copilot reviewed 6 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
tests/parser_test.rs |
Minor cleanup to use map(Cirru::List) in serde-json parser test. |
src/parser.rs |
Re-exports CirruFocusOptions and focus_cirru_preview_with_options from the crate root. |
src/focus.rs |
Implements configurable focus/fold options, root-prefix preservation, and adds tests/doctests. |
README.md |
Documents the focused preview API and how to customize it. |
examples/focus_cirru_preview.rs |
Demonstrates both default focusing and customized focusing via options. |
Comments suppressed due to low confidence (1)
src/focus.rs:80
- The doc comment for
folded_placestill hard-codes'FOLDED:...and claims the placeholder leaf will always print bare. Now thatoptions.folded_markeris user-configurable, the placeholder may not be'FOLDED:..., and if the marker (ordetail) contains spaces/non-ASCII it will be quoted/escaped by the writer (see README escaping example). Updating this comment will prevent misleading API docs.
/// Build a `'FOLDED:...` placeholder: a single bare Cirru symbol leaf.
///
/// Uses the `'` symbol prefix (not `|` string prefix): this is an
/// identifier-like marker, not free-form string data, so `'FOLDED:...`
/// matches Cirru's own convention for such tokens. Deliberately a single
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
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.
Adds a backward-compatible CirruFocusOptions API for custom focus/fold markers, root-prefix preservation, and target/non-target folding limits. Keeps focus_cirru_preview defaults unchanged. Includes unit tests, doctests, README docs, and an executable example. Local cargo test, serde-json tests, and clippy all pass.