Skip to content

Move crate drop-down to search results page #92490

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 2 commits into from
Jan 9, 2022

Conversation

jsha
Copy link
Contributor

@jsha jsha commented Jan 2, 2022

@rust-highfive
Copy link
Contributor

Some changes occurred in HTML/CSS/JS.

cc @GuillaumeGomez

@rustbot rustbot added the T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. label Jan 2, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jan 2, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@@ -1126,9 +1126,16 @@ window.initSearch = function(rawSearchIndex) {
}
}

var output = "<h1>Results for " + escape(query.query) +
let crates = `<select id="crate-search"><option value="All crates">All crates</option>`;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't eslint complaining when you use backticks without ${} content?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope! I wouldn't expect it to. Backticks do a bunch of things besides template expansion. They also allow multiline strings, and serve as a different delimiter so you don't have to backslash double quotes (\")

@GuillaumeGomez
Copy link
Member

As said previously, I really like it! The display needs a bit of improvement: the in is too small I think (but maybe it's voluntary?). Maybe we should force the dropdown to be on its own line on mobile? Currently it gives (with long search string):

Screenshot from 2022-01-02 18-09-51

The style of the dropdown is incomplete I think: the border is looking strange.

In any case, it's a nice start. :)

@jsha
Copy link
Contributor Author

jsha commented Jan 2, 2022

the in is too small I think (but maybe it's voluntary?).

This was on purpose, since in ____ isn't part of the title (<h1>). But I could make it the same size as the <h1>, just outside the tag? I don't have a strong opinion about what's better.

Maybe we should force the dropdown to be on its own line on mobile?

Good idea.

@camelid
Copy link
Member

camelid commented Jan 2, 2022

I also had an idea recently that could help with this (I forget if I mentioned it or not). We could add a crate:some_crate search syntactical form. Then we could add it as an option to the advanced search builder @jsha proposed.

@camelid
Copy link
Member

camelid commented Jan 2, 2022

This was on purpose, since in ____ isn't part of the title (<h1>). But I could make it the same size as the <h1>, just outside the tag? I don't have a strong opinion about what's better.

It looks very strange to me. The select also renders differently from how it used to:

image

The bezel seems a bit extreme.

@jsha
Copy link
Contributor Author

jsha commented Jan 2, 2022 via email

@camelid
Copy link
Member

camelid commented Jan 2, 2022

Firefox on macOS.

@jsha jsha force-pushed the crates-in-results branch 3 times, most recently from 6958519 to 3f3b976 Compare January 3, 2022 01:22
@jsha
Copy link
Contributor Author

jsha commented Jan 3, 2022

Alright, I've increased the size of in and fixed the border issue (I had overzealously removed a border:0 in the CSS that turned out to be needed). I also tweaked the padding slightly. Demo is pushed and ready for another look!

@rust-log-analyzer

This comment has been minimized.

@jsha jsha force-pushed the crates-in-results branch from 3f3b976 to 8abe0ab Compare January 5, 2022 05:27
@camelid camelid added the A-rustdoc-ui Area: Rustdoc UI (generated HTML) label Jan 5, 2022
@rust-log-analyzer

This comment has been minimized.

@jsha jsha force-pushed the crates-in-results branch from 8abe0ab to 5c3e82a Compare January 5, 2022 14:57
@rust-log-analyzer

This comment has been minimized.

(query.type ? " (type: " + escape(query.type) + ")" : "") + "</h1>" +
"<div id=\"titles\">" +
` in ${crates} ` +
"</div><div id=\"titles\">" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think backticks would be better here as well.

@@ -40,5 +40,5 @@ ENV SCRIPT python3 ../x.py --stage 2 test src/tools/expand-yaml-anchors && \
/scripts/validate-toolstate.sh && \
/scripts/validate-error-codes.sh && \
# Runs checks to ensure that there are no ES5 issues in our JS code.
es-check es5 ../src/librustdoc/html/static/js/*.js && \
es-check es6 ../src/librustdoc/html/static/js/*.js && \
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We wanted to make this change in bigger PR but I guess it's fine... Don't forget to update the comment just above please.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually think a giant PR adding ES6 features wherever possible, and updating the linter at the same time would be a bad idea. The way we should do it is like I'm doing here:

  • update the linter to accept es6 as a standalone commit
  • start using es6 features where they are useful
  • do a series of standalone commits that do one of two things:
    • adopt an ES6 feature where it is useful (e.g. const everything that can be consted), or
    • migrate a discrete chunk of code to using various useful ES6 features.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like I said, it's fine. 😉

jsha added 2 commits January 5, 2022 11:44
Also update Node to v16.9.0, es-check to 6.1.1, and eslint to 8.6.0.
This reduces clutter on doc pages.
@jsha jsha force-pushed the crates-in-results branch from 5c3e82a to 8abb4bb Compare January 5, 2022 17:57
@GuillaumeGomez
Copy link
Member

Thanks!

@bors: r+

@bors
Copy link
Collaborator

bors commented Jan 5, 2022

📌 Commit 8abb4bb has been approved by GuillaumeGomez

@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 Jan 5, 2022
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 5, 2022
…Gomez

Move crate drop-down to search results page

This reduces clutter on doc pages.

Part of rust-lang#59840

r? `@GuillaumeGomez`

Demo: https://rustdoc.crud.net/jsha/crates-in-results/std/index.html?search=str
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Jan 6, 2022
…Gomez

Move crate drop-down to search results page

This reduces clutter on doc pages.

Part of rust-lang#59840

r? ``@GuillaumeGomez``

Demo: https://rustdoc.crud.net/jsha/crates-in-results/std/index.html?search=str
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 9, 2022
…askrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#92055 (Add release notes for 1.58)
 - rust-lang#92490 (Move crate drop-down to search results page)
 - rust-lang#92510 (Don't resolve blocks in foreign functions)
 - rust-lang#92573 (expand: Refactor InvocationCollector visitor for better code reuse)
 - rust-lang#92608 (rustdoc: Introduce a resolver cache for sharing data between early doc link resolution and later passes)
 - rust-lang#92657 (Implemented const casts of raw pointers)
 - rust-lang#92671 (Make `Atomic*::from_mut` return `&mut Atomic*`)
 - rust-lang#92673 (Remove useless collapse toggle on "all items" page)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 598364c into rust-lang:master Jan 9, 2022
@rustbot rustbot added this to the 1.60.0 milestone Jan 9, 2022
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
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.

7 participants