Skip to content

Implemented README section detection#17

Open
PrasannaVenkatesanE wants to merge 1 commit into
NammaRust:mainfrom
PrasannaVenkatesanE:feature/7-README-detection
Open

Implemented README section detection#17
PrasannaVenkatesanE wants to merge 1 commit into
NammaRust:mainfrom
PrasannaVenkatesanE:feature/7-README-detection

Conversation

@PrasannaVenkatesanE

@PrasannaVenkatesanE PrasannaVenkatesanE commented Jul 9, 2026

Copy link
Copy Markdown

Summary

Implemented README section detection.

Changes

  • Detects Markdown headings
  • Identifies common README sections
  • Reports missing sections

Closes #7

Summary by CodeRabbit

  • New Features
    • Added automated README section detection and validation output.
    • Introduced an additional README scoring step during startup, with clear console output.
  • Bug Fixes
    • Improved handling of missing or unreadable README files by reporting the issue and exiting gracefully.

@coderabbitai

coderabbitai Bot commented Jul 9, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Adds a new readme module with a detector submodule that reads README.md, extracts and lowercases Markdown headings into a set, prints detected sections, and validates presence of required sections (installation, usage, license, contributing, features, api, examples). main.rs invokes detect() and score() after env validation.

Changes

README Section Detection

Layer / File(s) Summary
Module wiring and main invocation
src/main.rs, src/readme/mod.rs
Declares readme module with public detector and quality_scoring submodules; main calls readme::detector::detect() and readme::quality_scoring::score() after env validation, with an added newline print.
README detection and section validation
src/readme/detector.rs
detect() reads README.md from the manifest directory, handles read errors, extracts lowercase heading text into a HashSet, prints detected sections, then checks and prints found/missing status for required sections (installation, usage, license, contributing, features, api, examples).

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Main
  participant Detector as readme::detector
  participant FS as File System

  Main->>Detector: detect()
  Detector->>FS: read README.md
  FS-->>Detector: file contents or error
  Detector->>Detector: extract headings into HashSet
  Detector->>Detector: check required sections
  Detector-->>Main: print detected sections and validation report
Loading
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Out of Scope Changes check ⚠️ Warning The PR adds quality scoring and validates extra sections beyond the linked issue scope. Remove the quality_scoring call and restrict validation to Installation, Usage, Contributing, and License.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly matches the main change: adding README section detection.
Linked Issues check ✅ Passed The PR implements README existence handling and section detection for the requested sections.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/readme/detector.rs`:
- Around line 41-49: The required sections list in the README detector is too
broad and does not match the PR acceptance criteria. Update the
required_sections vector in the detector logic to check only the four intended
sections: Installation, Usage, Contributing, and License, and remove the extra
feature/api/examples entries so the missing-section report aligns with the spec.
- Around line 21-24: The heading extraction in the readme detector is treating
lines inside fenced code blocks as real headings. Update the logic in the
detector function that scans trimmed lines to track fenced block state (for
example, a boolean toggled when encountering a ``` fence) and skip any
`trimmed.starts_with('#')` checks while inside a code fence. Keep the heading
normalization/insert logic the same, but ensure it only runs for actual markdown
content outside code blocks.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: fcef3862-7e35-47ec-bc93-d071f9958c7b

📥 Commits

Reviewing files that changed from the base of the PR and between 02cf00d and e32380f.

📒 Files selected for processing (3)
  • src/main.rs
  • src/readme/detector.rs
  • src/readme/mod.rs

Comment thread src/readme/detector.rs
Comment on lines +21 to +24
if trimmed.starts_with('#') {
let heading = trimmed.trim_start_matches('#').trim().to_lowercase();
sections.insert(heading);
}

Copy link
Copy Markdown

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 dependencies in 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
     let mut sections: HashSet<String> = HashSet::new();
+    let mut in_code_block = false;

     for line in content.lines() {
         let trimmed = line.trim();

+        if trimmed.starts_with("```") {
+            in_code_block = !in_code_block;
+            continue;
+        }
+
+        if in_code_block {
+            continue;
+        }
+
         if trimmed.starts_with('#') {
             let heading = trimmed.trim_start_matches('#').trim().to_lowercase();
             sections.insert(heading);
         }
     }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if trimmed.starts_with('#') {
let heading = trimmed.trim_start_matches('#').trim().to_lowercase();
sections.insert(heading);
}
let mut sections: HashSet<String> = HashSet::new();
let mut in_code_block = false;
for line in content.lines() {
let trimmed = line.trim();
if trimmed.starts_with("
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/readme/detector.rs` around lines 21 - 24, The heading extraction in the
readme detector is treating lines inside fenced code blocks as real headings.
Update the logic in the detector function that scans trimmed lines to track
fenced block state (for example, a boolean toggled when encountering a ```
fence) and skip any `trimmed.starts_with('#')` checks while inside a code fence.
Keep the heading normalization/insert logic the same, but ensure it only runs
for actual markdown content outside code blocks.

Comment thread src/readme/detector.rs
Comment on lines +41 to +49
let required_sections = vec![
"installation",
"usage",
"license",
"contributing",
"features",
"api",
"examples",
];

Copy link
Copy Markdown

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

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 features, api, and examples. These extra sections will report false "Missing" status for READMEs that legitimately omit them, creating confusion since the issue only requires four.

🔧 Proposed fix: align required sections with PR objectives
     let required_sections = vec![
         "installation",
         "usage",
-        "license",
-        "contributing",
-        "features",
-        "api",
-        "examples",
+        "contributing",
+        "license",
     ];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
let required_sections = vec![
"installation",
"usage",
"license",
"contributing",
"features",
"api",
"examples",
];
let required_sections = vec![
"installation",
"usage",
"contributing",
"license",
];
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/readme/detector.rs` around lines 41 - 49, The required sections list in
the README detector is too broad and does not match the PR acceptance criteria.
Update the required_sections vector in the detector logic to check only the four
intended sections: Installation, Usage, Contributing, and License, and remove
the extra feature/api/examples entries so the missing-section report aligns with
the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Implement README section detection

1 participant