feat(cph): add outline export command

This commit is contained in:
2026-08-05 16:34:02 +08:00
committed by 洪佳荣
parent 9927d38c18
commit fe8a17c6ad
15 changed files with 635 additions and 56 deletions
+1
View File
@@ -9,6 +9,7 @@ author = "范式教育教研组"
[[children]]
kind = "segment"
path = "segments/intro"
notes = "这一节补充一个直观例题"
[[children]]
kind = "lemma"
+37 -6
View File
@@ -35,6 +35,17 @@ fn valid_two_part_lesson_loads_in_order_with_no_errors() {
assert_eq!(lesson.parts.len(), 2);
assert_eq!(lesson.parts[0].kind, "segment");
assert_eq!(lesson.parts[0].path, PathBuf::from("segments/intro"));
assert_eq!(
lesson.parts[0].notes.as_deref(),
Some("这一节补充一个直观例题")
);
let outline = lesson.outline_document();
assert_eq!(outline.children[0].title, "intro");
assert_eq!(
outline.children[0].notes.as_deref(),
Some("这一节补充一个直观例题")
);
assert!(outline.children[0].children.is_empty());
assert_eq!(lesson.parts[0].descriptor.kind, "segment");
assert_eq!(lesson.parts[1].kind, "lemma");
assert_eq!(lesson.parts[1].path, PathBuf::from("lemmas/young"));
@@ -45,8 +56,14 @@ fn valid_two_part_lesson_loads_in_order_with_no_errors() {
assert_eq!(
lesson.outline,
vec![
OutlineEntry::Element { part_index: 0 },
OutlineEntry::Element { part_index: 1 },
OutlineEntry::Element {
part_index: 0,
depth: 0,
},
OutlineEntry::Element {
part_index: 1,
depth: 0,
},
]
);
@@ -114,22 +131,36 @@ fn nested_sections_flatten_depth_first_with_correct_depths() {
assert_eq!(
lesson.outline,
vec![
OutlineEntry::Element { part_index: 0 }, // segments/开场白
OutlineEntry::Element {
part_index: 0,
depth: 0,
}, // segments/开场白
OutlineEntry::Section {
kind: "section".to_string(),
title: "导言簇".to_string(),
depth: 1,
notes: None,
path: PathBuf::from("导言簇"),
},
OutlineEntry::Element { part_index: 1 }, // 导言簇/segments/子段一
OutlineEntry::Element {
part_index: 1,
depth: 1,
}, // 导言簇/segments/子段一
OutlineEntry::Section {
kind: "section".to_string(),
title: "嵌套子节".to_string(),
depth: 2,
notes: None,
path: PathBuf::from("导言簇/嵌套子节"),
},
OutlineEntry::Element { part_index: 2 }, // 导言簇/嵌套子节/lemmas/子引理
OutlineEntry::Element { part_index: 3 }, // 导言簇/segments/子段二
OutlineEntry::Element {
part_index: 2,
depth: 2,
}, // 导言簇/嵌套子节/lemmas/子引理
OutlineEntry::Element {
part_index: 3,
depth: 1,
}, // 导言簇/segments/子段二
]
);