diff --git a/crates/kodoc/src/commands/build.rs b/crates/kodoc/src/commands/build.rs index 8a047bb..5727f4b 100644 --- a/crates/kodoc/src/commands/build.rs +++ b/crates/kodoc/src/commands/build.rs @@ -548,8 +548,9 @@ fn resolve_manifest_deps(project_dir: &std::path::Path) -> Vec m, - Err(e) => { - eprintln!("warning: {e}"); + Err(_) => { + // kodo.toml exists but may be a trust-only config (no module/version/deps). + // Silently skip dependency loading in that case. return Vec::new(); } }; diff --git a/crates/kodoc/src/manifest.rs b/crates/kodoc/src/manifest.rs index 8d7abd8..62dca0a 100644 --- a/crates/kodoc/src/manifest.rs +++ b/crates/kodoc/src/manifest.rs @@ -76,14 +76,33 @@ pub(crate) enum Dependency { }, } +/// Minimal manifest used only for trust config extraction. +/// +/// Unlike [`Manifest`], this struct does not require `module` or `version`, +/// allowing a `kodo.toml` that contains only a `[trust]` section to parse +/// successfully. +#[derive(Debug, Deserialize, Default)] +struct TrustOnlyManifest { + #[serde(default)] + trust: Option, +} + /// Loads trust configuration for a source file by looking for `kodo.toml`. /// /// Searches only the immediate parent directory of `source_file`. Returns /// `TrustConfig::default()` (no validation) if no `kodo.toml` exists or /// if it has no `[trust]` section. +/// +/// Accepts both a full project manifest (with `module`/`version`) and a +/// minimal manifest containing only `[trust]`. pub(crate) fn load_trust_config(source_file: &Path) -> kodo_types::TrustConfig { let dir = source_file.parent().unwrap_or(Path::new(".")); - read_manifest(dir) + let manifest_path = dir.join("kodo.toml"); + let content = match std::fs::read_to_string(&manifest_path) { + Ok(c) => c, + Err(_) => return kodo_types::TrustConfig::default(), + }; + toml::from_str::(&content) .ok() .and_then(|m| m.trust) .map(TrustSection::into_trust_config)