-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Improve Rustdoc UI for scraped examples with multiline arguments, fix overflow in line numbers #93217
Conversation
Some changes occurred in HTML/CSS/JS. |
295bbbf
to
1407067
Compare
ed4aff1
to
66e3208
Compare
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
37a312f
to
935f112
Compare
Please move the |
I think that change would also require an FCP and more discussion. |
935f112
to
9b94c26
Compare
Ok, I pulled that change into #93497. |
☔ The latest upstream changes (presumably #93498) made this pull request unmergeable. Please resolve the merge conflicts. |
9b94c26
to
dc9c17b
Compare
src/librustdoc/html/render/mod.rs
Outdated
@@ -2577,7 +2578,9 @@ fn render_call_locations(w: &mut Buffer, cx: &Context<'_>, item: &clean::Item) { | |||
<span></span>\ | |||
<h5 id=\"{id}\" class=\"section-header\">\ | |||
<a href=\"#{id}\">Examples found in repository</a>\ | |||
<a class=\"scrape-help\" href=\"{doc_prefix}/rustdoc/scraped-examples.html\" target=\"_blank\">?</a>\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is way too much:
- It's pretty obvious what this is.
- It'll increase the page size once more for a very minor gain.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I really don't think we should be worrying about a small increase in page size like this. And I don't think it's that obvious what it is. For you, it may be obvious, since you've been immersed in this feature throughout its development, but most users have never even heard of it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Even if they don't know about the feature, the text itself is pretty explicit: "Examples found in...". The rustdoc book exists and will include a chapter about this but I don't think there is enough interest for it.
Also, it's definitely not a small increase in page size. Especially on big crates with a lot of methods.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rustdoc book exists and will include a chapter about this but I don't think there is enough interest for it.
I'm not sure what you mean about interest.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're going to have an explainer in the docs that's distinct from the chapter in the rustdoc book, it should probably just be an overlay / popup like the current help menu. It wouldn't be more than a couple sentences probably.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jsha @GuillaumeGomez can y'all let me know what your final preference is for the scrape examples help message? I'd like to implement it this weekend.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Writing a page and linking to it based on what @jsha suggested.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is it ok if I implement it as a popup though? I really think that would be both a better user experience and simpler for me to implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Simpler I'm not sure. Adding an HTML page should be quite easy. Then you just have to link to it. Adding more JS for this doesn't seem the best solution but maybe I'm wrong?
☔ The latest upstream changes (presumably #93762) made this pull request unmergeable. Please resolve the merge conflicts. |
dc9c17b
to
fa0719a
Compare
☔ The latest upstream changes (presumably #93854) made this pull request unmergeable. Please resolve the merge conflicts. |
fa0719a
to
dca7ceb
Compare
2aa8381
to
d1416d5
Compare
Alright, well if it's good as is, are there any last requests on this PR? @jsha @GuillaumeGomez @camelid |
@rustbot ready |
The effects of this change as listed in the PR description sound good to me; I'll leave reviewing the code to Guillaume. |
|
||
1. For a given item, a maximum of 5 examples are included in the page. The remaining examples are just links to source code. | ||
2. Only one example is shown by default, and the remaining examples are hidden behind a toggle. | ||
3. For a given file that contains examples, only the item containing the examples will be included in the generated documentation. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add a new section at the end providing a link to the rustdoc book chapter talking about this feature please? Something like:
## Official tutorial
If you want more information about this feature, take a look at the [rustdoc book chapter](link here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Apart from my comment, looks all good to me! |
locations in scrape examples.
Note: I also just added a commit which removes the remaining |
let mut ids = IdMap::default(); | ||
format!( | ||
"<div class=\"main-heading\"> | ||
"<div class=\"main-heading\">\ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
All good for me. Then let's go! @bors: r+ |
📌 Commit 6a18b68 has been approved by |
Rollup of 6 pull requests Successful merges: - rust-lang#93217 (Improve Rustdoc UI for scraped examples with multiline arguments, fix overflow in line numbers) - rust-lang#95885 (Improve error message in case of missing checksum) - rust-lang#95962 (Document that DirEntry holds the directory open) - rust-lang#95991 (fix: wrong trait import suggestion for T:) - rust-lang#96005 (Add missing article to fix "few" to "a few".) - rust-lang#96006 (Add a missing article) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
This PR improves a few aspects of the scrape examples feature in Rustdoc.
r? @GuillaumeGomez