-
Notifications
You must be signed in to change notification settings - Fork 5
Implemented README section detection #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -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<String> = 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", | ||||||||||||||||||||||||||||||||
| ]; | ||||||||||||||||||||||||||||||||
|
Comment on lines
+41
to
+49
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🎯 Functional Correctness | 🟠 Major | ⚡ Quick win Required sections list doesn't match the PR acceptance criteria. The PR objectives specify four required sections: Installation, Usage, Contributing, License. The code checks seven, adding 🔧 Proposed fix: align required sections with PR objectives let required_sections = vec![
"installation",
"usage",
- "license",
- "contributing",
- "features",
- "api",
- "examples",
+ "contributing",
+ "license",
];📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| for section in required_sections { | ||||||||||||||||||||||||||||||||
| if sections.contains(section) { | ||||||||||||||||||||||||||||||||
| println!("✅ {} - Found", section); | ||||||||||||||||||||||||||||||||
| } else { | ||||||||||||||||||||||||||||||||
| println!("❌ {} - Missing", section); | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| pub mod detector; | ||
| pub mod quality_scoring; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
Lines starting with
#inside fenced code blocks are falsely detected as headings.A
#comment inside a```block (e.g.,# Install dependenciesin a bash snippet) would be extracted as a heading. If such a comment matches a required section name (e.g.,# installation), the validator would report it as "Found" even though no real section exists, masking a genuinely missing section.Track fenced code block state to skip lines inside
```blocks:🛡️ Proposed fix: skip headings inside code fences
📝 Committable suggestion
🤖 Prompt for AI Agents