Skip to content

refactor: Phase 1 - Parser refactoring and command syntax unification#7

Open
genro wants to merge 5 commits intomainfrom
refactor/command-syntax
Open

refactor: Phase 1 - Parser refactoring and command syntax unification#7
genro wants to merge 5 commits intomainfrom
refactor/command-syntax

Conversation

@genro
Copy link
Contributor

@genro genro commented Nov 4, 2025

Summary

This PR implements Phase 1 of the command syntax refactoring as defined in Issue #6.

The goal is to unify the concept of "protocols" and "modifiers" into a single "command" abstraction, where all commands use consistent command: syntax and can be composed in pipelines.

Changes

1.1 - Remove implicit static: fallback

  • static: protocol is now mandatory
  • ✅ Lines without explicit protocol generate error
  • ✅ 4 tests updated to use explicit static: syntax

Breaking change: Files using implicit {path} must now use static: {path}

1.2 - Rename terminology (modifier/protocol → command)

  • ✅ Unified terminology: everything is now a "command"
  • ✅ Internal structure: SOURCE_COMMANDS (static, cli, glob) and TRANSFORM_COMMANDS (render, tldr, translate)
  • ✅ All docstrings and comments updated
  • ✅ Error message changed from "Unknown protocol" to "Unknown command"

1.3 - Spacing (skipped - already OK)

  • Current parser already handles spaces after colons correctly
  • Both cli: date and cli:date are accepted

1.4 - Rename expand:render:

  • ✅ Transform command renamed for clarity
  • ✅ Method _expand_content_render_content
  • ✅ All tests updated (:expand::render:)

Breaking change: :expand: must now be written as :render:

Test Results

  • 171 tests passed, 17 skipped
  • ✅ Ruff lint: PASSED
  • ✅ Black format: PASSED
  • ⚠️ Mypy: 18 errors (non-blocking, pre-existing)
  • 📊 Coverage: 70%

Breaking Changes Summary

  1. Implicit static: removed - all file paths must now explicitly use static: prefix
  2. expand: renamed to render: - update all :expand: to :render: in your .gtext files

Related

Checklist

  • All tests passing locally
  • Local lint/format checks passing
  • Breaking changes documented
  • CI passing (waiting for GitHub Actions)

genro added 4 commits November 4, 2025 11:28
Add script and documentation for running tests locally before push
to avoid CI failures. This replicates GitHub Actions checks locally.

Changes:
- Add scripts/test-local.sh for one-command local testing
- Document testing workflow in CLAUDE.md
- Include ruff, black, pytest, and mypy checks

Note: Windows-specific tests cannot be run locally on macOS
Remove backward compatibility for implicit static: protocol.
The static: protocol is now mandatory for all static file includes.

Changes:
- include.py: Return 'unknown' protocol instead of 'static' for lines without explicit protocol
- Updated 4 tests to use explicit static: syntax
- Renamed test_modifier_without_protocol_uses_static to test_modifier_without_protocol_errors

Breaking change: Files using `{path}` must now use `static: {path}`

Related to Issue #6
… 1.2)

Unify terminology to use "command" everywhere, eliminating the
distinction between "modifiers" and "protocols" from user perspective.

Internally, maintain two categories:
- SOURCE_COMMANDS: fetch data (static, cli, glob)
- TRANSFORM_COMMANDS: transform content (expand, tldr, translate)

Changes:
- Rename PROTOCOLS → SOURCE_COMMANDS
- Rename MODIFIERS → TRANSFORM_COMMANDS
- Update all docstrings and comments to use "command" terminology
- Change error message from "Unknown protocol" to "Unknown command"
- Update test expectations for new error message

Related to Issue #6, Decision #2
Rename the 'expand' transform command to 'render' for clarity.
The render command recursively processes included content.

Changes:
- TRANSFORM_COMMANDS: "expand" → "render"
- Method: _expand_content → _render_content
- All docstrings and examples updated
- All test files updated (:expand: → :render:)
- Test expectations updated ('expand' → 'render' in tuples)

Breaking change: `:expand:` must now be written as `:render:`

Related to Issue #6, Decision #7
@codecov
Copy link

codecov bot commented Nov 4, 2025

Codecov Report

❌ Patch coverage is 93.33333% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 66.34%. Comparing base (80d3ab9) to head (25723e2).

Files with missing lines Patch % Lines
gtext/extensions/include.py 93.33% 1 Missing ⚠️

❌ Your project check has failed because the head coverage (66.34%) is below the target coverage (80.00%). You can increase the head coverage or adjust the target coverage.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main       #7      +/-   ##
==========================================
+ Coverage   66.24%   66.34%   +0.09%     
==========================================
  Files          10       10              
  Lines        1031     1031              
==========================================
+ Hits          683      684       +1     
+ Misses        348      347       -1     
Flag Coverage Δ
unittests 66.34% <93.33%> (+0.09%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
gtext/extensions/include.py 79.16% <93.33%> (+0.52%) ⬆️
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Add prominent family membership badge after main badges section
to establish gtext as part of the We-Birds toolkit brand.
Consistent with smartswitch branding.
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.

1 participant