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

rustdoc doesn't include all text that cross attribute type boundaries in the summary #85763

Open
Nemo157 opened this issue May 27, 2021 · 3 comments
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) C-bug Category: This is a bug. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@Nemo157
Copy link
Member

Nemo157 commented May 27, 2021

I tried this code:

#[doc = " Some text"]
#[doc = " that should"]
/// be concatenated.
pub fn main() {
    println!("Hello, world!");
}

I expected to see this happen: The entire first paragraph is used as the summary for the function in the module docs: "Some text that should be concatenated"

Instead, this happened: Only the unsugared doc attributes are used: "Some text that should"

image

image

Meta

rustc --version --verbose:

rustc 1.54.0-nightly (4e3e6db01 2021-05-18)
binary: rustc
commit-hash: 4e3e6db011c5b482d2bef8ba02274657f93b5e0d
commit-date: 2021-05-18
host: x86_64-unknown-linux-gnu
release: 1.54.0-nightly
LLVM version: 12.0.1
@Nemo157 Nemo157 added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. C-bug Category: This is a bug. A-rustdoc-ui Area: rustdoc UI (generated HTML) labels May 27, 2021
@ben0x539
Copy link
Contributor

This seems to be achieved here:

if new_frag.kind != ori.kind || new_frag.parent_module != ori.parent_module {
(probably from #80261?)

We're concatenating the text from doc attrs here, but only until we find one of a different kind. Seems intentional enough but I don't know what it's for.

To me naively it only makes sense to concatenate single-line doc comments to generate the summary; with either multiline doc comments or explicit attrs I would expect that where they end is a good place to end the summary.

@Nemo157
Copy link
Member Author

Nemo157 commented Jun 10, 2021

My usecase is dynamically generating some words in the first sentence based on cfg. I don't see any reason that rustdoc should distinguish between attribute types here, it has markdown's concept of a paragraph to determine how much to look at for the summary, there's no need to limit how users can construct that first paragraph.

@ben0x539
Copy link
Contributor

Right, that's a compelling use case for sure! My take was "separate attributes are probably intended as separate paragraphs", but I didn't consider that you'd dynamically construct the set of attributes. I'm curious if that was the original motivation for the kind comparison or if it's needed for another reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-ui Area: rustdoc UI (generated HTML) 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

No branches or pull requests

2 participants