Feature: Implement new bracket syntax for line selection (v3.0.0)#15
Conversation
- Add regex detection for new path[selector] syntax - Implement backwards compatibility detection for old colon syntax - Add helpful migration error messages for deprecated syntax - Support colons in file paths when not followed by line selectors - All tests passing (22/22) including new migration error tests Part of Python-like slicing syntax implementation (Task 1.1)
- Refactor parsing logic to support new Python-like syntax for line selectors - Implement backwards compatibility for old dash syntax - Update example tags in Author, Chapter, and Library classes to use new bracket syntax - Add new interfaces for line selection and parsed line selectors - Introduce resolveLineSelections function for handling parsed selections - Ensure all tests pass, including new cases for the updated syntax
- Introduced Python-like slicing syntax for line selection with advanced features - Deprecated old colon syntax; migration guide provided in README - Updated README to reflect new syntax and breaking changes - Updated Dockerfile to use new plugin version - Enhanced error messages for deprecated syntax in parsing logic - Ensured comprehensive test coverage with 52 tests
…mples - Introduced BookStore class for inventory management with example usage - Added Magazine class for article processing and featuring books - Implemented Publisher class for managing book publication - Created Review class for handling book reviews with validation - Included example files for each new class demonstrating functionality - Updated index.ts to export new classes for easier access
- Changed example syntax in Chapter and Library classes from dash to colon format - Refactored tests to remove old dash syntax and ensure compatibility with new parsing logic - Enhanced error handling for out-of-range selections in tests - Updated parsing logic to throw errors for deprecated dash syntax - Improved test cases for line selection, including complex scenarios and exclusions
- Change parameter type from Application to ApplicationType to avoid type/value import conflicts in generated .d.ts files - Prevents Biome linting errors on generated declaration files by separating type-only imports from value imports - Maintains runtime functionality while improving TypeScript compilation
…lection syntax - Added Apple Silicon compatibility options in CONTRIBUTING.md for Docker builds - Updated README to reflect new bracket syntax for line selection and improved documentation structure - Enhanced examples and troubleshooting sections for clarity and usability
- Cleaned up whitespace and formatting in load.ts for consistency - Refactored parseLineSelector.ts to enhance readability and maintainability - Introduced helper functions for range and single line parsing - Improved error handling and validation in resolveLineSelections.ts - Ensured all changes maintain compatibility with existing syntax and functionality
|
Great work ! No problem for adding this to v3.0.0 soon. Automatic pull request checks are not passing because of Biome code formatting, you might want to check again the unformatted files |
- Updated tests for line selection to cover new mixed positive/negative range scenarios and exclusions. - Refactored parsing logic to improve readability and maintainability, including the introduction of utility functions. - Enhanced error handling for invalid line numbers and range logic. - Ensured compatibility with new bracket syntax and improved test coverage across various edge cases.
|
Got it. I made sure to push the files with biome formatting now. |
|
It's merged. you're profile is not appearing in contributors, my guess is it's because the email you used to configure git is not the same as your github email. resulting in all you commits being "kind of" anonymous. If this isn't intentionnal you want to fix it, I suggest you read this https://docs.github.com/fr/account-and-profile/setting-up-and-managing-your-personal-account-on-github/managing-email-preferences/setting-your-commit-email-address and use the command Then redact another PR with a small modification, for example adding youself to the list of contributors in package.json :) |
|
also @spenpal you can read the mutation testing report for all the tests you have written here https://ferdodo.github.io/typedoc-plugin-include-example/reports/mutation/mutation.html#mutant you can inspect precisely what edge cases might have been missed while testing. |

Summary
This PR introduces a major breaking change by implementing a new bracket syntax for line selection in the
@includeExampletag, replacing the old colon and dash syntax. The new syntax is more intuitive, powerful, and supports advanced features like negative indexing and exclusions.Changes Made
Core Syntax Changes
@includeExample path/to/file[selector]path/to/file:selector2-4) with colon ranges (2:4)Enhanced Line Selection Features
[5][2:8][2:5,10,15:20][5:],[:10][-5:],[:-3][1:10,!5:7][](select all lines)Migration Support
Testing
Documentation Updates
README.mdwith new bracket syntax examplesdocs.mdwith comprehensive usage guideCONTRIBUTING.mdwith new Docker setup instructionsMigration Guide
New Demo Examples
Added comprehensive demo classes with example files:
Breaking Changes
This is a major version bump (v3.0.0) due to breaking changes:
path:selector) no longer supported2-4) replaced with colon ranges (2:4)Related