docs(adr): cph 的 nested-manifest / batch-export 改号 0036/0037

上游 0029/0030 与本地 filelib 侧同号 ADR 相撞,cph 两份改到本地空闲号段,
代码锚点引用一并跟随。
This commit is contained in:
2026-08-06 00:51:33 +08:00
parent e878b46701
commit ecc92c9a87
27 changed files with 100 additions and 100 deletions
+3 -3
View File
@@ -181,7 +181,7 @@ impl Engine {
))
}
/// Compile-check `bundle` for `target` (ADR-0030) — same contract as
/// Compile-check `bundle` for `target` (ADR-0037) — same contract as
/// [`Engine::compile_check`], but over a [`Bundle`]'s own declared targets
/// and the augmented **bundle** manifest (each member lesson's outline,
/// path-prefixed to resolve against the bundle root).
@@ -200,7 +200,7 @@ impl Engine {
out
}
/// Build a PDF for `bundle` / `target` (ADR-0030) — same contract as
/// Build a PDF for `bundle` / `target` (ADR-0037) — same contract as
/// [`Engine::build_pdf`], over a [`Bundle`]'s own declared targets.
pub fn build_bundle_pdf(
&self,
@@ -244,7 +244,7 @@ impl Default for Engine {
/// Validate a `(targets, target)` request and resolve the template path to
/// compile. Shared by [`Engine::world_for`] (a lesson's `targets`) and
/// [`Engine::world_for_bundle`] (a bundle's own `targets` — ADR-0030 gives a
/// [`Engine::world_for_bundle`] (a bundle's own `targets` — ADR-0037 gives a
/// bundle target the exact same build/artifact/step shape). Returns
/// `Ok(template_path)` (relative to the lesson/bundle root) when the request is
/// buildable, or `Err(blocking_diagnostics)` when it is not:
+8 -8
View File
@@ -1,4 +1,4 @@
//! Augmented-manifest construction (ADR-0011, outline shape per ADR-0029).
//! Augmented-manifest construction (ADR-0011, outline shape per ADR-0036).
//!
//! The template (`exports/<target>.typ`) reads the manifest via
//! `toml(sys.inputs.manifest)`, then for each **element** outline entry
@@ -10,13 +10,13 @@
//!
//! The ENGINE has filesystem access, so it closes that gap: it builds an
//! **augmented manifest** = the lesson's `[info]` + the ordered `[[outline]]`
//! (ADR-0029's depth-first rendering order — elements interleaved with section
//! (ADR-0036's depth-first rendering order — elements interleaved with section
//! headings at their DFS-open position). Each `[[outline]]` entry carries a
//! `type` discriminator (`"element"` | `"section"`):
//!
//! - `type = "element"`: `kind`, `path`, and a per-part **`fields` array**
//! listing the content fields whose `<field>.typ` actually exists under the
//! lesson root (same contract as before ADR-0029).
//! lesson root (same contract as before ADR-0036).
//! - `type = "section"`: `kind`, `title`, `depth`, `path` — a section heading;
//! the template renders it without touching any content file.
//!
@@ -41,7 +41,7 @@ use cph_model::{Bundle, BundleLesson, Lesson, OutlineEntry};
///
/// The result is a self-contained TOML document the template's
/// `toml(sys.inputs.manifest)` reads. It carries `[info]` (title + optional
/// author) and the ordered `[[outline]]` (ADR-0029's depth-first rendering
/// author) and the ordered `[[outline]]` (ADR-0036's depth-first rendering
/// order), each entry typed `"element"` or `"section"` per the module docs. It
/// does **not** reproduce `[project]` or `[targets.*]` — the template only
/// consumes `info` and `outline`.
@@ -50,7 +50,7 @@ pub fn build_augmented_manifest(lesson: &Lesson) -> String {
doc.insert("info".to_string(), toml::Value::Table(info_table(lesson)));
// [[outline]] — ADR-0029's depth-first rendering order: elements
// [[outline]] — ADR-0036's depth-first rendering order: elements
// interleaved with section headings at their DFS-open position.
let outline: Vec<toml::Value> = lesson
.outline
@@ -62,7 +62,7 @@ pub fn build_augmented_manifest(lesson: &Lesson) -> String {
toml::to_string(&doc).expect("augmented manifest serializes")
}
/// Build the augmented **bundle** manifest TOML source for `bundle` (ADR-0030).
/// Build the augmented **bundle** manifest TOML source for `bundle` (ADR-0037).
///
/// The bundle template (`exports/<target>.typ` under the `bundle.toml` root)
/// reads it via `toml(sys.inputs.manifest)`. It carries `[info]` (the bundle's
@@ -71,7 +71,7 @@ pub fn build_augmented_manifest(lesson: &Lesson) -> String {
/// would assemble, except every outline entry's `path` is **prefixed with that
/// lesson's own bundle-root-relative directory** (`BundleLesson::path`), since
/// the bundle template's computed include paths resolve against the *bundle*
/// root, not each lesson's own root (ADR-0030: combination reads
/// root, not each lesson's own root (ADR-0037: combination reads
/// already-authored lessons at export time; each lesson's `path` bookkeeping
/// stays correct because the prefix is applied only here, in the manifest the
/// template consumes — never inside a lesson's own authored content).
@@ -147,7 +147,7 @@ fn info_table(lesson: &Lesson) -> toml::Table {
}
/// Build one `[[outline]]` entry's table for either variant of
/// [`OutlineEntry`]. `bundle_prefix`, when set (ADR-0030's bundle case), is
/// [`OutlineEntry`]. `bundle_prefix`, when set (ADR-0037's bundle case), is
/// joined onto the emitted `path` so the bundle template's computed include
/// resolves against the bundle root rather than the lesson's own root.
fn outline_entry_table(
+2 -2
View File
@@ -1,4 +1,4 @@
//! Integration tests for the bundle build path (ADR-0030): compiling a bundle
//! Integration tests for the bundle build path (ADR-0037): compiling a bundle
//! target's template (`exports/<target>.typ` under a `bundle.toml` root) as
//! main, injecting the augmented **bundle** manifest, against the real
//! `render/` package.
@@ -32,7 +32,7 @@ fn load_bundle() -> cph_model::Bundle {
/// PURE UNIT TEST (no fonts, no render package): the augmented bundle manifest
/// carries the bundle's own `[info]` and an ordered `[[lessons]]`, each with
/// that member's own `info`/`target` and a `path`-prefixed outline (ADR-0030).
/// that member's own `info`/`target` and a `path`-prefixed outline (ADR-0037).
#[test]
fn augmented_bundle_manifest_prefixes_member_paths() {
let bundle = load_bundle();
+2 -2
View File
@@ -39,7 +39,7 @@ fn load_mini() -> cph_model::Lesson {
}
/// PURE UNIT TEST (no fonts, no render package): the augmented manifest carries
/// `[info]` and the ordered `[[outline]]` (ADR-0029) — elements (with a
/// `[info]` and the ordered `[[outline]]` (ADR-0036) — elements (with a
/// per-element `fields` array of the content fields present on disk)
/// interleaved with the section heading the mini fixture nests its two lemmas
/// under.
@@ -58,7 +58,7 @@ fn augmented_manifest_has_outline_with_section_and_fields() {
.get("outline")
.and_then(|p| p.as_array())
.expect("outline array present");
// segment, section, lemma, lemma, example — 5 entries (ADR-0029: the
// segment, section, lemma, lemma, example — 5 entries (ADR-0036: the
// section contributes a heading entry, not an element).
assert_eq!(outline.len(), 5, "five outline entries:\n{src}");
+2 -2
View File
@@ -1,4 +1,4 @@
// DEFAULT BUNDLE TEMPLATE (ADR-0030, outline shape ADR-0029).
// DEFAULT BUNDLE TEMPLATE (ADR-0037, outline shape ADR-0036).
//
// Lives in a bundle at `<bundle-root>/exports/<target>.typ`, e.g.
// `exports/merged.typ`. Compiled AS MAIN with the augmented BUNDLE manifest
@@ -66,7 +66,7 @@
))
// Presentation: shared per-level heading numbering across the whole bundle,
// and the ADR-0030 recommended default of resetting auto-counters at each
// and the ADR-0037 recommended default of resetting auto-counters at each
// lesson boundary (override `reset-counters: false` for continuous numbering).
#render-bundle(
info: info,
+3 -3
View File
@@ -1,4 +1,4 @@
// DEFAULT STUDENT TEMPLATE (framework default; ADR-0011, outline shape ADR-0029).
// DEFAULT STUDENT TEMPLATE (framework default; ADR-0011, outline shape ADR-0036).
//
// This is a *real, editable* file that lives in an engineering file at
// `exports/student.typ`. The framework compiles it AS THE MAIN FILE with the
@@ -16,7 +16,7 @@
// PACKAGE, not the engineering root. A `/<part.path>/<field>.typ` written HERE
// (this template lives under `--root`) resolves against `--root`. So the
// template loads content and hands cph-render an already-assembled `outline`
// array (elements interleaved with section headings, ADR-0029).
// array (elements interleaved with section headings, ADR-0036).
//
// OPEN CONTRACT POINT — optional-content presence. typst has no "does this file
// exist" primitive (a missing `include` is a hard compile error). So the
@@ -43,7 +43,7 @@
// resolved against --root) and read scalar fields from <path>/element.toml.
// `part-fields` (from cph-render) is the single source of truth for
// kind->fields.
// - a "section" entry (ADR-0029): pass its title/depth straight through — no
// - a "section" entry (ADR-0036): pass its title/depth straight through — no
// content to load, it is a heading.
#let outline = raw-outline.map(raw => {
if raw.at("type", default: "element") == "section" {
+2 -2
View File
@@ -1,4 +1,4 @@
// DEFAULT TEACHER TEMPLATE (framework default; ADR-0011, outline shape ADR-0029).
// DEFAULT TEACHER TEMPLATE (framework default; ADR-0011, outline shape ADR-0036).
//
// Lives in an engineering file at `exports/teacher.typ`. Compiled AS MAIN with
// the manifest injected:
@@ -21,7 +21,7 @@
#let raw-outline = manifest.at("outline", default: ())
// Assemble each outline entry: an "element" entry includes its content fields
// and reads scalars from element.toml; a "section" entry (ADR-0029) passes
// and reads scalars from element.toml; a "section" entry (ADR-0036) passes
// title/depth straight through as a heading, no content to load.
#let outline = raw-outline.map(raw => {
if raw.at("type", default: "element") == "section" {