{html.escape(str(relative_path))}
" f"{html.escape(content)}"
"#!/usr/bin/env python3 r"""Aggregate UPDATES.md files below an explicitly selected directory into local HTML.""" from __future__ import annotations import argparse import html import os from datetime import datetime from pathlib import Path DEFAULT_OUTPUT = Path(__file__).resolve().parent.parent / "output/updates-aggregate.html" IGNORED_DIRS = {".git", ".hg", ".svn", ".venv", "node_modules"} def find_update_files(folder: Path) -> list[Path]: """Return the folder's UPDATES.md files in alphabetical path order.""" matches: list[Path] = [] for current_dir, dir_names, file_names in os.walk(folder): dir_names[:] = sorted( (name for name in dir_names if name not in IGNORED_DIRS), key=str.casefold, ) if "UPDATES.md" in file_names: matches.append(Path(current_dir) / "UPDATES.md") return sorted(matches, key=lambda path: str(path).casefold()) def build_html(projects_dir: Path) -> str: folders = sorted( (path for path in projects_dir.iterdir() if path.is_dir()), key=lambda path: path.name.casefold(), ) sections: list[str] = [] nav_items: list[str] = [] total_files = 0 for index, folder in enumerate(folders): update_files = find_update_files(folder) total_files += len(update_files) anchor = f"folder-{index}" background_class = " red-background" if index % 2 else "" nav_items.append( f'
{html.escape(content)}"
"No UPDATES.md files found.
') sections.append( f'{total_files} UPDATES.md files across {len(folders)} top-level folders.
Generated {html.escape(generated)} from the configured projects directory.