Skip to content

Feature: Implement new bracket syntax for line selection (v3.0.0)#15

Merged
ferdodo merged 12 commits into
ferdodo:masterfrom
sanjeevpenupala:feature/#9-new-bracket-syntax
Jul 7, 2025
Merged

Feature: Implement new bracket syntax for line selection (v3.0.0)#15
ferdodo merged 12 commits into
ferdodo:masterfrom
sanjeevpenupala:feature/#9-new-bracket-syntax

Conversation

@sanjeevpenupala

Copy link
Copy Markdown

Summary

This PR introduces a major breaking change by implementing a new bracket syntax for line selection in the @includeExample tag, 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

  • NEW: Bracket syntax: @includeExample path/to/file[selector]
  • BREAKING: Removed support for old colon syntax: path/to/file:selector
  • BREAKING: Replaced dash ranges (2-4) with colon ranges (2:4)

Enhanced Line Selection Features

  • Single line selection: [5]
  • Range selection: [2:8]
  • Multiple selections: [2:5,10,15:20]
  • Open-ended ranges: [5:], [:10]
  • Negative indexing: [-5:], [:-3]
  • Exclusions: [1:10,!5:7]
  • Empty brackets: [] (select all lines)

Migration Support

  • Clear error messages for deprecated syntax with migration examples
  • Automatic suggestion of new syntax when old syntax is detected
  • Comprehensive documentation for migration path

Testing

  • Comprehensive test suite covering all new syntax features
  • Edge case testing for complex mixed selections
  • Performance testing for large files
  • Negative indexing validation
  • Exclusion logic verification
  • Breaking change error message validation

Documentation Updates

  • Updated README.md with new bracket syntax examples
  • Enhanced docs.md with comprehensive usage guide
  • Added troubleshooting section and migration guide
  • Updated CONTRIBUTING.md with new Docker setup instructions

Migration Guide

- @includeExample path/to/file:15
+ @includeExample path/to/file[15]

- @includeExample path/to/file:2-4
+ @includeExample path/to/file[2:4]

- @includeExample path/to/file:2-4,15
+ @includeExample path/to/file[2:4,15]

- @includeExample path/to/file:5-
+ @includeExample path/to/file[5:]

New Demo Examples

Added comprehensive demo classes with example files:

  • BookStore with inventory management examples
  • Magazine with article processing examples
  • Publisher with book publishing workflow
  • Review with rating and feedback systems

Breaking Changes

This is a major version bump (v3.0.0) due to breaking changes:

  1. Old colon syntax (path:selector) no longer supported
  2. Dash ranges (2-4) replaced with colon ranges (2:4)
  3. Users must migrate to new bracket syntax

Related

spenpal added 9 commits July 2, 2025 16:18
- 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
@ferdodo

ferdodo commented Jul 5, 2025

Copy link
Copy Markdown
Owner

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

spenpal added 2 commits July 6, 2025 19:24
- 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.
@sanjeevpenupala

Copy link
Copy Markdown
Author

Got it. I made sure to push the files with biome formatting now.

@ferdodo ferdodo merged commit 7f8d36a into ferdodo:master Jul 7, 2025
1 check failed
@ferdodo

ferdodo commented Jul 7, 2025

Copy link
Copy Markdown
Owner

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.

image

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 git config --global user.email "YOUR_EMAIL"

Then redact another PR with a small modification, for example adding youself to the list of contributors in package.json :)

@ferdodo

ferdodo commented Jul 7, 2025

Copy link
Copy Markdown
Owner

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.

@sanjeevpenupala sanjeevpenupala deleted the feature/#9-new-bracket-syntax branch July 7, 2025 20:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] Enhanced Line Selection Syntax

2 participants