From e32380fd05f3dc1df47b1d09fe38fe88cec7f1fb Mon Sep 17 00:00:00 2001 From: Prasanna Venkatesan E Date: Thu, 9 Jul 2026 10:11:49 +0530 Subject: [PATCH 1/2] Implemented README section detection --- src/main.rs | 9 ++++++- src/readme/detector.rs | 58 ++++++++++++++++++++++++++++++++++++++++++ src/readme/mod.rs | 2 ++ 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/readme/detector.rs create mode 100644 src/readme/mod.rs 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 From 366b141e15cfc60909b53f930ca10b5f7c056d66 Mon Sep 17 00:00:00 2001 From: Prasanna Venkatesan E Date: Thu, 9 Jul 2026 11:07:15 +0530 Subject: [PATCH 2/2] Implemented README quality scoring --- src/readme/quality_scoring.rs | 87 +++++++++++++++++++++++++++++++++++ 1 file changed, 87 insertions(+) create mode 100644 src/readme/quality_scoring.rs diff --git a/src/readme/quality_scoring.rs b/src/readme/quality_scoring.rs new file mode 100644 index 0000000..d24ba51 --- /dev/null +++ b/src/readme/quality_scoring.rs @@ -0,0 +1,87 @@ +use std::collections::HashSet; +use std::fs; +use std::path::PathBuf; + +pub fn score() { + 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!("Error reading 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); + } + } + + let scoring = vec![ + ("installation", 20), + ("usage", 20), + ("features", 15), + ("contributing", 15), + ("license", 10), + ("api", 10), + ("examples", 10), + ]; + + let mut score = 0; + let mut missing = Vec::new(); + + println!( + " +========== README QUALITY REPORT ========== +" + ); + + for (section, points) in scoring { + if sections.contains(section) { + println!("✅ {:15} +{} points", section, points); + score += points; + } else { + println!("❌ {:15} Missing", section); + missing.push(section); + } + } + + println!( + " +==========================================" + ); + println!("README Quality Score: {}/100", score); + + if missing.is_empty() { + println!("Excellent! README contains all recommended sections."); + } else { + println!( + " +Missing Sections:" + ); + for section in missing { + println!(" - {}", section); + } + } + + println!(); + + if score >= 90 { + println!("Grade: A ⭐⭐⭐⭐⭐"); + } else if score >= 75 { + println!("Grade: B ⭐⭐⭐⭐"); + } else if score >= 60 { + println!("Grade: C ⭐⭐⭐"); + } else if score >= 40 { + println!("Grade: D ⭐⭐"); + } else { + println!("Grade: F ⭐"); + } +}