Skip to content

Switch settings menu to full js - #93097

Merged
bors merged 4 commits into
rust-lang:masterfrom
GuillaumeGomez:settings-js
May 3, 2022
Merged

Switch settings menu to full js#93097
bors merged 4 commits into
rust-lang:masterfrom
GuillaumeGomez:settings-js

Conversation

@GuillaumeGomez

@GuillaumeGomezGuillaumeGomez commented Jan 19, 2022

Copy link
Copy Markdown
Member

Since the settings can only be set when the JS is enabled, it's not really a problem. It also fixes a debate we had around the themes not being accessible easily before.

Screenshot from 2022-01-19 23-06-59

You can test it here.

r? @jsha

@GuillaumeGomezGuillaumeGomez 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 Jan 19, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez,@Folyd

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 19, 2022
@jsha

jsha commented Jan 19, 2022

Copy link
Copy Markdown
Contributor

Some early feedback from testing: This should generate a page navigation event, like searching does, so that when you hit the "back" button in your browser you go back to the page you were on.

The page navigation event should make the URL /settings.html, and we could keep an actual settings.html that just calls the JS to generate the page contents.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

The page navigation event should make the URL /settings.html, and we could keep an actual settings.html that just calls the JS to generate the page contents.

That'd mean that we'd need to have a settings.html file in every folder, no? Maybe simpler to keep it like search with a query parameter, don't you think?

Comment threadsrc/librustdoc/templates/page.html Outdated
@jsha

jsha commented Jan 19, 2022

Copy link
Copy Markdown
Contributor

That'd mean that we'd need to have a settings.html file in every folder, no? Maybe simpler to keep it like search with a query parameter, don't you think?

No, I'm proposing to have one settings.html per documentation instance, just like we have today - and in exactly the same place.

Comment threadsrc/librustdoc/html/static/js/main.js Outdated
@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

No, I'm proposing to have one settings.html per documentation instance, just like we have today - and in exactly the same place.

I'm not a big fan of the idea: it means duplicating where the settings are set and generated... I think it's extra work for not much gain.

@jsha

jsha commented Jan 19, 2022

Copy link
Copy Markdown
Contributor

it means duplicating where the settings are set and generated... I think it's extra work for not much gain.

I think you misunderstand me. I'm not proposing that we should generate the settings into HTML. I'm proposing that we have HTML that is an empty shell, and just calls loadScript(window.settingsJS);. The settingsJS is still responsible for rendering the settings via JS.

@rust-log-analyzer

This comment has been minimized.

@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

it means duplicating where the settings are set and generated... I think it's extra work for not much gain.

I think you misunderstand me. I'm not proposing that we should generate the settings into HTML. I'm proposing that we have HTML that is an empty shell, and just calls loadScript(window.settingsJS);. The settingsJS is still responsible for rendering the settings via JS.

Oh indeed. Great idea!

@bors

bors commented Jan 20, 2022

Copy link
Copy Markdown
Collaborator

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

@rust-log-analyzer

This comment has been minimized.

@bors

bors commented Jan 23, 2022

Copy link
Copy Markdown
Collaborator

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

@JohnCSimonJohnCSimon added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 27, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@jsha

jsha commented Apr 28, 2022

Copy link
Copy Markdown
Contributor

This needs another merge deconflict.

@jsha

jsha commented Apr 28, 2022

Copy link
Copy Markdown
Contributor

From the demo:

image

Two problems:

  • This says "preferred-dark-theme" etc, but should say "Preferred dark theme"
  • The "Preferred light theme" setting should come ahead of the "Preferred dark theme" as it currently does.

Comment threadsrc/librustdoc/html/static/js/settings.js Outdated
Comment threadsrc/librustdoc/html/static/js/settings.js Outdated
@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

Thanks for the review! I'll update it tomorrow.

@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

Updated!

@bors

bors commented Apr 30, 2022

Copy link
Copy Markdown
Collaborator

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

@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

Fixed merge conflicts. :)

@jsha

jsha commented May 1, 2022

Copy link
Copy Markdown
Contributor

This still has "Preferred dark theme" above "Preferred light theme." It should be the other way around, to match the current UI.

Comment threadsrc/librustdoc/html/static/js/main.js Outdated
Comment threadsrc/librustdoc/html/static/js/main.js Outdated
Comment threadsrc/librustdoc/html/static/js/settings.js Outdated
Comment threadsrc/librustdoc/html/static/js/settings.js Outdated
* Improve code.
* Fix some documentation argument types.
* Make settings order the same as before this PR.
* Change timeout to 0 so that browser will render it as fast as possible.
@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

Updated and uploaded updated version. :)

@jsha

jsha commented May 2, 2022

Copy link
Copy Markdown
Contributor

@bors r+ rollup

@bors

bors commented May 2, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 73688e4 has been approved by jsha

@borsbors 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 May 2, 2022
@GuillaumeGomez

Copy link
Copy Markdown
MemberAuthor

🎉

GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request May 2, 2022
Switch settings menu to full js
Since the settings can only be set when the JS is enabled, it's not really a problem. It also fixes a debate we had around the themes not being accessible easily before.
![Screenshot from 2022-01-19 23-06-59](https://user-images.githubusercontent.com/3050060/150221936-fd1a1e76-06b6-4416-a653-dbae111979ed.png)
You can test it [here](https://rustdoc.crud.net/imperio/settings-js/doc/foo/index.html).
r? `@jsha`
@JohnTitorJohnTitor mentioned this pull request May 3, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request May 3, 2022
Rollup of 8 pull requests
Successful merges:
- rust-lang#93097 (Switch settings menu to full js)
- rust-lang#96587 (Refactor the WriteBackendMethods and ExtraBackendMethods traits)
- rust-lang#96589 (Use source callsite in check_argument_types suggestion)
- rust-lang#96599 (Update `RValue::Discriminant` documentation)
- rust-lang#96614 (Add a regression test for rust-lang#92305)
- rust-lang#96629 (Fix invalid keyword order for function declarations)
- rust-lang#96641 (Use a yes/no enum instead of a bool.)
- rust-lang#96646 (Mitigate impact of subtle invalid call suggestion logic)
Failed merges:
r? `@ghost`
`@rustbot` modify labels: rollup
@bors
bors merged commit 27d7615 into rust-lang:masterMay 3, 2022
@rustbotrustbot added this to the 1.62.0 milestone May 3, 2022
@GuillaumeGomez
GuillaumeGomez deleted the settings-js branch May 3, 2022 09:22
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-rustdoc-jsArea: Rustdoc's JS front-endA-rustdoc-uiArea: Rustdoc UI (generated HTML)S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-rustdocRelevant 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.

8 participants

@GuillaumeGomez@rust-highfive@jsha@rust-log-analyzer@bors@notriddle@JohnCSimon@rustbot