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

Closed
Nemo157 opened this issue May 27, 2021 · 4 comments · Fixed by #132871
Closed
Assignees
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.

@lolbinarycat lolbinarycat self-assigned this Nov 10, 2024
@lolbinarycat
Copy link
Contributor

lolbinarycat commented Nov 10, 2024

separate attributes are probably intended as separate paragraphs

however, they're not treated as separate paragraphs, in the full docs, it is one paragraph.

in my experience, the main use for #[doc = ""] attributes is dynamically generating docs via macros.

if anything, we should just ingest clippy::too_long_first_doc_paragraph into rustdoc. this would allow it to be applied to the standard library, which would be useful, since i've fixed several errors of that class in the stdlib.

lolbinarycat added a commit to lolbinarycat/rust that referenced this issue Nov 10, 2024
bors added a commit to rust-lang-ci/rust that referenced this issue Nov 11, 2024
Rollup of 3 pull requests

Successful merges:

 - rust-lang#131080 (Stabilize WebAssembly `multivalue`, `reference-types`, and `tail-call` target features)
 - rust-lang#132871 (add regression test for rust-lang#85763)
 - rust-lang#132878 (triagebot: Assign rustdoc tests to T-rustdoc.)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors closed this as completed in 5742e22 Nov 11, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this issue Nov 11, 2024
Rollup merge of rust-lang#132871 - lolbinarycat:rustdoc-heterogeneous-first-paragraph-85763, r=aDotInTheVoid

add regression test for rust-lang#85763

closes rust-lang#85763
mati865 pushed a commit to mati865/rust that referenced this issue Nov 12, 2024
…-first-paragraph-85763, r=aDotInTheVoid

add regression test for rust-lang#85763

closes rust-lang#85763
mati865 pushed a commit to mati865/rust that referenced this issue Nov 12, 2024
Rollup of 3 pull requests

Successful merges:

 - rust-lang#131080 (Stabilize WebAssembly `multivalue`, `reference-types`, and `tail-call` target features)
 - rust-lang#132871 (add regression test for rust-lang#85763)
 - rust-lang#132878 (triagebot: Assign rustdoc tests to T-rustdoc.)

r? `@ghost`
`@rustbot` modify labels: rollup
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

Successfully merging a pull request may close this issue.

3 participants