docs: Add comprehensive documentation for modes, services, and plugins

Co-authored-by: aider (openai/andrew/openrouter/sonoma-sky-alpha) <aider@aider.chat>
This commit is contained in:
Andrew Phillips
2025-09-10 14:29:16 -03:00
parent d44f3fbb5b
commit 88c7290a7b
6 changed files with 146 additions and 12 deletions

View File

@@ -3,6 +3,9 @@ use std::io::{Result, Read, Write, BufRead};
use regex::Regex;
/// A filter that matches lines against a regular expression pattern.
///
/// Outputs only lines that match the given regex.
#[derive(Debug, Clone)]
pub struct GrepFilter {
regex: Regex,
}
@@ -16,7 +19,7 @@ impl GrepFilter {
///
/// # Errors
///
/// Returns an `io::Error` if the regex pattern is invalid.
/// Returns an `io::Error` with `InvalidInput` if the regex pattern is invalid.
pub fn new(pattern: String) -> Result<Self> {
let regex = Regex::new(&pattern)
.map_err(|e| std::io::Error::new(std::io::ErrorKind::InvalidInput, e))?;
@@ -29,6 +32,8 @@ impl GrepFilter {
impl FilterPlugin for GrepFilter {
/// Filters the input by writing only lines that match the regex pattern.
///
/// Reads lines from the input and writes matching lines to the output, preserving newlines.
///
/// # Arguments
///
/// * `reader` - A boxed mutable reference to the input reader providing the data stream.
@@ -37,6 +42,10 @@ impl FilterPlugin for GrepFilter {
/// # Returns
///
/// Returns `Ok(())` on success, or an `io::Error` if reading or writing fails.
///
/// # Errors
///
/// Propagates `io::Error` from reading lines or writing output.
fn filter(&mut self, mut reader: Box<&mut dyn Read>, mut writer: Box<&mut dyn Write>) -> Result<()> {
let mut buf_reader = std::io::BufReader::new(&mut *reader);
for line in buf_reader.by_ref().lines() {
@@ -50,6 +59,8 @@ impl FilterPlugin for GrepFilter {
/// Clones this filter into a new boxed instance.
///
/// Creates a new GrepFilter with the same regex pattern.
///
/// # Returns
///
/// A new `Box<dyn FilterPlugin>` representing a clone of this filter.
@@ -61,6 +72,8 @@ impl FilterPlugin for GrepFilter {
/// Returns the configuration options for this filter.
///
/// The only option is the required "pattern" for the regex.
///
/// # Returns
///
/// A vector of `FilterOption` describing the filter's configurable parameters.