Files
Forge-Engine/document_engine/__init__.py
T
williamandClaude Sonnet 5 864ae697fd Ajoute le système de modèles/thèmes de document ("Utiliser un modèle")
Nouveau bouton dans le topbar de l'éditeur, à côté d'Aperçu, qui ouvre
une modale listant les thèmes du catalogue (document_engine/themes/).
Cliquer un thème charge un VRAI aperçu (rendu serveur réel dans un
iframe, jamais une resucée CSS côté client) avec le choix de garder le
contenu actuel ou de le remplacer par le contenu de démonstration du
modèle.

Architecture pensée pour une centaine de thèmes futurs : chaque thème
est une feuille de style externe (static/document/themes/<id>.css) qui
habille les classes fixes du moteur, jamais du code qui en changerait
la structure. Premier thème implémenté pour valider le mécanisme :
"Sécurité Incendie" (6 pages de contenu réel, quiz inclus).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
2026-09-24 09:12:57 +02:00

136 lines
4.5 KiB
Python

"""
document_engine — support de formation : entité racine séparée du jeu 2D
(voir docs/plan/PLAN.md). Un support est composé de plusieurs PAGES (voir
document_engine/pages/, retour utilisateur du 21/09/2026 : "il faut
implémenter un système de page") ; chaque page structure son propre
contenu en deux couches sur le même canevas :
le flux de contenu (titre/paragraphe/image/bouton/mini-jeux), organisé en
rangées ("row") par le moteur d'inférence de layout (voir
document_engine/rendering/render_document_element.py).
Tout est stocké dans support.db (voir db/supports/) : _document_pages (une
ligne par page) et _document_elements (chaque élément appartient à
exactement une page via page_id, avec parent_id NULL au top-niveau ou
enfant d'une rangée).
Aucun import croisé avec game_engine ou tout module lié au jeu 2D — voir
le contrat import-linter dans pyproject.toml (game_engine | document_engine
sont un même palier, mutuellement isolés).
Ce module se contente de ré-exporter l'intégralité de l'API publique du
paquet (pattern "un fichier = une fonction, un dossier = une responsabi-
lité", voir game_engine/__init__.py).
"""
from .elements.add_document_element import add_document_element
from .elements.delete_document_element import delete_document_element
from .elements.get_document_element import get_document_element
from .elements.list_document_elements import list_document_elements
from .elements.move_document_element import move_document_element
from .elements.move_document_element_to_page import move_document_element_to_page
from .elements.update_document_element_attributes import update_document_element_attributes
from .labels.association_config import (
DEFAULT_ASSOCIATION_CONFIG,
MAX_PAIRS,
MIN_PAIRS,
sanitize_association_config,
)
from .labels.element_kind_labels import (
CONTENT_KINDS,
ELEMENT_KIND_LABELS,
ELEMENT_LIBRARY,
MINIGAME_KINDS,
element_default_attributes,
)
from .labels.memory_config import (
CARD_MODES,
DEFAULT_MEMORY_CONFIG,
MAX_CARDS,
MIN_CARDS,
sanitize_memory_config,
)
from .labels.mots_config import (
DEFAULT_MOTS_CONFIG,
MAX_WORDS,
MIN_WORDS,
sanitize_mots_config,
)
from .labels.quiz_config import (
DEFAULT_QUIZ_CONFIG,
MAX_CHOICES,
MAX_TIMER_SECONDS,
MIN_CHOICES,
MIN_TIMER_SECONDS,
quiz_total_points,
sanitize_quiz_config,
)
from .labels.sanitize_element_attributes import sanitize_element_attributes
from .labels.scenario_config import (
DEFAULT_SCENARIO_CONFIG,
MAX_SCENARIO_CHOICES,
sanitize_scenario_config,
)
from .pages.add_document_page import add_document_page
from .pages.delete_document_page import delete_document_page
from .pages.get_document_page import get_document_page
from .pages.list_document_pages import list_document_pages
from .pages.move_document_page import move_document_page
from .pages.replace_document_content import replace_document_content
from .pages.update_document_page import update_document_page
from .rendering.render_document_element import render_document, render_document_element
from .rendering.sanitize_svg_markup import sanitize_svg_markup
from .themes.seed_blocks_to_elements import seed_blocks_to_elements
from .themes.theme_catalog import DOCUMENT_THEMES, get_document_theme_entry
__all__ = [
"CARD_MODES",
"CONTENT_KINDS",
"DEFAULT_ASSOCIATION_CONFIG",
"DEFAULT_MEMORY_CONFIG",
"DEFAULT_MOTS_CONFIG",
"DEFAULT_QUIZ_CONFIG",
"DEFAULT_SCENARIO_CONFIG",
"DOCUMENT_THEMES",
"ELEMENT_KIND_LABELS",
"ELEMENT_LIBRARY",
"MAX_CARDS",
"MAX_CHOICES",
"MAX_PAIRS",
"MAX_SCENARIO_CHOICES",
"MAX_TIMER_SECONDS",
"MAX_WORDS",
"MIN_CARDS",
"MIN_CHOICES",
"MIN_PAIRS",
"MIN_TIMER_SECONDS",
"MIN_WORDS",
"MINIGAME_KINDS",
"add_document_element",
"add_document_page",
"delete_document_element",
"delete_document_page",
"element_default_attributes",
"get_document_element",
"get_document_page",
"get_document_theme_entry",
"list_document_elements",
"list_document_pages",
"move_document_element",
"move_document_element_to_page",
"move_document_page",
"quiz_total_points",
"render_document",
"render_document_element",
"replace_document_content",
"sanitize_association_config",
"sanitize_element_attributes",
"sanitize_memory_config",
"sanitize_mots_config",
"sanitize_quiz_config",
"sanitize_scenario_config",
"sanitize_svg_markup",
"seed_blocks_to_elements",
"update_document_element_attributes",
"update_document_page",
]