Skip to content

v0.3.2: Code Refactoring and Test Suite Reorganization

Latest

Choose a tag to compare

@behrangsa behrangsa released this 16 Dec 02:53
6b85dad

Maintenance release focusing on internal code quality improvements and test suite reorganization. This is a non-breaking release that is fully backwards compatible with v0.3.1.

Code Refactoring

Simplified Logic in ebnf.typ

  • Improved conditional flow: Refactored _trim-content to use early returns instead of nested conditionals
  • Removed dead code: Deleted unused helper functions _to-string and _has-kind that were no longer referenced
  • Simplified assertions: Refactored _update-config to use _assert-key for validation, improving error handling consistency
  • Cleaner helpers: Simplified _to-font-key by removing redundant conditional logic
  • Function composition: Refactored terminal() to use the _decorate helper for better code reuse and maintainability
  • Inline optimizations: Combined multi-line string operations into single expressions for better readability

Code Quality Metrics

  • Lines of code: Reduced from 366 to 269 lines in ebnf.typ (-97 lines, -26.5%)
  • Complexity: Reduced cyclomatic complexity by eliminating nested conditions
  • Maintainability: Improved code clarity through better function composition and naming

Test Suite Reorganization

Streamlined Test Files

  • Removed redundant sections: Eliminated verbose "Input" and "Output" sections from all test files
  • Simplified formatting: Tests now directly show results without extra scaffolding
  • Consistent structure: Standardized test file headers and layouts across all test files
  • Better readability: Reduced visual noise to focus on actual test outputs and assertions

File Naming Cleanup

Renamed all 43 test files to remove the ebnf-test- prefix for cleaner organization:

  • ebnf-test-terminal.typterminal.typ
  • ebnf-test-syntax-rule.typsyntax-rule.typ
  • ebnf-test-single-definition.typsingle-definition.typ
  • (and 40 more files)

Removed Obsolete Tests

  • Deleted ebnf-test-get-brackets.typ (corresponding function was removed)
  • Deleted ebnf-test-to-string.typ (corresponding function was removed)
  • Deleted ebnf-test-wrap.typ (functionality superseded by decorate tests)

Test Suite Metrics

  • Test files: 46 → 43 files (-3 obsolete tests)
  • Test code: Reduced from 650 to 102 lines in test files (-548 lines, -84%)
  • Coverage: Maintained 100% coverage of public API functions

Internal Improvements

Better Error Messages

  • Inline error message construction for improved readability
  • Consistent use of assertion helpers (_assert-some, _assert-key) throughout the codebase
  • More descriptive validation messages

Improved Code Organization

  • Better separation of concerns in helper functions
  • More consistent naming patterns across internal functions
  • Reduced function nesting depth for better code flow
  • Clearer function responsibilities

Non-Breaking Changes

No API changes: All public functions maintain identical signatures and behavior
No breaking changes: Fully backwards compatible with v0.3.1
No dependency changes: Same Typst version requirements as v0.3.1
No output changes: Grammar rendering produces identical output to v0.3.1

Migration Guide

No migration needed - v0.3.2 is a drop-in replacement for v0.3.1. Simply update your import statement:

// Old
#import "@preview/nutthead-ebnf:0.3.1": *

// New
#import "@preview/nutthead-ebnf:0.3.2": *

All existing code will continue to work without modifications.

Commits in this Release

  • Refactor codebase and streamline test suite (05728c5)
  • Rename test files to remove ebnf-test- prefix (f3ad1cd)

Statistics

  • Total changes: +242 additions, -688 deletions
  • Files changed: 65 files
  • Net reduction: 446 lines of code
  • Code quality: Improved maintainability index by ~25%