feat: preserve OpenSCAD Customizer comments for 3D printing site uploads#6
Merged
Conversation
… printing sites - Add `--preserve-comments/--no-preserve-comments` CLI flag (default: on) - Pre-process entry file with `_strip_expression_comments` to remove `//` inside `()`/`[]` before parsing with `include_comments=True`, so statement-level magic comments (`// [min:max]`, `/* [Section] */`) survive without tripping the parser - Merge inline CommentLine annotations back onto the same output line as their assignment via `_merge_inline_comments` (Customizer requires `var = val; // [x]` on one line) - Reorder packed output: parametric assignments/comments first, library definitions second, geometry calls last — so Customizer finds variables at the top of the file - Add `## Why?` section to README explaining the 3D printing site use case - 138 tests, 99% branch coverage Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #6 +/- ##
===========================================
- Coverage 100.00% 99.59% -0.41%
===========================================
Files 6 6
Lines 146 244 +98
Branches 29 53 +24
===========================================
+ Hits 146 243 +97
- Partials 0 1 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Co-authored-by: Copilot Autofix powered by AI <223894421+github-code-quality[bot]@users.noreply.github.com>
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.
Summary
.scadfile. Creators using BOSL2 or similar libraries need everything inlined. This PR makes the packed output work seamlessly with the Customizer.//comments inside()/[]expression contexts (which trip the parser), then re-parsed withinclude_comments=Trueso statement-level magic annotations (// [min:max],/* [Section] */) survive into the output. Library files remain comment-free.var = val; // [min:max]is emitted on one line (as Customizer requires). The parser splits these into separate nodes;_merge_inline_commentspost-processes the output string to stitch them back together using source position data.--preserve-comments/--no-preserve-comments(default: on). Falls back gracefully with a stderr warning if the pre-processed source still can't be parsed with comments.## Why?section explaining the 3D printing site motivation.Test plan
uv run pytest— 138 tests, 99% branch coverage, all passuv run openscad-packer pack model.scad -o packed.scad) and open in OpenSCAD — Customizer should show all parameter sections and sliders/dropdowns--no-preserve-commentsstrips comments cleanlycube([10, // width\n 20])) pack without warnings🤖 Generated with Claude Code