How ilaborie/html2pdf works
Main Components
• CLI Entry Point – Represented by src/main.rs which initializes the program.
• Argument Parsing Module – Handled in src/cli.rs where all command-line options, flags, and input file parameters are parsed.
• Core Conversion Logic – Contained in src/lib.rs that abstracts and orchestrates the conversion process (interacting with headless_chrome, handling options such as landscape mode, background printing, and header/footer templates).
Relationships and Data Flow
• Start at the CLI entry point (src/main.rs) which captures the command-line input.
• From the Argument Parsing module, flow into the core library module (src/lib.rs) that performs the actual conversion logic. Show how parameters and configuration are passed along.
• An “Environment Config” node to represent configuration values and logging options (like RUST_LOG) that influence behavior.
Architectural Patterns and Design Principles
• Layered separation: an interface layer (CLI), a business logic layer (conversion routines), and an integration layer (headless chrome).
• Although simple, note that the project design follows the Single Responsibility Principle by separating argument parsing from core functionality.
• The modular structure (separated into src/cli.rs, src/lib.rs, and src/main.rs) indicates that each component has a dedicated, well-defined role.
Technologies and Frameworks
• Rust and Cargo – Represent the build and dependency management system.
• headless_chrome crate – As the external library providing browser automation.
• GitHub Actions (visible from the .github directory) can be mentioned as part of the project’s CI/CD pipeline, but are not central to the runtime architecture.
Additional Elements
• Labels for each component with details such as file names.
• Annotations to indicate that the primary functionality is to convert HTML to PDF using a headless browser.