Skip to main content

strip_roxygen_from_attrs

Function strip_roxygen_from_attrs 

Source
pub(crate) fn strip_roxygen_from_attrs(attrs: &[Attribute]) -> Vec<Attribute>
Expand description

Strip roxygen tag lines from doc attributes, keeping only regular documentation.

Returns a new vector of attributes with roxygen lines removed from doc comments. Non-doc attributes, and doc attributes that are not string literals (#[doc = include_str!(..)]), are passed through unchanged.

§Algorithm

The lines are classified by the same rule the tag extractor reads (classify), so text that reaches R help leaves rustdoc and text that does not stays:

  • leading prose (before the first @tag) is kept;
  • a tag and every line it takes are dropped: the paragraphs of a multi-line tag (@return X / blank / more text), the wrapped lines of a joined tag (@title), a bare @rdname’s topic line;
  • a line after a single-line tag (@export, @noRd, @rdname topic) is rustdoc only and kept, with the blank line before it.

A doc attribute is dropped when its first non-blank line is a tag or tag text, or when it is blank and inside or at the end of a tag.