import Spec.Courseware.Model.Primitives import Spec.Courseware.Export.Artifact /-! # Render —— export target = artifact + 有序 typed steps(ADR-0009 / 0011) ADR-0009:export target 是一次 build,产出一个有类型的 `Artifact`。ADR-0011 钉死 build 的**形状**:一个 target 是 `artifact` + 一串**有序 typed step**。 - `typstCompile template` —— 把**模板文件**(如 `exports/student.typ`)编译成产物。它是 *typed* 而非裸 shell,正因框架要把 **manifest 注入**模板(经 `--input manifest=…`), 裸字符串表达不了这个 wiring。presentation(编号、样式)住模板里,不在 manifest。 - `shell run` —— 逃生口,给难以声明的步骤(ADR-0005 的 (b) 类 medium-only)。 **渲染覆盖**:ADR-0011 废止了 per-target `RenderRule` 载荷——渲染的"how"已移进模板。 契约只保留覆盖声明 `covers`(该 target 渲染哪些 kind),供种子诊断用。 -/ namespace Spec.Courseware variable (P : Primitives) /-- 一个 build **step**(`PINNED` typed, ADR-0011;可扩展)。MVP 仅一个 `typstCompile`; `steps` 是 list 因为 FileTree / 第三方 build 会需多步。刻意不把模板内部、shell 命令的 解析结构写进来(实现细节, ADR-0011 OPEN)。 -/ inductive Step where /-- 编译模板文件 `template`(相对工程根)成产物;框架注入 manifest。typed 的理由: 注入这件事裸 shell 写不出。 -/ | typstCompile (template : String) /-- shell 逃生口:执行命令 `run`(ADR-0005 (b) 类落这)。MVP 不实现,先建结构。 -/ | shell (run : String) /-- 一个 export target 的 build 规格(`PINNED` artifact + 有序 steps, ADR-0011)。 -/ structure TargetSpec where /-- 产物(带字段, ADR-0011)。决定 build 折叠成单文件还是文件树。 -/ artifact : Artifact /-- **有序** build steps。按序执行;MVP 仅一个 `typstCompile`。 -/ steps : List Step /-- **覆盖声明**:`covers k` 表示此 target 渲染 kind `k`。ADR-0011 把旧 `renders : KindId → Option RenderRule` 降级后的产物——契约只声明"渲染哪些 kind" (种子诊断 `renderIgnored` 用),"how"由 `steps` 的模板实现。 -/ covers : P.KindId → Prop /-- 渲染配置(`PINNED` target-中心, ADR-0009/0011)。`spec t = none` 表示 target `t` 未声明(不导出);`some s` 给出其 build 规格。 -/ structure RenderConfig where /-- target ↦ 该 target 的 build 规格(未声明则 `none`)。 -/ spec : P.TargetId → Option (TargetSpec P) /-- kind `k` 在 target `t` 下**被渲染**(`PINNED`, ADR-0009/0011;承接 ADR-0005)。成立 ⟺ `t` 已声明(`spec t = some s`)**且** `s.covers k`。为假即"此 kind 在此 target 下不 被渲染"——checker 据此报 warning(见 `Diagnostic.renderIgnored`)。`P` 隐式以便点记法。 -/ def RenderConfig.covers {P : Primitives} (c : RenderConfig P) (k : P.KindId) (t : P.TargetId) : Prop := match c.spec t with | none => False | some s => s.covers k end Spec.Courseware