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

Always display first line of impl blocks even when collapsed #132155

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

GuillaumeGomez
Copy link
Member

Fixes #130612.

It the line is too long, only the beginning will be visible:

Screenshot from 2024-10-25 17-21-41

Otherwise, it looks like this:

image

Can be tested here.

r? @notriddle

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 25, 2024
@rustbot
Copy link
Collaborator

rustbot commented Oct 25, 2024

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez, @jsha

@rust-log-analyzer

This comment has been minimized.

Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks cool 💚

tests/rustdoc-gui/src/test_docs/lib.rs Show resolved Hide resolved
@@ -1413,6 +1416,52 @@ impl MarkdownItemInfo<'_> {
}
}

pub(crate) fn markdown_split_summary_and_content(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should have a comment explaining what it does. Also, it should probably be a method on the Markdown struct? It's basically a different version of to_string.

/// Convert markdown to (summary, remaining) HTML.
///
/// - The summary is the first top-level Markdown element (usually a paragraph, but potentially any block).
/// - The remaining docs contain everything after the summary.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea for the docs. I don't have an opinion on whether or not it should be a method so I'll just make a method since you seem to favor it. 👍

@GuillaumeGomez
Copy link
Member Author

Applied suggestions.

@notriddle notriddle added T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. and removed T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Oct 28, 2024
@notriddle

This comment was marked as duplicate.

@notriddle

This comment was marked as duplicate.

@rfcbot

This comment was marked as duplicate.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 28, 2024
@notriddle notriddle removed the T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. label Oct 28, 2024
@notriddle
Copy link
Contributor

@rfcbot fcp cancel

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented Oct 28, 2024

@notriddle proposal cancelled.

@rfcbot rfcbot removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 28, 2024
@rfcbot
Copy link

rfcbot commented Oct 28, 2024

Team member @notriddle has proposed to merge this. The next step is review by the rest of the tagged team members:

Concerns:

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels Oct 28, 2024
left: 0;
right: 0;
pointer-events: none;
background: linear-gradient(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't love the look of this. It looks a bit out of place compared to the generally clean style of rustdoc. In the case of tables and other things, it seems reasonable to just not show them rather than do a paywall-style blur of everything below the first row.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rfcbot concern gradient-looks-weird

I see what you mean there. To avoid this, I think you'd want to only have a summary if the first element is a paragraph or header, and then use white-space: nowrap; overflow: hidden; text-overflow: ellipsis;?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly, that sounds good.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I liked the blur effect but text ellipsis is fine too. 😆

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem with this approach is that the ellipsis only appears if the current sentence is cut:

image

expanded:

image

I'll try to check if we can still get the "..." in any case...

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't figure a way to have an ellipsis which matches these conditions:

  • Appears whatever the width of the first line.
  • Appears only if there is hidden content.

With the blur I didn't have these issues, hence why I went for this solution. 😆

If you have an idea, I'd love to hear it!

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few things I thought about: the problem with short sentences is that they don't overflow, and therefore don't generate the ellipsis. However if there is more content, users won't until expanded. So instead I tried to cheat a bit and added a ::after element:

details.toggle:not([open]) > summary .docblock > :first-child {
	max-width: calc(100% - 1em);
	overflow: hidden;
	width: fit-content;
	white-space: nowrap;
	position: relative;
	text-overflow: clip;
	padding-right: 1em;
}
details.toggle:not([open]) > summary .docblock > :first-child::after {
	content: "…";
	position: absolute;
	right: 0;
	top: 0;
	background-color: var(--main-background-color);
}

However, it never gets displayed correctly on big text as it goes over it or is always stuck to the right side. I was hoping to kinda go around this issue by using padding and was able to. It gives this result:

image

If you are ok with this result, I can go with it.

@notriddle
Copy link
Contributor

@rfcbot concern gradient-looks-weird

#132155 (comment)

@rustbot rustbot added the T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. label Oct 29, 2024
@GuillaumeGomez
Copy link
Member Author

I pushed the change with the text ellipsis. I find this solution less good but if majority prefers it, let's go with it. :)

@GuillaumeGomez
Copy link
Member Author

Half+1 members approved the PR. Should we move forward with it?

@bors
Copy link
Contributor

bors commented Nov 14, 2024

☔ The latest upstream changes (presumably #133006) made this pull request unmergeable. Please resolve the merge conflicts.

@GuillaumeGomez
Copy link
Member Author

Fixed merge conflicts.

@notriddle
Copy link
Contributor

@rfcbot resolve gradient-looks-weird

@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Nov 14, 2024
@rfcbot
Copy link

rfcbot commented Nov 14, 2024

🔔 This is now entering its final comment period, as per the review above. 🔔

@bors
Copy link
Contributor

bors commented Nov 15, 2024

☔ The latest upstream changes (presumably #133047) made this pull request unmergeable. Please resolve the merge conflicts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-testsuite Area: The testsuite used to check the correctness of rustc disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc: First line of documentation on collapsed impl blocks should be visible
8 participants