Expand description
The versions check: hygiene versions [ROOT] fails when a text names
a version of riff.
§Design
A text, a rustdoc line and a page of the book describe the riff of
today. A version name in them ages: it was right on the day of the
release, and wrong on the next major release. So the code, its
tests and the book name no version of riff
(01M5R2XVDN99TE9NEJYY1GJE91, 01M5R2XVGMTB2HC9PRMS85ZWTY).
just check runs hygiene versions.
The rule versions finds each name of the form riff N or
riff N.M, also riff-server N, in each file of these folders
under ROOT (the default is .), but in
docs/src/requirements-history.md: a requirement that a new one
superseded in full moved there with its text unchanged, and its
history names versions. docs/src/requirements.md holds the rules of
today, so the check reads it.
It finds a name that a line break splits too: riff at the end of
a line, and the number at the start of the next one.
crates/*/srccrates/*/testsdocs/src
A use that must name a version stays. It is a line in the allow
list crates/hygiene/versions.allow:
PATH | TEXT | REASON- PATH is the path of the file from ROOT.
- TEXT is a part of a line of that file. It holds the version name. The line is allowed for each name in TEXT.
- REASON says why the name stays. The one allowed kind: a rule between versions, with its real text.
A line of the list that allows nothing is an error: the list holds
no old entry. A line that starts with # is a comment.
flowchart TD
F["each file of crates/*/src, crates/*/tests, docs/src"] --> L{"a line with<br/>riff N or riff N.M?"}
L -- no --> OK["pass"]
L -- yes --> A{"an allow line of the file<br/>holds that name?"}
A -- yes --> OK
A -- no --> E["error: rewrite the line,<br/>or allow it"]use hygiene::versions::{check, parse_allow};
// The sample is built, so that this file names no version.
let line = format!("riff {} runs on Linux only.", "3.0");
let file = ("crates/a/src/text.rs".to_owned(), format!("{line}\n"));
let errors = check(&[file.clone()], &[]);
assert_eq!(errors.len(), 1);
assert_eq!(errors[0].rule, "versions");
assert!(errors[0].text.starts_with("crates/a/src/text.rs:1: "));
let (allow, problems) = parse_allow(&format!(
"crates/a/src/text.rs | riff {} runs | the rule of a release\n",
"3.0"
));
assert!(problems.is_empty());
assert!(check(&[file], &allow).is_empty());Structs§
- Allowed
- A line of the allow list.
Constants§
- ALLOW_
FILE - The file of the allow list, from the root.
- SKIPPED
- The page that the check skips: the history of the requirements names versions.
Functions§
- check
- The errors of the files
files(each with its path from the root and its text) against the listallow: one for each line with a version name that no line of the list allows, and one for each line of the list that allows no name. - names
- The version names in
line, each as the range of its bytes:rifforriff-server, a space, and a numberNorN.Mwith any number of parts. A sentence dot after the number is not part of it. - parse_
allow - The lines of the allow list
source, and the errors in it: a line that is notPATH | TEXT | REASON, or that has an empty part. - scan
- The files that the check reads under
root, each with its path fromroot, in path order: each file incrates/*/src,crates/*/testsanddocs/src, butSKIPPEDand a file that is not UTF-8.