pub struct Expected {
pub includes: HashMap<(RepoPath, usize), Option<String>>,
pub fences: HashMap<(RepoPath, usize), Fenced>,
pub bodies: HashMap<(RepoPath, usize), String>,
pub definitions: HashMap<RepoPath, Option<Vec<DefinitionEntry>>>,
pub cycles: Vec<Vec<RepoPath>>,
pub on_cycle: HashSet<RepoPath>,
pub layout: Layout,
}Expand description
An Expected holds what every generated block should hold.
Fields§
§includes: HashMap<(RepoPath, usize), Option<String>>This map holds the interior of each include block, keyed by file and
by the line of its open marker. The value is None when the interior
can’t be regenerated.
fences: HashMap<(RepoPath, usize), Fenced>This map holds the source of each include block that holds a file
in a fence, keyed as includes is. An include block of a document’s
body has no entry.
bodies: HashMap<(RepoPath, usize), String>This map holds the path from the root, as same-same reads it, of the
document whose body each include block of a body holds, keyed as
includes is.
definitions: HashMap<RepoPath, Option<Vec<DefinitionEntry>>>This map holds the definition entries of each file. The list is empty
when the file needs no block, and the value is None when a label
doesn’t resolve.
cycles: Vec<Vec<RepoPath>>cycles lists each include cycle as the files on it.
on_cycle: HashSet<RepoPath>on_cycle holds every file that lies on an include cycle.
layout: Layoutlayout records which blocks that differ from their expected text
same-same finds the same (CLI-4_AC-45).
Implementations§
Source§impl Expected
impl Expected
Sourcepub fn include(&self, path: &RepoPath, line: usize) -> Option<&str>
pub fn include(&self, path: &RepoPath, line: usize) -> Option<&str>
include returns the expected interior of the include block that
opens at line in path, when the interior can be regenerated.
Sourcepub fn include_pair(
&self,
path: &RepoPath,
line: usize,
content: &str,
) -> Option<Pair>
pub fn include_pair( &self, path: &RepoPath, line: usize, content: &str, ) -> Option<Pair>
include_pair returns the pair of texts that same-same compares
for the include block that opens at line in path and holds
content, when the block differs from its expected interior. An
include of a file compares the code inside the fence under the path
of its source, a region of it as a part of a file, and an
include of a body compares the whole interior under the path of the
included document (CLI-4_AC-113). It returns None when the
block has no expected interior, holds it, or holds a fence of another
form.
Sourcepub fn include_current(
&self,
path: &RepoPath,
line: usize,
content: &str,
) -> Option<bool>
pub fn include_current( &self, path: &RepoPath, line: usize, content: &str, ) -> Option<bool>
include_current returns whether the include block that opens at
line in path and holds content is current: whether it holds its
expected interior, or same-same finds the two the same. It returns
None when the block has no expected interior.
Sourcepub fn include_stale(
&self,
path: &RepoPath,
line: usize,
content: &str,
written: &str,
) -> (Option<Finding>, String)
pub fn include_stale( &self, path: &RepoPath, line: usize, content: &str, written: &str, ) -> (Option<Finding>, String)
include_stale returns the warning that the formatter failed on the
texts of the stale include block that opens at line in path,
holds content, and whose target is written as written, when it
did, and the message of its finding.