Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newlines don't cause a paragraph break when mixing #[doc] and /// #91201

Closed
camelid opened this issue Nov 24, 2021 · 3 comments · Fixed by #92357
Closed

Newlines don't cause a paragraph break when mixing #[doc] and /// #91201

camelid opened this issue Nov 24, 2021 · 3 comments · Fixed by #92357
Assignees
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@camelid
Copy link
Member

camelid commented Nov 24, 2021

See the test added in #91199. This code:

#[doc = "Hello world!\n\n"]
/// Goodbye!
#[doc = "  Hello again!\n"]
pub struct S1;

renders as:

Hello world! Goodbye! Hello again!

rather than the expected:

Hello world!

Goodbye! Hello again!

Meanwhile, changing some #[doc]s to ///s and vice versa causes it to render as expected.

cc @GuillaumeGomez

@camelid camelid added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. labels Nov 24, 2021
@GuillaumeGomez
Copy link
Member

This is the expected behaviour actually: it converts the /// into a #[doc = "..."] directly. So if you don't put empty doc comments between, it's as expected.

@camelid
Copy link
Member Author

camelid commented Dec 23, 2021

But why are the newlines in the #[doc = "..."] stripped?

@GuillaumeGomez
Copy link
Member

Oh, I didn't see that. I think it's because we use trim to remove whistespaces which also removes backlines. We should instead merge all doc comments before doing anything.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-attributes Area: Attributes (`#[…]`, `#![…]`) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants