extern crate self as shallguard;
pub mod baseline;
pub mod bundle;
pub mod check;
pub mod config;
pub mod coverage;
mod coverage_llvm;
mod coverage_markdown;
pub mod docs;
pub mod evidence_mark;
pub mod impact;
mod impact_dependency;
pub mod requirement_format;
pub mod review;
pub mod review_workflow;
pub mod scan;
pub mod test_index;
mod test_index_markdown;
mod workspace;
use std::collections::{BTreeMap, BTreeSet};
#[shallguard_macros::enforces("REQ-TRACE-008")]
pub use shallguard_macros::{enforces, enforces_here, verifies};
pub use workspace::workspace_root;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum ProgressEvent<'a> {
Message(&'a str),
LiveStatus {
message: &'a str,
log_when_redirected: bool,
},
ClearLiveStatus,
}
pub type ProgressCallback = fn(ProgressEvent<'_>);
pub(crate) fn report_progress(progress: Option<ProgressCallback>, message: impl AsRef<str>) {
if let Some(progress) = progress {
progress(ProgressEvent::Message(message.as_ref()));
}
}
pub(crate) fn report_live_progress(
progress: Option<ProgressCallback>,
message: impl AsRef<str>,
log_when_redirected: bool,
) {
if let Some(progress) = progress {
progress(ProgressEvent::LiveStatus {
message: message.as_ref(),
log_when_redirected,
});
}
}
pub(crate) fn clear_live_progress(progress: Option<ProgressCallback>) {
if let Some(progress) = progress {
progress(ProgressEvent::ClearLiveStatus);
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
#[shallguard::enforces("REQ-PORT-002")]
pub struct DocSpec {
pub path: String,
pub source_root: String,
pub prefixes: BTreeMap<String, String>,
}
impl DocSpec {
pub fn new(
path: impl Into<String>,
source_root: impl Into<String>,
prefixes: BTreeMap<String, String>,
) -> Self {
Self {
path: path.into(),
source_root: source_root.into(),
prefixes,
}
}
pub fn source_roots(&self) -> BTreeSet<&str> {
std::iter::once(self.source_root.as_str())
.chain(self.prefixes.values().map(String::as_str))
.collect()
}
pub fn scan_roots(&self) -> BTreeSet<String> {
self.source_roots()
.into_iter()
.flat_map(|root| {
let root = if root == "." { "" } else { root };
[
format!("{root}{}src", if root.is_empty() { "" } else { "/" }),
format!("{root}{}tests", if root.is_empty() { "" } else { "/" }),
]
})
.collect()
}
}