Skip to content

parse_docs doesn't handle block doc comments properly #341

@gustavo-shigueo

Description

@gustavo-shigueo

The way we generate the doc string is:

format!("/**\n{}\n */\n", lines.join("\n")),

lines in the snippet represents a Vec<String>, where each item is the content of a single #[doc = "..."] attribute.

This works great with /// comments, as the compiler converts each of these to its own #[doc = "..."] attribute, where ... is replace with the contents of the comment.

However, a /***/ comment is replaced with a single #[doc = "..."] attribute, where ... is replaced with every single character between the second and third * characters, including any leading or trailing \n.

So

/**
 * Scan progress
 */

is replaced with #[doc = "\n * Scan progress\n "]. This leading \n, combined with our default \n + "* " before the #[doc] contents, causes the weird blank line

Originally posted by @gustavo-shigueo in #316 (comment)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions