Goal: Break down the 2,146-line src/blogmore/generator.py into a focused package to improve maintainability, reduce "God Object" complexity, and adhere to a <1000 line-per-file standard.
Create a new package directory: src/blogmore/generator/.
| Sub-module | Responsibilities |
|---|---|
site.py |
High-level orchestration. Contains the SiteGenerator class and the primary generate() loop. |
assets.py |
Implementation of icon generation, FontAwesome optimization, CSS/JS minification, and static/extras copying. |
paths.py |
URL calculations, output path resolution, and canonical URL logic. |
context.py |
Global template context preparation and sidebar page resolution. |
grouping.py |
Logic for grouping posts by tags, categories, and dates; includes word-cloud calculation logic. |
listing.py |
The generate_paginated_listing boilerplate used by archives, tags, and categories. |
utils.py |
Shared helpers like minified_filename and paginate_posts. |
constants.py |
Filename constants and internal configuration lists (e.g., PAGE_SPECIFIC_CSS). |
__init__.py |
Public API surface to ensure backward compatibility for from blogmore.generator import SiteGenerator. |
- Abstract the Rendering Pipeline: Consolidate the repetitive 5-step pattern used in over 10 different
_generate_X_pagemethods into a single internal utility. - Unify Minification: Merge the nearly identical CSS and JS minification logic to reduce code duplication.
- Centralize Path Logic: Replace manual string manipulation and repeated
lstrip("/")calls with centralized helpers inpaths.py. - Encapsulate Side Effects: Move low-level file system operations (like
shutil.copy2andminify_html) out of the main class and into focused asset handlers.
- Ensure all 330+ unit tests in
tests/test_generator.pypass. - Verify that integration tests in
tests/test_integration.pyconfirm the site still builds correctly end-to-end. - Maintain private method wrappers in
SiteGeneratorwhere necessary to avoid breaking tests that rely on internal method names.