Skip to content

feat(rust): description is the first paragraph, not the first line - #5

Open
nightscape wants to merge 1 commit into
GitSmart86:mainfrom
nightscape:feat/description-paragraphs
Open

nightscape wants to merge 1 commit into
GitSmart86:mainfrom
nightscape:feat/description-paragraphs

Conversation

@nightscape

Copy link
Copy Markdown

Problem

extract_description returns 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:

//! @c4 component
//!
//! Cross-PBT transition traits shared between
//! `holon-layout-testing` and `holon-integration-tests`.

→ 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:

  1. First paragraph, stop at blank/markerthis PR. Most intuitive; the only surprise is if someone intentionally relied on truncation to hide a second line (very unlikely).
  2. Continuation-only-if-incomplete — append the next line only when the current line lacks terminal punctuation (., !, ?, :). Even more conservative, but punctuation-sensitive and surprising in its own way.
  3. Config flag (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_line still passes.

🤖 Generated with Claude Code

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>
Copilot AI review requested due to automatic review settings June 14, 2026 09:55

Copilot AI 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.

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);
}
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.

2 participants