merge: rules.md splits into one claims file per bookspec area (S-D0; branch t3/split-rules-md-claims-by-area, ca8d676d; lossless, rebuilt byte for byte)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
commit
b4479036a5
13 files changed
+3851
-3691
No files matched your search
@@ -1,26 +1,47 @@
|
||||
use crate::*;
|
||||
|
||||
/// `docs/spec/rules.md` carries every stated rule's id under its heading,
|
||||
/// and no longer calls a choice a decision (P13 step 3).
|
||||
/// `docs/spec/claims/*.md` carry every stated rule's id under its heading,
|
||||
/// `docs/spec/rules.md` indexes every rule to its claims file, and neither
|
||||
/// calls a choice a decision (P14 unit S-D0; P13 step 3).
|
||||
#[test]
|
||||
pub(crate) fn rules_md_carries_every_id() {
|
||||
let text = std::fs::read_to_string(
|
||||
Path::new(env!("CARGO_MANIFEST_DIR")).join("../../docs/spec/rules.md"),
|
||||
)
|
||||
.expect("docs/spec/rules.md");
|
||||
for rule in bookspec_checker::rules()
|
||||
.iter()
|
||||
.filter(|r| r.status.is_some())
|
||||
{
|
||||
let spec = Path::new(env!("CARGO_MANIFEST_DIR")).join("../../docs/spec");
|
||||
let index = std::fs::read_to_string(spec.join("rules.md")).expect("docs/spec/rules.md");
|
||||
|
||||
let mut claims = std::fs::read_dir(spec.join("claims"))
|
||||
.expect("docs/spec/claims")
|
||||
.map(|entry| entry.expect("a claims entry").path())
|
||||
.filter(|path| path.extension().is_some_and(|ext| ext == "md"))
|
||||
.collect::<Vec<_>>();
|
||||
claims.sort();
|
||||
assert!(!claims.is_empty(), "docs/spec/claims holds the rule text");
|
||||
|
||||
let mut all = String::new();
|
||||
for path in &claims {
|
||||
let text = std::fs::read_to_string(path)
|
||||
.unwrap_or_else(|error| panic!("{}: {error}", path.display()));
|
||||
all.push_str(&text);
|
||||
all.push('\n');
|
||||
}
|
||||
|
||||
for rule in bookspec_checker::rules().iter() {
|
||||
assert!(
|
||||
text.contains(&format!("**bookspec:** `{}`", rule.id)),
|
||||
"B-{} carries {}",
|
||||
index.contains(&format!("| B-{} | `{}` |", rule.b, rule.id)),
|
||||
"rules.md indexes B-{} to {}",
|
||||
rule.b,
|
||||
rule.id
|
||||
);
|
||||
if rule.status.is_some() {
|
||||
assert!(
|
||||
all.contains(&format!("**bookspec:** `{}`", rule.id)),
|
||||
"B-{} carries {} in its claims file",
|
||||
rule.b,
|
||||
rule.id
|
||||
);
|
||||
}
|
||||
}
|
||||
assert!(
|
||||
!text.contains("DECISION"),
|
||||
"rules.md speaks bookspec's CHOICE"
|
||||
!index.contains("DECISION") && !all.contains("DECISION"),
|
||||
"the rules speak bookspec's CHOICE"
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user