#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ build_gallery.py — Génère la galerie HTML du design system v2 depuis layouts_v2.yaml. Relancer après tout ajout de layout. Usage : python3 build_gallery.py → produit index.html """ import yaml import wireframes from pathlib import Path from datetime import datetime LAYOUTS = yaml.safe_load(open("layouts_v2.yaml", encoding="utf-8"))["layouts"] THEME = yaml.safe_load(open("theme_v2.yaml", encoding="utf-8")) C = THEME["colors"] NAVY = C["primary"]["navy"] NAVY2 = C["primary"]["navy_light"] CORAL = C["accent"]["coral"] GLACIER = C["secondary"]["glacier"] SLATE = C["secondary"]["slate"] CARD = C["backgrounds"]["card"] # Familles regroupées dans l'ordre d'apparition families = {} for name, cfg in LAYOUTS.items(): fam = cfg.get("famille", "Autres") families.setdefault(fam, []).append((name, cfg)) n_layouts = len(LAYOUTS) n_families = len(families) def card(name, cfg): lid = cfg.get("id", "") mode = cfg.get("mode", "light") hint = " ".join(cfg.get("agent_hint", "").split()) champs = ", ".join(cfg.get("champs", [])) requis = ", ".join(cfg.get("champs_requis", [])) thumb = wireframes.svg_for(name, mode) mode_badge = { "light": ("Clair", "#f4f1ec", NAVY), "dark": ("Sombre", NAVY, "#ffffff"), "panel": ("Panel", GLACIER, NAVY), }.get(mode, ("Clair", "#f4f1ec", NAVY)) return f"""
{lid} {mode_badge[0]}
{thumb}

{name}

{hint}

Champs{champs}
Requis{requis}
""" sections = "" for fam, items in families.items(): cards = "\n".join(card(n, c) for n, c in items) sections += f"""
{len(items)} layout{'s' if len(items)>1 else ''}

{fam}

{cards}
""" palette = "".join( f'
' f'
{label}
' f'
{hexv}
' for label, hexv in [ ("Navy", NAVY), ("Navy light", NAVY2), ("Coral", CORAL), ("Glacier", GLACIER), ("Slate", SLATE), ("Card", CARD)]) html = f""" Sliding Design System v2 — Pernod Ricard
Pernod Ricard · Data Governance

Sliding Design System v2

Catalogue des layouts disponibles dans le pipeline de génération automatique de présentations. Design system « PR Editorial » : navy dominant, accent corail, grille fixe et centrage vertical systématique.

Layouts{n_layouts}
Familles{n_families}
Version2.0
Palette

Charte chromatique

{palette}
{sections} """ Path("index.html").write_text(html, encoding="utf-8") print(f"index.html généré — {n_layouts} layouts, {n_families} familles")