1
Fork 0
Commit graph

399 commits

Author SHA1 Message Date
Guillaume Gomez
fc61cca41c Expand sub code blocks block content when hidden when the page hash refers to it 2020-07-02 13:19:04 +02:00
Guillaume Gomez
0fcb7dabac Improve page hash handling 2020-07-02 13:19:04 +02:00
Guillaume Gomez
d5141e6829 No need to call getPageId a second time 2020-07-02 13:19:04 +02:00
Manish Goregaokar
a25fbb9710
Rollup merge of #72967 - integer32llc:prevent-default-arrows, r=kinnison
Don't move cursor in search box when using arrows to navigate results

## What happens

- Go to https://doc.rust-lang.org/stable/std/index.html
- Press 's' to focus the search box
- Type a query like 'test'
- Press the down arrow one or more times to change which search result is highlighted
- Press the up arrow once to go up one search result
- Notice the cursor in the search box is now at the beginning of your query, such that if you now typed 'a' the search box would contain 'atest', when it would be expected that the cursor would have remained where it was and if you typed 'a' at this point it would result in 'testa'
- Press the down arrow once to go down one search result
- Now notice the cursor is at the end of your query again

## What I expected

I expected that changing which search result was highlighted using the up and down arrows would have no effect on where the cursor was in the search box.

## The fix

This PR prevents the default action of the up and down arrows when the custom keydown events are happening during a search.
2020-06-26 00:38:58 -07:00
Oliver Middleton
478750c1db rustdoc: Fix doc aliases with crate filtering
Fix a crash when searching for an alias contained in the currently selected filter crate.

Also remove alias search results for crates that should be filtered out.

The test suite needed to be fixed to actually take into account the crate filtering and check that there are no results when none are expected.
2020-06-23 09:27:37 +01:00
Manish Goregaokar
bf59152c01
Rollup merge of #72968 - integer32llc:docs-arrow-keys, r=GuillaumeGomez
Only highlight doc search results via mouseover if mouse has moved

## What happens

- Go to https://doc.rust-lang.org/stable/std/index.html
- Put your mouse cursor somewhere in the middle where search results will appear and then don't move the mouse
- Press 's' to focus the search box
- Type a query that brings up enough search results to go under where your mouse cursor is
- Press the down arrow
- The search result that is one below where your mouse cursor is will be highlighted.

## What I expected

When not currently using the mouse, I expect doing a search and then pressing the down arrow to always highlight the first search result immediately below the search box.

## The fix

This feels a bit hacky to me; I'm open to other solutions. This introduces a global JS var that keeps track of whether the person searching has moved their mouse after doing a search or not, and only uses the mouse position to highlight search results if the person HAS moved the mouse AFTER doing a search.
2020-06-18 15:20:49 -07:00
Dylan DPC
98bd22bda3
Rollup merge of #71842 - tspiteri:doc-impl-const, r=GuillaumeGomez
doc: make impl block collapsible if it has an associated constant

Fixes #71822.
2020-06-08 22:15:08 +02:00
Carol (Nichols || Goulding)
1bc4e45b3f
Only highlight results via mouseover if mouse has moved 2020-06-03 21:18:39 -04:00
Carol (Nichols || Goulding)
e85df08bde
Don't move cursor in search box when using arrows to navigate search results 2020-06-03 21:09:55 -04:00
Dylan DPC
6cd9a67314
Rollup merge of #72691 - GuillaumeGomez:escape-key-handling, r=kinnison
Fix escape key handling

Fixes #72647.

The problem was that you could have a timeout just after the moment you press "escape", putting back the results.

r? @kinnison
2020-05-31 21:30:00 +02:00
Guillaume Gomez
7a2efa3a10 Put input timeout clearance inside a function 2020-05-31 14:27:33 +02:00
Guillaume Gomez
bcf57d8f20 Fix escape key handling 2020-05-28 14:51:12 +02:00
Trevor Spiteri
da18df2859 doc: make impl block collapsible if it has an associated constant
Fixes #71822.
2020-05-27 12:00:53 +02:00
Guillaume Gomez
a423d2d4b0 Improve formatting 2020-05-26 15:11:44 +02:00
Guillaume Gomez
f41d284ea0 Fix eslint lints 2020-05-26 11:18:10 +02:00
Guillaume Gomez
872ddf243e Reexported functions are now declared directly as "windows" field 2020-05-26 11:18:10 +02:00
Guillaume Gomez
deaf5e200e Move "global" code into anonymous functions 2020-05-26 11:18:10 +02:00
Guillaume Gomez
0fa4762a80 Move focusSearchBar and defocusSearchBar functions to the top of the file with other functions 2020-05-26 11:18:10 +02:00
Ralf Jung
e279bd5366
Rollup merge of #72272 - GuillaumeGomez:fix-back-on-page-with-search-behaviour, r=kinnison
Fix going back in history to a search result page on firefox

This bug was actually firefox not re-running JS script when you go back in history. To trigger it on the current docs:

 * Make a search
 * Pick an element (which isn't on the same page as the current element!)
 * Go back in history

Instead of having the search results, you'll see the normal doc page. You can find a small explanation about it [here](http://web.archive.org/web/20100428053932/http://www.firefoxanswer.com/firefox/672-firefoxanswer.html).

r? @kinnison

cc @ollie27
2020-05-21 13:12:17 +02:00
Guillaume Gomez
ed8478036c Fix going back in history to a search result page on firefox 2020-05-19 16:48:21 +02:00
Guillaume Gomez
e17ac66899 * Update aliases data struct from HashMap to BTreeMap to have more deterministic results
* Update Javascript to take this change into account
* Update CrateData::aliases field to take a reference instead (it allowed to remove a conversion loop)
2020-05-14 11:36:02 +02:00
Guillaume Gomez
c4d9318be6 Make current crate aliases go first 2020-05-14 11:36:02 +02:00
Guillaume Gomez
883c177abb Move doc alias discovery into the Attributes struct and some code improvements 2020-05-14 11:35:44 +02:00
Guillaume Gomez
f581cf7544 Merge aliases and search-index 2020-05-07 20:08:08 +02:00
Guillaume Gomez
7590c393de Improve doc alias JS code 2020-05-07 20:08:08 +02:00
Guillaume Gomez
e17f36b82e Replace title "Methods" with "Implementations" 2020-05-05 22:56:23 +02:00
Guillaume Gomez
496256c561 Update src/librustdoc/html/static/main.js
Fix variable name

Co-Authored-By: Mazdak Farrokhzad <twingoow@gmail.com>
2020-03-16 18:30:26 +01:00
Guillaume Gomez
5654cde729 formatting 2020-03-16 18:30:26 +01:00
Guillaume Gomez
b9167e6c7d Support type search for arguments and returned types 2020-03-16 18:29:19 +01:00
Guillaume Gomez
1244ced958 Remove "important traits" feature 2020-02-27 14:51:22 +01:00
bors
8ba3ca0e6b Auto merge of #68668 - GuillaumeGomez:struct-variant-field-search, r=ollie27
Struct variant field search

Fixes #16017.

Reopening of #64724.

cc @tomjakubowski
cc @ollie27

r? @kinnison
2020-02-15 22:32:51 +00:00
Tom Jakubowski
05c6f329e7 rustdoc: emit JS paths for struct-like variants
On the backend, rustdoc now emits `paths` entries to a crate's search
index for struct-like enum variants, and index items of type structfield
which belong to such variants point to their variant parents in the
`paths` table, rather than their enum grandparents.  The path entry for
a variant is the fully qualified module path plus the enum name.

On the frontend, the search code recognizes structfields belonging to
structlike variants in the `paths` table and re-constructs the URL to
the field's anchor on the enum documentation page.

closes #16017
2020-01-30 13:39:01 +01:00
Guillaume Gomez
0754461e02 Fix null synthetic_implementors error 2020-01-28 23:32:29 +01:00
Guillaume Gomez
12882a8392 Remove usage of global variable "inlined_types" 2020-01-20 13:34:44 +01:00
Oliver Middleton
79f59fa820 rustdoc: HTML escape arrows on help popup 2020-01-12 23:37:47 +00:00
Guillaume Gomez
71ff18fb89 Fix invalid results showing back 2019-12-22 15:42:29 +01:00
Guillaume Gomez
b67701347a Improve code readability 2019-12-22 15:42:10 +01:00
Guillaume Gomez
4ce2384501 Improve JS code a bit by avoid erasing all event handlers 2019-12-22 14:14:37 +01:00
Guillaume Gomez
5f68732b04 Fix JS error when loading page with search 2019-12-15 21:27:25 +01:00
Guillaume Gomez
5748b4ce95 Add missing check 2019-12-02 10:25:36 +01:00
Mazdak Farrokhzad
4bd9168d7f
Rollup merge of #66514 - GuillaumeGomez:fix-search-filter-save, r=kinnison
Fix selected crate search filter

Fixes #62929.

r? @kinnison
2019-11-20 18:32:10 +01:00
Mazdak Farrokhzad
00cbc75c74
Rollup merge of #66298 - Ppjet6:disable-search-field, r=GuillaumeGomez
rustdoc: fixes #64305: disable search field instead of hidding it

The result seems to be ok but I wasn't entirely sure how to get there. I tried to stay generic a bit but maybe it's not required at all.

@GuillaumeGomez

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-11-20 18:32:06 +01:00
Maxime “pep” Buquet
5cbd406a14 rustdoc: fixes #64305: disable search field instead of hidding it
Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
2019-11-20 11:32:58 +01:00
Mazdak Farrokhzad
95b9766e0a
Rollup merge of #66430 - dns2utf8:fix_code_selection_click_handler, r=GuillaumeGomez
[doc] Fix the source code highlighting on source comments

The code would always forget the previous selection.

r? @GuillaumeGomez
2019-11-19 13:10:15 +01:00
Guillaume Gomez
00ef5c1b98 Fix selected crate search filter 2019-11-18 14:15:00 +01:00
Stefan Schindler
1bbb8168ec Prevent jumps when selecting one or many lines 2019-11-15 02:30:44 +01:00
Stefan Schindler
71cf364c3c Fix the source code highlighting on source comments 2019-11-15 02:02:09 +01:00
Stefan Schindler
cee0403b5c Code cleanup to remove douplacte var definition
Also move the declaration outside the loop since they accumulate state with each iteration
2019-11-15 00:45:08 +01:00
Stefan Schindler
e3afe6ac23 Remove unused argument 2019-11-15 00:27:53 +01:00
Yuki Okushi
392ebad5c6
Rollup merge of #66123 - GuillaumeGomez:no-more-hidden-elements, r=Dylan-DPC
No more hidden elements

Fixes #66046.

Follow-up of #66082.

r? @kinnison
2019-11-08 13:42:19 +09:00