diff --git a/src/main.rs b/src/main.rs index 49a5243..e0a91d8 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,5 +1,5 @@ mod env_validator; - +mod readme; use std::fs; fn main() { @@ -28,4 +28,11 @@ fn main() { println!(); env_validator::validate_env(&extracted, &env); + + + + + readme::detector::detect(); + println!(); + readme::quality_scoring::score(); } \ No newline at end of file diff --git a/src/readme/detector.rs b/src/readme/detector.rs new file mode 100644 index 0000000..d674c38 --- /dev/null +++ b/src/readme/detector.rs @@ -0,0 +1,58 @@ +use std::collections::HashSet; +use std::fs; +use std::path::PathBuf; + +pub fn detect() { + let file_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("README.md"); + + let content = match fs::read_to_string(&file_path) { + Ok(data) => data, + Err(err) => { + println!("Failed to read README.md at {:?}: {}", file_path, err); + return; + } + }; + + let mut sections: HashSet = HashSet::new(); + + for line in content.lines() { + let trimmed = line.trim(); + + if trimmed.starts_with('#') { + let heading = trimmed.trim_start_matches('#').trim().to_lowercase(); + sections.insert(heading); + } + } + + println!( + "========== README Section Detection ========== +" + ); + println!("Detected Sections:"); + for section in §ions { + println!("• {}", section); + } + + println!( + " +========== Validation ==========" + ); + + let required_sections = vec![ + "installation", + "usage", + "license", + "contributing", + "features", + "api", + "examples", + ]; + + for section in required_sections { + if sections.contains(section) { + println!("✅ {} - Found", section); + } else { + println!("❌ {} - Missing", section); + } + } +} diff --git a/src/readme/mod.rs b/src/readme/mod.rs new file mode 100644 index 0000000..71b80bd --- /dev/null +++ b/src/readme/mod.rs @@ -0,0 +1,2 @@ +pub mod detector; +pub mod quality_scoring; \ No newline at end of file