use std::path::PathBuf;
#[derive(Debug, Clone)]
pub struct Config {
pub out_dir: PathBuf,
pub preset: Preset,
pub strict: bool,
pub check: bool,
pub exclude: Vec<String>,
pub platforms: Vec<Platform>,
pub emit_error_catalog: bool,
}
impl Default for Config {
fn default() -> Self {
Self {
out_dir: PathBuf::from("docs/aidoc"),
preset: Preset::Publish,
strict: false,
check: false,
exclude: Vec::new(),
platforms: Vec::new(),
emit_error_catalog: false,
}
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Preset {
Publish,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum Platform {
Context7,
DeepWiki,
AnthropicStyle,
}
impl Platform {
pub fn as_str(self) -> &'static str {
match self {
Self::Context7 => "context7",
Self::DeepWiki => "deepwiki",
Self::AnthropicStyle => "anthropic-style",
}
}
}
impl std::str::FromStr for Platform {
type Err = UnknownPlatform;
fn from_str(s: &str) -> std::result::Result<Self, Self::Err> {
match s {
"context7" => Ok(Self::Context7),
"deepwiki" => Ok(Self::DeepWiki),
"anthropic-style" => Ok(Self::AnthropicStyle),
other => Err(UnknownPlatform(other.to_owned())),
}
}
}
#[derive(Debug, Clone)]
pub struct UnknownPlatform(pub String);
impl std::fmt::Display for UnknownPlatform {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(
f,
"unknown platform `{}`; expected one of: context7, deepwiki, anthropic-style",
self.0
)
}
}
impl std::error::Error for UnknownPlatform {}