Arquitectura RAM-first y migración a Poetry#2
Open
runesc wants to merge 3 commits intoEdybrown:mainfrom
Open
Conversation
Major refactor introducing in-memory HTML/CSS generation for seamless
integration with downstream applications (PPG, web frameworks) without
requiring disk I/O by default.
Architecture Changes:
- Migrate build system: setuptools → poetry (modern dependency management)
- create_document() now supports output modes: "file", "raw", "both"
- bundle_document() generates self-contained HTML with embedded CSS
- CSSProcessor extracted for pure CSS transformation (testable, reusable)
- _write_file() helper centralizes file operations (DRY principle)
Features:
- Generate HTML/CSS for in-memory use without disk I/O
- Return content ready for integration with frameworks (PPG, Flask, FastAPI, etc)
- Optional disk export ("file" mode) when needed
- Optional memory + disk export ("both" mode)
- Self-contained bundled HTML generation (embedded CSS)
Code Quality:
- Better separation of concerns (Single Responsibility Principle)
- Pure functions enable easier unit testing
- Centralized file error handling via _write_file()
- Improved documentation (comprehensive docstrings)
- Explicit type hints with Literal types for output modes
Dependencies:
- Add lxml>=6.0.2,<7.0.0 for DOM manipulation
- Requires Python >=3.8
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Este es un refactor arquitectónico que introduce generación de HTML/CSS en memoria,
permitiendo integración seamless con aplicaciones downstream (PPG, frameworks
web) sin requerir I/O en disco por defecto.
Cambios Principales
1. Sistema de Construcción
poetry-corecomo build backend2. Arquitectura de Memoria
create_document()ahora soporta 3 modos de salida:"raw": Retorna dict con HTML y CSS en memoria"file": Escribe archivos en disco (comportamiento original)"both": Retorna contenido + escribe en discobundle_document()(NUEVO)<style>tag"raw"o"file"en el parametro"output")3. Mejoras de Código
helpers/fs.py (NUEVO)
_write_file()centraliza operaciones de escriturastyle_manager.py
CSSProcessor(NUEVO): Lógica pura de transformación CSSStyleManager: Adaptador de filesystemhtml_doc.py
Refactor completo del método
create_document()Literalpara parámetrosNuevo método
bundle_document()<style>taglxmlpara manipulación DOM segura4. Dependencias
lxml>=6.0.2,<7.0.0