forked from EduCraft/curriculum-project-hub
feat(cph): implement nested outline manifest and batch/combined export
ADR-0029 — nested outline manifest, supersedes ADR-0008's flat [[parts]]:
- cph-model: recursive loader over manifest.toml containers / element.toml
leaves; Lesson.parts (pure elements, DFS order) + Lesson.outline (elements
interleaved with section headings at their DFS-open position); rejects
ambiguous/incomplete folders and root-vs-container table misplacement
- cph-diag: new DiagCode::ManifestMalformed for carrier-document structure
errors (discharges an existing TODO)
- cph-typst: augmented manifest now serializes the outline (element/section
entries) instead of a flat parts array
- render/lib.typ: render-lesson renders section headings at their depth
- examples/TH-141 migrated to 5 nested section containers + 3 root segments,
byte-identical element order; smoke-verified via cph check/build + pdftotext
ADR-0030 — batch & combined export, extends ADR-0009/0011:
- cph build with no --target batches every declared target (repeatable
--target for an explicit subset); any target failure => non-zero exit,
per-target ledger, independent per-target execution
- cph-model: bundle.toml loader (directory + [info]/[targets.*]/ordered
lessons with per-lesson target overrides)
- cph-typst: augmented bundle manifest (path-prefixed member outlines),
Engine::{compile_check_bundle,build_bundle_pdf}
- render/lib.typ: render-bundle assembles member lessons under per-lesson
headings, depth-shifts their own section headings, resets example/lemma
counters at each lesson boundary by default
- cph-cli: `cph bundle <path> --target <name>` subcommand, same batching
contract as `cph build`
- new bundle fixtures/tests (cph-model unit + cph-typst through-template PDF
compile), smoke-verified via a real 2-lesson merged PDF
Verification: cargo fmt/clippy/test clean across the workspace (68 tests);
real cph check/build/bundle runs against TH-141 and a bundle fixture, PDF
content inspected via pdftotext.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
[project]
|
||||
id = "fixture-both"
|
||||
name = "both"
|
||||
|
||||
[info]
|
||||
title = "文件夹既是容器又是叶子"
|
||||
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/broken"
|
||||
|
||||
[targets.student]
|
||||
+1
@@ -0,0 +1 @@
|
||||
kind = "segment"
|
||||
+1
@@ -0,0 +1 @@
|
||||
[[children]]
|
||||
@@ -0,0 +1,2 @@
|
||||
[info
|
||||
this is broken
|
||||
@@ -0,0 +1,5 @@
|
||||
[info]
|
||||
title = "缺失课时的合集"
|
||||
|
||||
[[lessons]]
|
||||
path = "does-not-exist"
|
||||
@@ -0,0 +1,16 @@
|
||||
[info]
|
||||
title = "测试合集"
|
||||
author = ["张老师", "李老师"]
|
||||
|
||||
[[lessons]]
|
||||
path = "lesson-a"
|
||||
|
||||
[[lessons]]
|
||||
path = "lesson-b"
|
||||
target = "teacher"
|
||||
|
||||
[targets.merged]
|
||||
artifact = { type = "single-file", filepath = "build/merged.pdf" }
|
||||
[[targets.merged.steps]]
|
||||
type = "typst-compile"
|
||||
template = "exports/merged.typ"
|
||||
@@ -0,0 +1,12 @@
|
||||
[project]
|
||||
id = "lesson-a"
|
||||
name = "lesson-a"
|
||||
|
||||
[info]
|
||||
title = "课时A"
|
||||
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/a"
|
||||
|
||||
[targets.student]
|
||||
@@ -0,0 +1 @@
|
||||
kind = "segment"
|
||||
@@ -0,0 +1 @@
|
||||
A.
|
||||
@@ -0,0 +1,12 @@
|
||||
[project]
|
||||
id = "lesson-b"
|
||||
name = "lesson-b"
|
||||
|
||||
[info]
|
||||
title = "课时B"
|
||||
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/b"
|
||||
|
||||
[targets.teacher]
|
||||
@@ -0,0 +1 @@
|
||||
kind = "segment"
|
||||
@@ -0,0 +1 @@
|
||||
B.
|
||||
@@ -0,0 +1,12 @@
|
||||
[project]
|
||||
id = "fixture-container-root-tables"
|
||||
name = "container-root-tables"
|
||||
|
||||
[info]
|
||||
title = "容器错误声明了根级表"
|
||||
|
||||
[[children]]
|
||||
kind = "section"
|
||||
path = "section"
|
||||
|
||||
[targets.student]
|
||||
@@ -0,0 +1,5 @@
|
||||
[project]
|
||||
id = "should-not-be-here"
|
||||
name = "should-not-be-here"
|
||||
|
||||
children = []
|
||||
@@ -5,7 +5,7 @@ name = "kind-mismatch"
|
||||
[info]
|
||||
title = "kind 不一致测试"
|
||||
|
||||
[[parts]]
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/intro"
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ name = "missing-part"
|
||||
[info]
|
||||
title = "缺部件测试"
|
||||
|
||||
[[parts]]
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/intro"
|
||||
|
||||
[[parts]]
|
||||
[[children]]
|
||||
kind = "lemma"
|
||||
path = "lemmas/does-not-exist"
|
||||
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
[project]
|
||||
id = "fixture-neither"
|
||||
name = "neither"
|
||||
|
||||
[info]
|
||||
title = "文件夹既不是容器也不是叶子"
|
||||
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/broken"
|
||||
|
||||
[targets.student]
|
||||
@@ -0,0 +1,16 @@
|
||||
[project]
|
||||
id = "fixture-nested"
|
||||
name = "nested"
|
||||
|
||||
[info]
|
||||
title = "嵌套结构测试"
|
||||
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/开场白"
|
||||
|
||||
[[children]]
|
||||
kind = "section"
|
||||
path = "导言簇"
|
||||
|
||||
[targets.student]
|
||||
@@ -0,0 +1 @@
|
||||
kind = "segment"
|
||||
@@ -0,0 +1 @@
|
||||
开场白。
|
||||
@@ -0,0 +1,14 @@
|
||||
[group]
|
||||
title = "导言簇"
|
||||
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/子段一"
|
||||
|
||||
[[children]]
|
||||
kind = "section"
|
||||
path = "嵌套子节"
|
||||
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/子段二"
|
||||
@@ -0,0 +1 @@
|
||||
kind = "segment"
|
||||
@@ -0,0 +1 @@
|
||||
子段一。
|
||||
@@ -0,0 +1 @@
|
||||
kind = "segment"
|
||||
@@ -0,0 +1 @@
|
||||
子段二。
|
||||
@@ -0,0 +1 @@
|
||||
kind = "lemma"
|
||||
@@ -0,0 +1 @@
|
||||
子引理陈述。
|
||||
@@ -0,0 +1,3 @@
|
||||
[[children]]
|
||||
kind = "lemma"
|
||||
path = "lemmas/子引理"
|
||||
@@ -0,0 +1,15 @@
|
||||
[project]
|
||||
id = "fixture-root-group"
|
||||
name = "root-group"
|
||||
|
||||
[info]
|
||||
title = "根级 manifest 错误声明了 group"
|
||||
|
||||
[group]
|
||||
title = "不该在根级"
|
||||
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/a"
|
||||
|
||||
[targets.student]
|
||||
@@ -0,0 +1 @@
|
||||
kind = "segment"
|
||||
@@ -0,0 +1 @@
|
||||
a.
|
||||
+2
-2
@@ -6,11 +6,11 @@ name = "valid-2-part"
|
||||
title = "测试课:两个部件"
|
||||
author = "范式教育教研组"
|
||||
|
||||
[[parts]]
|
||||
[[children]]
|
||||
kind = "segment"
|
||||
path = "segments/intro"
|
||||
|
||||
[[parts]]
|
||||
[[children]]
|
||||
kind = "lemma"
|
||||
path = "lemmas/young"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user