Skip to content

[RustDoc] Could "Summary" still show the first line of docs? #160922

Description

@scottmcm

This issue inspired by a private conversation where people were discussing whether method documentation should have different rules from module-level functions since they don't have the same rustdoc summary list that uses that first sentence. Clippy's too_long_first_doc_paragraph lint also specifically talks about "in the module page".

But maybe rustdoc should be taking advantage of the short-first-paragraph in some way for methods too?

As one possible idea, maybe folding the methods could still show the first line?

Take https://doc.rust-lang.org/std/primitive.u32.html#method.carrying_mul_add, for example, which has a long comment

Image

Today it folds to just the signature

Image

But maybe it would make sense to fold also showing the same first-sentence that would be shown in a module table, perhaps something like

Image

I think that might help the "summary" button

Image

since if I just want a list of names there's the sidebar, and signature + 1st-doc-line might be a useful middle ground between "everything" and "just the names".

(Spitballing: I don't know if it's worth putting a separate block into the HTML to repeat the first sentence. Maybe overflow: hidden with a 1-line height when collapsed, or something? And removing the extra margin? I'm pretty terrible at HTML+CSS, so you'll probably come up with something better than I can.)

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.needs-triageThis issue may need triage. Remove it if it has been sufficiently triaged.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions