Skip to content

Refactor render strategies#136

Closed
elong0527 wants to merge 6 commits intomainfrom
refactor-render-strategies
Closed

Refactor render strategies#136
elong0527 wants to merge 6 commits intomainfrom
refactor-render-strategies

Conversation

@elong0527
Copy link
Collaborator

create a strategies folder to enable a single render.

   2
   3 Unify single and multi-page rendering strategies, centralizing border and element placement logic. Remove outdated manual border applications and a
     private side-channel for border style passing. Also resolves Ruff and MyPy warnings.
    2
    3 This commit refactors the RTF generation pipeline to implement a modular strategy pattern for pagination and rendering, enhancing maintainability and extensibility.
    4
    5 Key changes include:
    6
    7 - **Unified RTF Encoder**: Replaced `SinglePageStrategy` and `PaginatedStrategy` with a `UnifiedRTFEncoder` that orchestrates the entire document generation process.
    8 - **Pagination Strategy Interface**: Introduced a `PaginationStrategy` interface and a `StrategyRegistry` for managing different pagination behaviors (`DefaultPaginationStrategy`, `PageByStrategy`, `SublineStrategy`).
    9 - **Page Feature Processing**: Implemented `PageFeatureProcessor` to apply page-specific features (e.g., borders, headers) after pagination and before rendering.
   10 - **Page Renderer**: Extracted single-page rendering logic into a dedicated `PageRenderer`.
   11 - **Code Cleanup**: Removed obsolete code (`src/rtflite/encoding/strategies.py`, `rtflite.pagination.ContentDistributor` class, `RTFDocumentService.create_pagination_instance` method).
   12 - **Test Updates**: Refactored `tests/test_encoding_engine.py` and `tests/test_strategies_coverage.py` to align with the new architecture and verify correct behavior.
   13 - **Documentation**: Updated `AGENTS.md` to reflect the new system architecture.
   14 - **Documentation Build Fixes**: Resolved `ImportError` and `NameError` in mkdocs build process for `LibreOfficeConverter` by correctly exporting it and addressing python execution context.
   15 - **Output Consistency**: Fixed a regression where paginated document headers were not repeating on all pages. Addressed inconsistencies in `RTFBody` cell vertical alignment to match explicit default `[["top"]]`. Removed minor blank line
      diffs.
   16 - **Improved Attribute Slicing**: Enhanced attribute slicing logic in `RTFEncodingService.prepare_dataframe_for_body_encoding` to correctly handle `col_rel_width` when columns are removed by `page_by` or `subline_by` features. This ensure
      consistency between processed DataFrame columns and their corresponding attributes.
   17
   18 The refactor ensures a clearer separation of concerns and a more robust foundation for future development, while maintaining expected output characteristics for generated RTF files and correcting inconsistencies in example definitions.
@elong0527 elong0527 closed this Nov 30, 2025
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