Repository navigation
fix: batch_design accepts multi-line ops and # / // comments (#228) - #229
Merged
Merged
Conversation
The operations parser split on every newline, so the README's own multi-line chart/donut examples failed with 'Unmatched parentheses' and its '# comment' lines failed with 'Invalid operation'. A scanner now ends an op at a newline only at bracket depth 0, skips '#' comment lines between ops and '//' trailing comments, and ignores all of that inside quoted strings. The arg and brace matchers are quote-aware too, so a stray paren inside a content string no longer breaks an op.
Merged
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.
Fixes #228.
Problem
batch_designsplit its operations string on every newline. The README formats its chart and donut examples across several lines, so pasting them as written failed withUnmatched parentheses. The intro example uses# commentlines, and each of those failed withInvalid operation. The line-chart example's trailing// actualcomments would have been parsed as part of the arguments.Change
splitOperationsscanner insrc/operations.tsreplaces thesplit('\n'). A newline ends an op only when every(,{and[is closed. Newlines inside an open op become spaces, so the existing single-line parsing keeps working unchanged.#is a comment. Outside a quoted string,//comments out the rest of its line, at any depth."#RRGGBB"fills,https://URLs, and brackets insidecontentare left alone.extractArgsandparseJsonArgnow skip quoted strings too. Before, a single-line op whosecontentheld an unbalanced paren, such as"Total (incl. tax", failed for the same reason.Unmatched parentheseserror. Execution still stops at the first error.Docs
The new contract is stated in the README
batch_designsection, thebatch_designtool docstring and itsoperationsparameter description, a new gotcha in the server instructions, anddocs/GUIDELINES.md. All of them note that a#line inside an open bracket is not a comment, and that//is the comment to use there.Tests
test-ops-parser.tsadds seven cases:#comment lines between ops, including one with an apostrophe//comments inside a multi-line op#and//inside stringsUnmatched parenthesesThe fast suite passes 72/72 and
test-discoverability.tspasses 117/117.