pub mod man;
use crate::error::Result;
pub struct DocumentationGenerator {
command_name: String,
version: String,
}
impl DocumentationGenerator {
pub fn new(command_name: String, version: String) -> Self {
Self {
command_name,
version,
}
}
pub fn generate_all(&self, output_dir: &std::path::Path) -> Result<()> {
std::fs::create_dir_all(output_dir)?;
self.generate_man_pages(output_dir)?;
Ok(())
}
pub fn generate_man_pages(&self, output_dir: &std::path::Path) -> Result<()> {
let man_dir = output_dir.join("man");
std::fs::create_dir_all(&man_dir)?;
man::generate_main_man_page(&self.command_name, &self.version, &man_dir)?;
man::generate_subcommand_man_pages(&self.command_name, &self.version, &man_dir)?;
Ok(())
}
}
#[cfg(test)]
mod tests {
use super::*;
use tempfile::TempDir;
#[test]
fn test_documentation_generator_creation() {
let generator = DocumentationGenerator::new("voirs".to_string(), "1.0.0".to_string());
assert_eq!(generator.command_name, "voirs");
assert_eq!(generator.version, "1.0.0");
}
#[test]
fn test_generate_all_creates_directories() {
let temp_dir = TempDir::new().unwrap();
let generator = DocumentationGenerator::new("voirs".to_string(), "1.0.0".to_string());
generator.generate_all(temp_dir.path()).unwrap();
assert!(temp_dir.path().join("man").exists());
}
}