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

Merged
merged 8 commits into from
Dec 6, 2024

Conversation

GuillaumeGomez
Copy link
Member

@GuillaumeGomez GuillaumeGomez commented Oct 25, 2024

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)

@GuillaumeGomez
Copy link
Member Author

Fixed merge conflicts.

@bors
Copy link
Contributor

bors commented Dec 2, 2024

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

@rust-log-analyzer

This comment has been minimized.

@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. to-announce Announce this issue on triage meeting and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels Dec 5, 2024
@rfcbot
Copy link

rfcbot commented Dec 5, 2024

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

This will be merged soon.

@GuillaumeGomez
Copy link
Member Author

@bors r=rustdoc

@bors
Copy link
Contributor

bors commented Dec 5, 2024

📌 Commit 854ebe7 has been approved by rustdoc

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Dec 5, 2024
bors added a commit to rust-lang-ci/rust that referenced this pull request Dec 5, 2024
…llaumeGomez

Rollup of 8 pull requests

Successful merges:

 - rust-lang#132155 (Always display first line of impl blocks even when collapsed)
 - rust-lang#133256 (CI: use free runners for i686-gnu jobs)
 - rust-lang#133607 (implement checks for tail calls)
 - rust-lang#133821 (Replace black with ruff in `tidy`)
 - rust-lang#133827 (CI: rfl: move job forward to Linux v6.13-rc1)
 - rust-lang#133910 (Normalize target-cpus.rs stdout test for LLVM changes)
 - rust-lang#133921 (Adapt codegen tests for NUW inference)
 - rust-lang#133936 (Avoid fetching the anon const hir node that is already available)

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit a424813 into rust-lang:master Dec 6, 2024
6 checks passed
@rustbot rustbot added this to the 1.85.0 milestone Dec 6, 2024
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Dec 6, 2024
Rollup merge of rust-lang#132155 - GuillaumeGomez:impl-block-doc, r=rustdoc

Always display first line of impl blocks even when collapsed

Fixes rust-lang#130612.

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

![Screenshot from 2024-10-25 17-21-41](/~https://github.com/user-attachments/assets/dd2d912c-ad55-4410-8195-1d66a0a99ad4)

Otherwise, it looks like this:

![image](/~https://github.com/user-attachments/assets/1f40b9e0-2143-4b9d-a4b0-338a0cd740df)

Can be tested [here](https://rustdoc.crud.net/imperio/impl-block-doc/foo/struct.ImplDoc.html).

r? `@notriddle`
@GuillaumeGomez GuillaumeGomez deleted the impl-block-doc branch December 6, 2024 10:01
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. finished-final-comment-period The final comment period is finished for this PR / Issue. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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. to-announce Announce this issue on triage meeting
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