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

Correctly handle crate level page on docs.rs as well #99209

Merged
merged 1 commit into from
Jul 15, 2022

Conversation

GuillaumeGomez
Copy link
Member

Fixes #99121.

On docs.rs, they move the class attribute into a child which still has rustdoc. So instead of using the <body>, we can simply use this one directly.

r? @jsha

@GuillaumeGomez GuillaumeGomez added T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. A-rustdoc-ui Area: Rustdoc UI (generated HTML) A-rustdoc-js Area: Rustdoc's JS front-end labels Jul 13, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 13, 2022
@jsha
Copy link
Contributor

jsha commented Jul 13, 2022

Let's actually remove the JS check. Right now most of the logic for this is in our page template that decides which "extra" JS to include:

https://github.com/rust-lang/rust/blob/master/src/librustdoc/html/templates/page.html#L37-L44

That is, crate pages get the crates list; source pages get the source files list; all other pages get the sidebar-items.

For consistency with your intent from https://github.com/rust-lang/rust/pull/84834/files#r625337543, this should become:

That is, crate pages get the crates list; source pages get the source files list; all other (non-mod) pages get the sidebar-items.

@notriddle
Copy link
Contributor

@jsha You mean something like this?

diff --git a/src/librustdoc/html/templates/page.html b/src/librustdoc/html/templates/page.html
index dfb3e4e6a2c..db45253ef69 100644
--- a/src/librustdoc/html/templates/page.html
+++ b/src/librustdoc/html/templates/page.html
@@ -39,7 +39,7 @@
     {%- else if page.css_class == "source" -%}
     <script defer src="{{static_root_path|safe}}source-script{{page.resource_suffix}}.js"></script> {#- -#}
     <script defer src="{{page.root_path|safe}}source-files{{page.resource_suffix}}.js"></script> {#- -#}
-    {%- else -%}
+    {%- else if page.css_class != "mod" -%}
     <script defer src="sidebar-items{{page.resource_suffix}}.js"></script> {#- -#}
     {%- endif -%}
     <script defer src="{{static_root_path|safe}}main{{page.resource_suffix}}.js"></script> {#- -#}

@jsha
Copy link
Contributor

jsha commented Jul 13, 2022

Yes, although that should be a .contains("mod"), since crate pages have css_class: "crate mod".

@GuillaumeGomez
Copy link
Member Author

GuillaumeGomez commented Jul 14, 2022

Less JS and less JS files loaded. That sounds like a big win. :)

PS: updated!

@GuillaumeGomez
Copy link
Member Author

Updated with @jsha's suggestion.

@jsha
Copy link
Contributor

jsha commented Jul 14, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Jul 14, 2022

📌 Commit b98fb49 has been approved by jsha

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 Jul 14, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 15, 2022
Rollup of 5 pull requests

Successful merges:

 - rust-lang#88991 (Add Nintendo Switch as tier 3 target)
 - rust-lang#98869 (Remove some usages of `guess_head_span`)
 - rust-lang#99119 (Refactor: remove a string matching about methods)
 - rust-lang#99209 (Correctly handle crate level page on docs.rs as well)
 - rust-lang#99246 (Update RLS)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 5c8c4db into rust-lang:master Jul 15, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 15, 2022
@GuillaumeGomez GuillaumeGomez deleted the crate-level-sidebar branch July 15, 2022 14:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustdoc-js Area: Rustdoc's JS front-end A-rustdoc-ui Area: Rustdoc UI (generated HTML) S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

rustdoc: sidebar items not shown on crate page on docs.rs
6 participants