feat: Added support for commented JSON; simplified instrumentation exports#2
Merged
regularkevvv merged 3 commits intomainfrom Jan 23, 2026
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for parsing JSON with C-style comments (JSONC) and simplifies the public API by removing the deprecated instrument() function and other internal utilities.
Changes:
- Added
allow_commentsparameter toas_json()andas_json_blocks()methods to support JSONC-style files with//and/* */comments - Removed
instrument()function from public API; callers should useTemplateSpecwhich handles instrumentation internally, or usecreate_instrumentation()+ manual env setup - Removed internal utilities (
create_instrumentation,load_template_with_markers,transform_markers,AnchorIndex,TraceRecorder,MarkerTransform) from public exports
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| jinjatest/parsers/json_parser.py | Added allow_comments parameter and comment-stripping logic using regex patterns |
| jinjatest/rendered.py | Added allow_comments parameter to as_json() and as_json_blocks() methods |
| jinjatest/init.py | Removed internal instrumentation and marker utilities from public exports |
| jinjatest/instrumentation.py | Removed instrument() function (deprecated in favor of TemplateSpec or manual setup) |
| jinjatest/spec.py | Updated to use create_instrumentation() directly instead of instrument() |
| jinjatest/markers.py | Updated docstring example to show manual instrumentation setup |
| tests/test_parsers.py | Added comprehensive tests for JSON comment parsing feature |
| tests/test_basic.py | Added tests for as_json(allow_comments=True) and updated imports |
| tests/test_fenced_blocks.py | Added test for as_json_blocks(allow_comments=True) |
| tests/test_markers.py | Updated to import create_instrumentation from jinjatest.instrumentation |
| tests/test_instrumentation.py | Removed tests for deprecated instrument() function |
| tests/test_imports.py | Updated to reflect removed exports |
| README.md | Updated documentation to show allow_comments usage and removed instrument() examples |
| Makefile | Renamed target from test-coverage to test-cov |
💡 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.
Summary
allow_commentsoption to JSON parser for JSONC-style files with//and/* */commentsinstrument()function - useTemplateSpecinstead which handles instrumentation internallyChanges
JSON Comments Support
Uses a state-tracking parser that correctly handles:
//in text)\")\\) including edge case"foo\\"(string ending with backslash)Removed from Public API
instrument()-TemplateSpechandles this internallycreate_instrumentation(),load_template_with_markers(),transform_markers()AnchorIndex,TraceRecorder,MarkerTransformStill Public
has_markers(),discover_markers()- useful for CI/toolingTestInstrumentation,ProductionInstrumentation- for type hintsTest Plan