Skip to content

Conversation

@Sajjon
Copy link
Owner

@Sajjon Sajjon commented Oct 24, 2025

Note

ChatGPT authored the commits of this PR.

Preparing for reuse for other documents than invoices.

…rom core/render - preparing for reuse for other documents than invoices.
@Sajjon Sajjon requested a review from Copilot October 24, 2025 18:16
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the codebase to separate invoice-specific logic from generic PDF rendering capabilities, enabling future reuse for other document types beyond invoices.

  • Split klirr-core into klirr-core-invoice (invoice domain logic) and klirr-core-pdf (generic PDF primitives)
  • Split klirr-render into klirr-render-invoice (invoice rendering) and klirr-render-pdf (generic Typst-based PDF rendering)
  • Introduced DocumentPlan and InlineModule abstractions to replace invoice-specific rendering context

Reviewed Changes

Copilot reviewed 87 out of 171 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
crates/render-pdf/Cargo.toml New crate for generic PDF rendering with Typst dependencies
crates/render-pdf/src/lib.rs Exports generic document rendering API
crates/render-pdf/src/module.rs Defines DocumentPlan and InlineModule for flexible document composition
crates/render-pdf/src/render.rs Generic render_document function replacing invoice-specific implementation
crates/render-pdf/src/typst_context/* Refactored Typst context to work with generic modules instead of fixed invoice sources
crates/core-pdf/Cargo.toml New crate for PDF-focused primitives
crates/core-pdf/src/* Extracted font handling, Typst conversion traits, and PDF type from core
crates/render-invoice/* Updated to use new generic rendering layer via DocumentPlan
crates/core-invoice/* Renamed from klirr-core with updated import paths
crates/cli/* Updated imports to reference renamed crates

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

if let Some(font) = self.environment().fonts().get(index).cloned() {
Some(font)
} else {
self.environment().fonts().get(index).cloned().or_else(|| {
Copy link

Copilot AI Oct 24, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The or_else closure will always panic, making the cloned() operation pointless. The panic should occur when get(index) returns None, not inside or_else. Consider using unwrap_or_else or restructuring to: self.environment().fonts().get(index).cloned().unwrap_or_else(|| panic!(\"Font not found at index: {}\", index))

Suggested change
self.environment().fonts().get(index).cloned().or_else(|| {
self.environment().fonts().get(index).cloned().unwrap_or_else(|| {

Copilot uses AI. Check for mistakes.
@codecov
Copy link

codecov bot commented Oct 24, 2025

Codecov Report

❌ Patch coverage is 62.50000% with 42 lines in your changes missing coverage. Please review.
✅ Project coverage is 93.02%. Comparing base (74a56db) to head (a4daab7).
⚠️ Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
crates/render-pdf/src/compare_images.rs 0.00% 35 Missing ⚠️
crates/render-invoice/src/render.rs 66.66% 3 Missing ⚠️
crates/render-pdf/src/render.rs 81.81% 2 Missing ⚠️
crates/render-pdf/src/typst_context/context.rs 85.71% 2 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #24      +/-   ##
==========================================
- Coverage   95.74%   93.02%   -2.72%     
==========================================
  Files          92      101       +9     
  Lines        2113     2221     +108     
==========================================
+ Hits         2023     2066      +43     
- Misses         90      155      +65     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@Sajjon Sajjon force-pushed the split_out_invoice_from_render branch from fa49646 to d93e8b1 Compare October 25, 2025 06:43
@Sajjon Sajjon force-pushed the split_out_invoice_from_render branch from fd16b99 to e9e1395 Compare October 26, 2025 14:50
@Sajjon Sajjon force-pushed the split_out_invoice_from_render branch from e9e1395 to a4daab7 Compare October 26, 2025 14:52
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.

2 participants