-
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
rustdoc: add hash to filename of toolchain files #101702
Conversation
Some changes occurred in HTML/CSS/JS. cc @GuillaumeGomez, @Folyd, @jsha |
(rust-highfive has picked a reviewer for you, use r? to override) |
This comment has been minimized.
This comment has been minimized.
It will be necessary to figure out how docs.rs will handle this. Currently the shared resource handling is a massive hack that allows a static resource request from anywhere but will only lookup the file from |
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #101895) made this pull request unmergeable. Please resolve the merge conflicts. |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I filed rust-lang/docs.rs#1863 documenting my current understanding of how this hack works. Assuming that's correct, I think there's a fairly straightforward way to make docs.rs' SharedResourceHandler work with this change: We can add code such that if the path begins with |
Another possible way to interface with docs.rs is demonstrated here: ea51f8a In other words, the default value of If we adopt this approach, docs.rs would have to make some changes in sync with the rustdoc release:
(note I specifically chose the different directory name |
I like being able to configure the static-root-path explicitly. To make synchronization easier I wonder if we could land that flag first (with it being a no-op), then update docs.rs to use it and copy (I'll also try and come up with a way we can test the behavior of docs.rs against this branch so we can confirm the changes work before it's merged). |
I'm a little confused - That said, we could make a change to docs.rs ahead of this one:
|
Ah, for some reason I thought the current flag was With ea51f8a we would have to change something because |
I think there are a few issues coming up from this change. If I understand correctly, the The content of I'm really not a big fan to have to update Another very minor concern: why One last point: I think we'll need a perf check to see if there is any impact with having such a big struct (I think not but better be aware of it if there is an impact). Overall it seems like a really nice improvement. :) |
No, there are two types of files now:
I wanted a name that couldn't conflict with a package or module name. I don't feel strongly about the choice and am happy to take suggestions.
This is a good idea. I'll see what I can do. |
Thanks for the answers, it all make more sense. Keeping the |
☔ The latest upstream changes (presumably #102726) made this pull request unmergeable. Please resolve the merge conflicts. |
…th, r=notriddle Fix invalid background-image file name This is a follow-up of rust-lang#101702. Apparently the image hash was the wrong one. You can see the error in https://doc.rust-lang.org/nightly/core/primitive.u16.html?search=hello too. I really need to check if I can adds check for resources load errors in `browser-ui-test`. cc `@jsha` r? `@notriddle`
…th, r=notriddle Fix invalid background-image file name This is a follow-up of rust-lang#101702. Apparently the image hash was the wrong one. You can see the error in https://doc.rust-lang.org/nightly/core/primitive.u16.html?search=hello too. I really need to check if I can adds check for resources load errors in `browser-ui-test`. cc ``@jsha`` r? ``@notriddle``
…th, r=notriddle Fix invalid background-image file name This is a follow-up of rust-lang#101702. Apparently the image hash was the wrong one. You can see the error in https://doc.rust-lang.org/nightly/core/primitive.u16.html?search=hello too. I really need to check if I can adds check for resources load errors in `browser-ui-test`. cc ```@jsha``` r? ```@notriddle```
…th, r=notriddle Fix invalid background-image file name This is a follow-up of rust-lang#101702. Apparently the image hash was the wrong one. You can see the error in https://doc.rust-lang.org/nightly/core/primitive.u16.html?search=hello too. I really need to check if I can adds check for resources load errors in `browser-ui-test`. cc ````@jsha```` r? ````@notriddle````
…th, r=notriddle Fix invalid background-image file name This is a follow-up of rust-lang#101702. Apparently the image hash was the wrong one. You can see the error in https://doc.rust-lang.org/nightly/core/primitive.u16.html?search=hello too. I really need to check if I can adds check for resources load errors in `browser-ui-test`. cc `````@jsha````` r? `````@notriddle`````
…th, r=notriddle Fix invalid background-image file name This is a follow-up of rust-lang#101702. Apparently the image hash was the wrong one. You can see the error in https://doc.rust-lang.org/nightly/core/primitive.u16.html?search=hello too. I really need to check if I can adds check for resources load errors in `browser-ui-test`. cc ``````@jsha`````` r? ``````@notriddle``````
…-errors, r=notriddle Add check in GUI test for file loading failure Since rust-lang#101702, some resources location need to be updated in case their content changed because then their hash will change too. This will prevent errors like rust-lang#104114 to happen again. The second commit is to prevent CORS errors: when a file is linked from a file itself imported, the web browser considers they come from a different domain and therefore triggers the error. The option tells the web browser to ignore this case. cc `@jsha` r? `@notriddle`
…-errors, r=notriddle Add check in GUI test for file loading failure Since rust-lang#101702, some resources location need to be updated in case their content changed because then their hash will change too. This will prevent errors like rust-lang#104114 to happen again. The second commit is to prevent CORS errors: when a file is linked from a file itself imported, the web browser considers they come from a different domain and therefore triggers the error. The option tells the web browser to ignore this case. cc ``@jsha`` r? ``@notriddle``
…-errors, r=notriddle Add check in GUI test for file loading failure Since rust-lang#101702, some resources location need to be updated in case their content changed because then their hash will change too. This will prevent errors like rust-lang#104114 to happen again. The second commit is to prevent CORS errors: when a file is linked from a file itself imported, the web browser considers they come from a different domain and therefore triggers the error. The option tells the web browser to ignore this case. cc ```@jsha``` r? ```@notriddle```
…ation, r=notriddle Fix missing minification for static files It's a fix for rust-lang#101702. The problem was that `Path::ends_with` doesn't do what we thought it does: it checks if the entire item is the last path part, no just if the "path string" ends with the given argument. So instead, I just used the `extension()` method to get the information we want. cc `@jsha` r? `@notriddle` PS: Is it worth it to add a CI test to ensure that the minification was performed on JS and CSS files or not?
…r=notriddle Add check in GUI test for file loading failure Since rust-lang/rust#101702, some resources location need to be updated in case their content changed because then their hash will change too. This will prevent errors like rust-lang/rust#104114 to happen again. The second commit is to prevent CORS errors: when a file is linked from a file itself imported, the web browser considers they come from a different domain and therefore triggers the error. The option tells the web browser to ignore this case. cc ```@jsha``` r? ```@notriddle```
…anup, r=GuillaumeGomez rustdoc: remove unused ID `mainThemeStyle` This was added in rust-lang#47620 and used to build the URL of the theme stylesheets. It isn't used any more, because rust-lang#101702 changed it so that the URL was supplied in a `<meta>` tag, which also provides the hashes of the files.
Rollup merge of rust-lang#115655 - notriddle:notriddle/rustdoc-fe-cleanup, r=GuillaumeGomez rustdoc: remove unused ID `mainThemeStyle` This was added in rust-lang#47620 and used to build the URL of the theme stylesheets. It isn't used any more, because rust-lang#101702 changed it so that the URL was supplied in a `<meta>` tag, which also provides the hashes of the files.
The static files placement by `rustdoc` changed in Rust 1.67.0 [1], but the custom code we have to replace the logo in the generated HTML files did not get updated. Thus update it to have the Linux logo again in the output. Hopefully `rustdoc` will eventually support a custom logo from a local file [2], so that we do not need to maintain this hack on our side. Link: rust-lang/rust#101702 [1] Link: rust-lang/rfcs#3226 [2] Fixes: 3ed03f4 ("rust: upgrade to Rust 1.68.2") Cc: stable@vger.kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
The static files placement by `rustdoc` changed in Rust 1.67.0 [1], but the custom code we have to replace the logo in the generated HTML files did not get updated. Thus update it to have the Linux logo again in the output. Hopefully `rustdoc` will eventually support a custom logo from a local file [2], so that we do not need to maintain this hack on our side. Link: rust-lang/rust#101702 [1] Link: rust-lang/rfcs#3226 [2] Fixes: 3ed03f4 ("rust: upgrade to Rust 1.68.2") Cc: stable@vger.kernel.org Tested-by: Benno Lossin <benno.lossin@proton.me> Link: https://lore.kernel.org/r/20231018155527.1015059-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
The static files placement by `rustdoc` changed in Rust 1.67.0 [1], but the custom code we have to replace the logo in the generated HTML files did not get updated. Thus update it to have the Linux logo again in the output. Hopefully `rustdoc` will eventually support a custom logo from a local file [2], so that we do not need to maintain this hack on our side. Link: rust-lang/rust#101702 [1] Link: rust-lang/rfcs#3226 [2] Fixes: 3ed03f4 ("rust: upgrade to Rust 1.68.2") Cc: stable@vger.kernel.org Tested-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Link: https://lore.kernel.org/r/20231018155527.1015059-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
[ Upstream commit cfd9672 ] The static files placement by `rustdoc` changed in Rust 1.67.0 [1], but the custom code we have to replace the logo in the generated HTML files did not get updated. Thus update it to have the Linux logo again in the output. Hopefully `rustdoc` will eventually support a custom logo from a local file [2], so that we do not need to maintain this hack on our side. Link: rust-lang/rust#101702 [1] Link: rust-lang/rfcs#3226 [2] Fixes: 3ed03f4 ("rust: upgrade to Rust 1.68.2") Cc: stable@vger.kernel.org Tested-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Link: https://lore.kernel.org/r/20231018155527.1015059-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
[ Upstream commit cfd9672 ] The static files placement by `rustdoc` changed in Rust 1.67.0 [1], but the custom code we have to replace the logo in the generated HTML files did not get updated. Thus update it to have the Linux logo again in the output. Hopefully `rustdoc` will eventually support a custom logo from a local file [2], so that we do not need to maintain this hack on our side. Link: rust-lang/rust#101702 [1] Link: rust-lang/rfcs#3226 [2] Fixes: 3ed03f4 ("rust: upgrade to Rust 1.68.2") Cc: stable@vger.kernel.org Tested-by: Benno Lossin <benno.lossin@proton.me> Reviewed-by: Andreas Hindborg <a.hindborg@samsung.com> Link: https://lore.kernel.org/r/20231018155527.1015059-1-ojeda@kernel.org Signed-off-by: Miguel Ojeda <ojeda@kernel.org> Signed-off-by: Sasha Levin <sashal@kernel.org>
…r=notriddle Add check in GUI test for file loading failure Since rust-lang/rust#101702, some resources location need to be updated in case their content changed because then their hash will change too. This will prevent errors like rust-lang/rust#104114 to happen again. The second commit is to prevent CORS errors: when a file is linked from a file itself imported, the web browser considers they come from a different domain and therefore triggers the error. The option tells the web browser to ignore this case. cc ```@jsha``` r? ```@notriddle```
…r=notriddle Add check in GUI test for file loading failure Since rust-lang/rust#101702, some resources location need to be updated in case their content changed because then their hash will change too. This will prevent errors like rust-lang/rust#104114 to happen again. The second commit is to prevent CORS errors: when a file is linked from a file itself imported, the web browser considers they come from a different domain and therefore triggers the error. The option tells the web browser to ignore this case. cc ```@jsha``` r? ```@notriddle```
All static files used by rustdoc are now stored in static.files/ and their filenames include a hash of their contents. Their filenames no longer include the contents of the --resource-suffix flag. This clarifies caching semantics. Anything in static.files can use Cache-Control: immutable because any updates will show up as a new URL.
Invocation-specific files like crates-NN.js, search-index-NN.js, and sidebar-items-NN.js still get the resource suffix.
This has a useful side effect: once toolchain files aren't affected by resource suffix, it will become possible for docs.rs to include crate version in the resource suffix. That should fix a caching issue with
/latest/
URLs: rust-lang/docs.rs#1593. My goal is that it should be safe to serve all rustdoc JS, CSS, and fonts with infinite caching headers, even when new versions of a crate are uploaded in the same place as old versions.The --disable-minification flag is removed because it would vary the output of static files based on invocation flags. Instead, for rustdoc development purposes it's preferable to symlink static files to a non-minified copy for quick iteration.
Example listing:
Fixes #98413