requirements.layout.project
Requirements index · View definition
Requirement
The Habeas Codicem project MUST keep its mdBook Markdown in
md/and Rust source insrc/, and its own book MUST use the Habeas preprocessor.
Rationale
The tests adequately cover requirements.layout.project. I derived three obligations from its text and mapped each to a test.
- Markdown in
md/:tests/repository.rs#fn[project_book_uses_the_repository_local_preprocessor_alias]asserts thatbook.tomlsetsbook.srctomd. It also asserts thatmd/SUMMARY.mdexists as a file. - Rust source in
src/:tests/repository.rs#fn[crate_targets_are_declared_in_src]asserts that theCargo.tomllib path issrc/lib.rs. It also asserts that the manifest has exactly one bin, namedhabeas, with pathsrc/main.rs. The first test additionally checks thatsrc/lib.rsandsrc/main.rsexist. - The book uses the Habeas preprocessor: The first test asserts that
preprocessor.habeasinbook.tomlhas the commandcargo habeas mdbookand the renderer list["html"]. It also asserts that.cargo/config.tomldefines thehabeasalias asrun --release -p habeas --. Together these show the book is wired to the project’s own preprocessor.
The helper repository_toml parses the file and returns the table, so the assertions run against the real repository files.
The tests check only the lib and bin targets, not every .rs file. I don’t count that as a gap, because the text doesn’t name any other Rust source and the target declarations are the natural check for “Rust source in src/”.
Inputs
Tests
Input 2: outline tests/repository.rs fn[project_book_uses_the_repository_local_preprocessor_alias]
- File:
tests/repository.rs - Selector:
fn[project_book_uses_the_repository_local_preprocessor_alias] - Kind:
fn tests/repository.rs:262–287
// {test}`requirements.cli.mdbook`
// {test}`requirements.layout.project`
#[test]
fn project_book_uses_the_repository_local_preprocessor_alias() {
let book = repository_toml("book.toml");
assert_eq!(book["book"]["src"].as_str(), Some("md"));
let preprocessor = &book["preprocessor"]["habeas"];
assert_eq!(
preprocessor["command"].as_str(),
Some("cargo habeas mdbook")
);
assert_eq!(
preprocessor["renderers"],
toml::Value::Array(vec!["html".into()])
);
let cargo = repository_toml(".cargo/config.toml");
assert_eq!(
cargo["alias"]["habeas"].as_str(),
Some("run --release -p habeas --")
);
let root = Path::new(env!("CARGO_MANIFEST_DIR"));
assert!(root.join("md/SUMMARY.md").is_file());
assert!(root.join("src/lib.rs").is_file());
assert!(root.join("src/main.rs").is_file());
}
Input 3: outline tests/repository.rs fn[crate_targets_are_declared_in_src]
- File:
tests/repository.rs - Selector:
fn[crate_targets_are_declared_in_src] - Kind:
fn tests/repository.rs:289–298
// {test}`requirements.layout.project`
#[test]
fn crate_targets_are_declared_in_src() {
let manifest = repository_toml("Cargo.toml");
assert_eq!(manifest["lib"]["path"].as_str(), Some("src/lib.rs"));
let bins = manifest["bin"].as_array().unwrap();
assert_eq!(bins.len(), 1);
assert_eq!(bins[0]["name"].as_str(), Some("habeas"));
assert_eq!(bins[0]["path"].as_str(), Some("src/main.rs"));
}
Other sources
Input 1: requirements selection requirements.layout.project
requirements.layout.project:md/requirements/layout.md:3–5
:::{req} project
The Habeas Codicem project MUST keep its mdBook Markdown in `md/` and Rust source in `src/`, and its own book MUST use the Habeas preprocessor.
:::
Input 4: outline tests/repository.rs fn[repository_toml]
- File:
tests/repository.rs - Selector:
fn[repository_toml] - Kind:
fn tests/repository.rs:18–21
// {cite}`habeas:util`
fn repository_toml(path: &str) -> toml::Table {
repository_file(path).parse().unwrap()
}