forked from EduCraft/curriculum-project-hub
feat(cli): cph init / cph add 子命令(工程脚手架)
init 生成可 check 的工程根(manifest.toml + .cph-version + 默认 exports/student.typ + 空 kind 目录); add 按 kind 建 part 目录/element.toml/必填内容文件并追加 [[parts]]。均纯本地,不涉及 hub 语义; Engine 改惰性构造。cph-schema 新增 required_content_field_names() 作为 add 建文件合同。
This commit is contained in:
@@ -74,3 +74,25 @@ fn example_source_non_string_is_schema_violation() {
|
||||
assert!(diags[0].message.contains("source"));
|
||||
assert!(diags[0].message.contains("string"));
|
||||
}
|
||||
|
||||
/// `required_content_field_names` is the `cph-cli add` authoring contract: the
|
||||
/// set of sibling `.typ` files a new part of a kind must have to be
|
||||
/// schema-legal (ADR-0008). It must be the schema `required` content fields —
|
||||
/// not the optional ones (e.g. a lemma's `proof`) and not the scalar fields.
|
||||
#[test]
|
||||
fn required_content_field_names_match_schema_required() {
|
||||
let case = |kind: &str, expected: Vec<&str>| {
|
||||
let mut got: Vec<&str> = cph_schema::schema_for(kind)
|
||||
.unwrap()
|
||||
.required_content_field_names();
|
||||
got.sort_unstable();
|
||||
let mut want = expected;
|
||||
want.sort_unstable();
|
||||
assert_eq!(got, want, "required content fields for '{kind}'");
|
||||
};
|
||||
|
||||
case("segment", vec!["textbook"]);
|
||||
case("lemma", vec!["stmt"]);
|
||||
case("example", vec!["problem", "solution"]);
|
||||
case("sop", vec!["sop"]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user