# ============================================================
# src/accountable_record/stage_090_docs/render.py
# ============================================================
"""Render stage 090 documentation pages in memory.

WHY:
    Stage 090 realizes the render plan from plan.py into page content. render.py
    produces RenderedPage values held in memory for inspection. It is the op the
    validation layer drives after planning.

OBS (no writes):
    Rendering returns in-memory content only. It does not write into docs/.
    Following the write-intent convention of stage 060, a later emitter would
    act on these pages; the verifier does not.

OBS (minimal content):
    The rendered body is a stable, minimal Markdown stub keyed to the element
    compact_id. Page content generation is intentionally simple here; richer
    rendering can grow without changing the plan or reconciliation contract.
"""

from accountable_record.stage_090_docs.model import (
    DocsRenderPlan,
    PlannedPage,
    RenderedPage,
)

__all__ = ["render_pages"]


def render_pages(plan: DocsRenderPlan) -> tuple[RenderedPage, ...]:
    """Render every planned page into in-memory content.

    Args:
        plan: The documentation render plan.

    Returns:
        Rendered pages in the plan's order.
    """
    return tuple(_render_page(page) for page in plan.pages)


def _render_page(page: PlannedPage) -> RenderedPage:
    """Render one planned page into Markdown content."""
    content = f"# {page.title}\n\n`{page.compact_id}`\n"
    return RenderedPage(rel_path=page.rel_path, content=content)
