Skip to main content

leading_prose_from_attrs

Function leading_prose_from_attrs 

Source
fn leading_prose_from_attrs(
    attrs: &[Attribute],
    links: ProseLinks,
) -> Option<String>
Expand description

Collect the leading prose of a doc comment (the lines before the first @tag, LineRole::Prose) as roxygen @description text, its links treated per the crate’s ProseLinks setting (passed in, so the unit tests need no manifest; roxygen_tags_with passes Strip for a block that renders no page).

The lines (doc_lines) keep their line breaks, blank lines (roxygen2 paragraph breaks, rendered as bare #' lines by push_roxygen_tags) and indentation, so a markdown list, a nested item or a fenced block reaches roxygen2 as written. Leading and trailing blank lines are dropped. With ProseLinks::Strip every link is neutralized; with ProseLinks::Keep only the rustdoc-only ones are (sanitize_prose_links).

Returns None when the block has no leading prose (empty, or starts with a @tag), so tag-led blocks never gain a spurious @description.