-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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] Page hash handling #70563
[rustdoc] Page hash handling #70563
Conversation
src/librustdoc/html/static/main.js
Outdated
@@ -282,6 +284,14 @@ function getSearchElement() { | |||
function expandSection(id) { | |||
var elem = document.getElementById(id); | |||
if (elem && isHidden(elem)) { | |||
if (elem.tagName === "CODE" && elem.parentNode.tagName === "H4") { | |||
// We are in a trait implementation, what we want is the parent. |
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.
Would it not be better to add a class or somesuch in the generated code so that we're not relying so hard on the exact element structure for this?
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 problem is that it would require a way bigger change to simplify the DOM in order to do so. At first I thought about adding an id to the collapse button but in this case, we have both the <code>
and the <h2>
with ids, making it impossible. This is why I change the page's hash when it's the <code>
.
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.
How does the id get into the code/h2 ? if it's purely via the markdown parser then I suppose I can understand the difficulty. If it's in rustdoc though then we ought to be able to do something. Failing that, the rest looks okay and if you're sure it's reliable then you can r=me.
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.
It's worth checking. I'll take another look around to be sure about it.
833ffa4
to
aa5c954
Compare
So in the end, I simply removed all the IDs inside the |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
cc @jyn514 |
The job Click to expand the log.
I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact |
3a30bbc
to
7ea2bcf
Compare
@kinnison I remove the ids from |
The IDs do look nicer in use. And you're sure nothing was relying on the dodgy IDs? |
Well, end-users could be relying on them. Until we stabilize intra-doc links, users have to link using the same format rustdoc generates, so changing the format will break links. Fortunately these were only hashes so the links will only go to the top of the page instead of giving a 404. |
The extra IDs are part of #35236. To remove them we have to be sure that nothing is still using them. For example it looks like RLS is: https://github.com/rust-lang/rls/blob/fb46b914c11b06828680cb526e2abe9e1d69b868/rls-analysis/src/lib.rs#L500 |
🤷 |
We have git blame... As I said, the IDs were added to FWIW I agree with removing these, but if we're going to remove features we should make some effort to help migrate existing users like RLS. We should also fully revert #35236 not just part of it. |
7ea2bcf
to
e955beb
Compare
I completely removed the option everywhere I could find it. Now I wonder: how do we handle this with RLS? ping @nrc |
@GuillaumeGomez It may also be worth pinging @Xanewok for rls stuff. |
Well, you did it. @ollie27: Should we wait for RLS or should we merge? I don't really know how things are supposed to be handled in such a case... Supporting RLS through HTML ids was not a great idea. :-/ |
RLS is currently broken and so I don't think we should block on RLS in this regard. I assume this modifies the behaviour that this snippet relies on: If so, could you help me adapt it to make it work as expected by new behaviour? |
The big difference will be that RLS will have to rely on "full" path instead of the weird abbreviated ones it used until now. So for example, a variant is "#variant.name". If you need a direct translation for each item, we can talk about it privately so I can help you more quickly. So if RLS isn't a blocker anymore, let's merge it. @bors r=ollie27,kinnison |
📌 Commit e955beb has been approved by |
…r=ollie27,kinnison [rustdoc] Page hash handling Fixes rust-lang#70476 A good example to see the change is to use this URL: https://doc.rust-lang.org/nightly/std/string/struct.String.html#from_iter.v-3 After the change, it actually goes to the target element (and change the page hash to something more clear for the users). r? @kinnison cc @ollie27
…arth Rollup of 14 pull requests Successful merges: - rust-lang#70563 ([rustdoc] Page hash handling) - rust-lang#73856 (Edit librustc_lexer top-level docs) - rust-lang#73870 (typeck: adding type information to projection) - rust-lang#73953 (Audit hidden/short code suggestions) - rust-lang#73962 (libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]) - rust-lang#73969 (mir: mark mir construction temporaries as internal) - rust-lang#73974 (Move A|Rc::as_ptr from feature(weak_into_raw) to feature(rc_as_ptr)) - rust-lang#74067 (rustdoc: Restore underline text decoration on hover for FQN in header) - rust-lang#74074 (Fix the return type of Windows' `OpenOptionsExt::security_qos_flags`.) - rust-lang#74078 (Always resolve type@primitive as a primitive, not a module) - rust-lang#74089 (Add rust-analyzer to the build manifest) - rust-lang#74090 (Remove unused RUSTC_DEBUG_ASSERTIONS) - rust-lang#74102 (Fix const prop ICE) - rust-lang#74112 (Expand abbreviation in core::ffi description) Failed merges: r? @ghost
☔ The latest upstream changes (presumably #74117) made this pull request unmergeable. Please resolve the merge conflicts. |
…arth Rollup of 14 pull requests Successful merges: - rust-lang#70563 ([rustdoc] Page hash handling) - rust-lang#73856 (Edit librustc_lexer top-level docs) - rust-lang#73870 (typeck: adding type information to projection) - rust-lang#73953 (Audit hidden/short code suggestions) - rust-lang#73962 (libstd/net/tcp.rs: #![deny(unsafe_op_in_unsafe_fn)]) - rust-lang#73969 (mir: mark mir construction temporaries as internal) - rust-lang#73974 (Move A|Rc::as_ptr from feature(weak_into_raw) to feature(rc_as_ptr)) - rust-lang#74067 (rustdoc: Restore underline text decoration on hover for FQN in header) - rust-lang#74074 (Fix the return type of Windows' `OpenOptionsExt::security_qos_flags`.) - rust-lang#74078 (Always resolve type@primitive as a primitive, not a module) - rust-lang#74089 (Add rust-analyzer to the build manifest) - rust-lang#74090 (Remove unused RUSTC_DEBUG_ASSERTIONS) - rust-lang#74102 (Fix const prop ICE) - rust-lang#74112 (Expand abbreviation in core::ffi description) Failed merges: r? @ghost
Fixes #70476
A good example to see the change is to use this URL: https://doc.rust-lang.org/nightly/std/string/struct.String.html#from_iter.v-3
After the change, it actually goes to the target element (and change the page hash to something more clear for the users).
r? @kinnison
cc @ollie27