ast_doc_core/config.rs
1//! Configuration types for the ast-doc pipeline.
2
3use std::path::PathBuf;
4
5/// Output strategy for code extraction.
6///
7/// Ordering: `Full < NoTests < Summary` (increasing degradation level).
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Default, PartialOrd, Ord)]
9pub enum OutputStrategy {
10 /// Include all source code verbatim.
11 #[default]
12 Full,
13 /// Strip test modules and test functions.
14 NoTests,
15 /// Extract signatures only, omit implementations.
16 Summary,
17}
18
19impl OutputStrategy {
20 /// Return the next more-degraded strategy, or `None` if already at `Summary`.
21 #[must_use]
22 pub const fn degrade(self) -> Option<Self> {
23 match self {
24 Self::Full => Some(Self::NoTests),
25 Self::NoTests => Some(Self::Summary),
26 Self::Summary => None,
27 }
28 }
29}
30
31impl std::fmt::Display for OutputStrategy {
32 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
33 match self {
34 Self::Full => write!(f, "Full"),
35 Self::NoTests => write!(f, "NoTests"),
36 Self::Summary => write!(f, "Summary"),
37 }
38 }
39}
40
41/// Top-level configuration for the ast-doc pipeline.
42#[derive(Debug, Clone)]
43pub struct AstDocConfig {
44 /// Path to the project root directory.
45 pub path: PathBuf,
46 /// Output file path (None = stdout).
47 pub output: Option<PathBuf>,
48 /// Maximum token budget for the output.
49 pub max_tokens: usize,
50 /// Glob patterns for core files that should never be degraded.
51 pub core_patterns: Vec<String>,
52 /// Default output strategy for non-core files.
53 pub default_strategy: OutputStrategy,
54 /// Glob patterns to include (e.g., "*.rs").
55 pub include_patterns: Vec<String>,
56 /// Glob patterns to exclude (e.g., "*.txt").
57 pub exclude_patterns: Vec<String>,
58 /// Skip git context collection.
59 pub no_git: bool,
60 /// Skip directory tree generation.
61 pub no_tree: bool,
62 /// Copy output to clipboard.
63 pub copy: bool,
64 /// Enable verbose logging.
65 pub verbose: bool,
66}