-
Notifications
You must be signed in to change notification settings - Fork 4
Split out invoice specific logic and models from core and render. #24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…rom core/render - preparing for reuse for other documents than invoices.
There was a problem hiding this 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-coreintoklirr-core-invoice(invoice domain logic) andklirr-core-pdf(generic PDF primitives) - Split
klirr-renderintoklirr-render-invoice(invoice rendering) andklirr-render-pdf(generic Typst-based PDF rendering) - Introduced
DocumentPlanandInlineModuleabstractions 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(|| { |
Copilot
AI
Oct 24, 2025
There was a problem hiding this comment.
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))
| self.environment().fonts().get(index).cloned().or_else(|| { | |
| self.environment().fonts().get(index).cloned().unwrap_or_else(|| { |
Codecov Report❌ Patch coverage is 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. 🚀 New features to boost your workflow:
|
fa49646 to
d93e8b1
Compare
fd16b99 to
e9e1395
Compare
e9e1395 to
a4daab7
Compare
Note
ChatGPT authored the commits of this PR.
Preparing for reuse for other documents than invoices.