feat(rust): description is the first paragraph, not the first line - #5
Open
nightscape wants to merge 1 commit into
Open
nightscape wants to merge 1 commit into
nightscape wants to merge 1 commit into
Conversation
extract_description took only the first non-marker line, so a summary that wrapped across several //! lines was truncated at the first wrap. Collect the first paragraph instead (consecutive non-empty, non-marker lines joined with a space), stopping at the first blank or marker line. Compatible by construction: a one-line description followed by a blank line is unchanged. Only a description whose first paragraph spans multiple lines changes — it is now joined rather than cut. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates description extraction to capture the first prose paragraph (instead of a single line), and adds tests to lock in the new behavior.
Changes:
- Add
is_marker_line()helper to centralize detection of non-prose “marker” lines. - Update
extract_description()to collect and join the first prose paragraph, stopping at markers/blank lines. - Add unit tests covering single-line, wrapped paragraph, marker termination, and empty placeholder cases.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+174
to
+180
| fn is_marker_line(trimmed: &str) -> bool { | ||
| trimmed.starts_with('#') | ||
| || trimmed.starts_with("@c4 ") | ||
| || trimmed.starts_with('|') | ||
| || trimmed.starts_with("GoF:") | ||
| || trimmed.starts_with("Pattern:") | ||
| } |
Comment on lines
+195
to
+205
| let mut paragraph: Vec<&str> = Vec::new(); | ||
| for line in content.lines() { | ||
| let trimmed = line.trim(); | ||
| if trimmed.is_empty() || is_marker_line(trimmed) { | ||
| if paragraph.is_empty() { | ||
| continue; // still skipping leading blanks / markers | ||
| } | ||
| break; // prose has ended | ||
| } | ||
| paragraph.push(trimmed); | ||
| } |
Comment on lines
+195
to
+205
| let mut paragraph: Vec<&str> = Vec::new(); | ||
| for line in content.lines() { | ||
| let trimmed = line.trim(); | ||
| if trimmed.is_empty() || is_marker_line(trimmed) { | ||
| if paragraph.is_empty() { | ||
| continue; // still skipping leading blanks / markers | ||
| } | ||
| break; // prose has ended | ||
| } | ||
| paragraph.push(trimmed); | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
extract_descriptionreturns the first non-empty, non-marker line of the module doc. A summary that wraps across several//!lines is therefore truncated at the first wrap:→ description =
"Cross-PBT transition traits shared between"(cut mid-sentence). Authors must hand-collapse every summary onto one physical line.Fix
Collect the first paragraph: consecutive non-empty, non-marker lines, joined with a single space. Leading blank/marker lines are skipped; collection stops at the first blank or marker line after prose begins.
Compatibility — and the trigger options
This is deliberately the most compatible of the designs I considered. The only behavioural change is for descriptions whose first paragraph already spanned multiple lines (those were truncated before; they are now joined). A one-line description followed by a blank line is byte-for-byte unchanged, which covers the overwhelming majority of existing annotations.
Other "when does multi-line kick in?" options, for reference:
.,!,?,:). Even more conservative, but punctuation-sensitive and surprising in its own way.description_mode: line | paragraph) — explicit opt-in, zero default change, at the cost of a knob. Easy to layer on top of this PR if you'd prefer paragraph mode to be opt-in.Happy to switch to (2) or (3) if you'd rather not change the default.
Tests
Added cases: single-line unchanged, wrapped paragraph joined, stop-at-marker-without-blank, empty → placeholder. Existing
description_skips_pattern_linestill passes.🤖 Generated with Claude Code