Commit Graph

303 Commits

Author SHA1 Message Date
Kazuyoshi Kato
1f441a0905 Check null-able variables before using them 2018-08-23 08:15:23 -07:00
Kazuyoshi Kato
917cdd295d Automatically expand a section even after page load
Fixes #52774
2018-08-23 00:45:43 -07:00
Guillaume Gomez
e87b4b3100 Search a substring instead of start of string in rustdoc search 2018-08-22 00:21:08 +02:00
Jack O'Connor
207550981f restore the page title after escaping out of a search 2018-08-15 23:05:52 -04:00
Guillaume Gomez
e37391b389 Remove unwanted console log 2018-08-10 18:48:36 +02:00
Guillaume Gomez
c70eb4b6ea Automatically expand section if url id point to one of its component 2018-08-05 19:44:10 +02:00
Guillaume Gomez
2462cdb71d Fix trait item doc setting, add new setting, start hiding elements by default and then showing them up 2018-08-02 00:19:04 +02:00
bors
11864c4e6c Auto merge of #51854 - davidtwco:rfc-2008-rustdoc, r=QuietMisdreavus
RFC 2008 non-exhaustive enums/structs: Rustdoc

Part of #44109. Not sure how those who maintain rustdoc primarily would prefer this addition look or where it should be placed, happy to make any changes required.

r? @QuietMisdreavus (not sure if this is the right person, just guessing)
2018-07-19 19:03:03 +00:00
David Wood
959a13d53e
Updated wording and placement of non-exhaustive notice so it is collapsed by default and easier to understand. 2018-07-18 20:27:25 +01:00
Guillaume Gomez
c0ec5d5e44 Add setting to prevent doc auto-hide of trait implementations 2018-07-08 15:07:06 +02:00
Guillaume Gomez
115df57757 reduce search-index size 2018-06-30 16:28:25 +02:00
Guillaume Gomez
e3b258324b Remove unused variable 2018-06-25 21:47:44 +02:00
Guillaume Gomez
f4ea46a5b3 Extend collision prevention to every type 2018-06-18 21:39:54 +02:00
Guillaume Gomez
afeb790ea1 Fix macro missing from doc search 2018-06-16 14:14:18 +02:00
Guillaume Gomez
e28502edca Fix search fn keyword 2018-06-15 23:23:25 +02:00
kennytm
ca65a5e485
Don't auto-hide inherent impls even if rustdoc-collapse == true. 2018-06-13 18:00:18 +08:00
Guillaume Gomez
ebee483e24 Add doc keyword support 2018-06-04 09:51:41 +02:00
Guillaume Gomez
26ad95c9d4 Add attributes for trait and methods as well 2018-06-02 23:26:46 +02:00
Guillaume Gomez
c7312fbae4 Fixes some style issues in rustdoc "implementations on Foreign types" 2018-05-30 01:12:23 +02:00
Guillaume Gomez
934e37aeb4
Rollup merge of #50632 - GuillaumeGomez:minification, r=ollie27
Add minification process

r? @QuietMisdreavus
2018-05-15 14:26:59 +02:00
Guillaume Gomez
f0db2cf14e Use fullpath instead of recreating it 2018-05-12 23:44:40 +02:00
Guillaume Gomez
f2bc09e68b Fix invalid deduplication 2018-05-12 19:16:37 +02:00
Guillaume Gomez
8fab482a68 Fix items counts in search results 2018-05-12 19:16:37 +02:00
Guillaume Gomez
6a4bdda87b Reduce js files size 2018-05-12 19:16:37 +02:00
Guillaume Gomez
72b7c8d291 Remove extra span tags 2018-05-12 19:16:37 +02:00
Guillaume Gomez
e81b59bba8 Improve alias rendering 2018-05-12 19:16:37 +02:00
Guillaume Gomez
cf9209f872 Improve results 2018-05-12 19:16:37 +02:00
Guillaume Gomez
4b14573d50 Add minification process 2018-05-12 19:15:06 +02:00
Guillaume Gomez
d0840fd63b Fix paths search 2018-05-05 12:44:10 +02:00
Guillaume Gomez
135ee85aba Rename "show type declaration" to "show declaration" 2018-04-30 22:32:17 +02:00
Guillaume Gomez
acf0adf798 Add setting to go to item if there is only one result 2018-04-26 19:53:21 +02:00
Guillaume Gomez
ac0f99c03f Some JS improvements 2018-04-25 09:01:32 +02:00
Guillaume Gomez
f33af5c4de fix search bar bug 2018-04-23 23:55:36 +02:00
bors
28193e873c Auto merge of #49954 - GuillaumeGomez:doc-settings, r=ollie27,QuietMisdreavus
Add rustdoc settings menu

Fixes #18167.

r? @QuietMisdreavus
2018-04-22 11:04:41 +00:00
Guillaume Gomez
d0e2d26ceb remove unused condition 2018-04-21 22:02:54 +02:00
Guillaume Gomez
ca3213c338 fix invalid items removal 2018-04-21 22:02:54 +02:00
Guillaume Gomez
03b0856849 Add aliases in the search as well 2018-04-21 22:02:53 +02:00
Guillaume Gomez
654cb84852 Add specific never search 2018-04-21 22:01:38 +02:00
Guillaume Gomez
f2ad3c3f6c Add rustdoc settings menu 2018-04-17 23:35:43 +02:00
Guillaume Gomez
47a9ffa573 Add multi-query search 2018-04-14 17:01:28 +02:00
Guillaume Gomez
238583a50f Fix anchors issue when everything is collapsed 2018-04-04 16:16:53 +02:00
bors
15e8c5d846 Auto merge of #49412 - GuillaumeGomez:hide-type-decl, r=QuietMisdreavus
Hide type declarations by default

I'm not very happy for the moment about the rendering but the bases are here:

<img width="610" alt="screen shot 2018-03-27 at 11 56 27" src="https://user-images.githubusercontent.com/3050060/37960492-0e045954-31b6-11e8-9cea-1ef8a3f980c4.png">

r? @QuietMisdreavus
2018-03-30 01:45:54 +00:00
kennytm
1a89250356
Rollup merge of #49439 - GuillaumeGomez:trait-impl-collapse, r=QuietMisdreavus
Fix trait implementation not collapsing docs

r? @QuietMisdreavus
2018-03-28 17:55:16 +02:00
kennytm
611ceef28d
Rollup merge of #49429 - GuillaumeGomez:fix-collapse-toggle-insertion, r=QuietMisdreavus
Fix collapse toggle insertions on impl with docs

Just went through this one randomly... When an impl has docs, the collapse toggle isn't generated. This fixes it.

r? @QuietMisdreavus
2018-03-28 17:55:14 +02:00
Guillaume Gomez
884153a257 Fix trait implementation not collapsing docs 2018-03-28 09:51:18 +02:00
Guillaume Gomez
8be26a2ca0 Fix collapse toggle insertions on impl with docs 2018-03-27 22:49:55 +02:00
Guillaume Gomez
73b97c7e7c Hide type declarations by default 2018-03-27 11:57:00 +02:00
Guillaume Gomez
96ef2f8ab9 Fix search appearance 2018-03-27 10:33:31 +02:00
Guillaume Gomez
90588a9086 Fix IE11 search 2018-03-23 21:27:15 +01:00
Guillaume Gomez
5581aa8eeb Fix events handling in rustdoc 2018-03-18 16:32:41 +01:00
kennytm
15d71d3285
Rollup merge of #48631 - focusaurus:remember-collapse-setting, r=QuietMisdreavus
Remember state of top-level collapse toggle widget

This change allows the big top-right expand/collapse toggle to remember its setting across navigation or page reloads. Prior to this change, there was this annoyance:

- browse to some docs
- Click the minus button to collapse them
- browse to other docs (or reload the page)
- Everything is expanded again

The solution is based on storing a simple boolean flag in localStorage. I think it's a good improvement, but it does introduce the following potentially surprising behavior:

- browse to some docs
- click the minus button to collapse them
- click to expand a particular item (not the main top-right big one)
- reload the page, everything is collapsed

Paired with @debugsteven on this.
2018-03-13 05:01:15 +08:00
Guillaume Gomez
9e0ccc5a47 Fix escape not working when searchbar selected 2018-03-09 17:45:44 +01:00
Guillaume Gomez
6235ef0422 Add missing items in the sidebar for functions 2018-03-09 17:45:44 +01:00
Guillaume Gomez
a628543891 Don't generate '[+]'/'[-]' on 'empty' traits 2018-03-05 23:39:34 +01:00
Peter Lyons
2dd81c86c5 Rename doc collapse sentinal to rustdoc-collapse 2018-03-01 02:50:32 -07:00
Peter Lyons
55cc9a4336 Remember state of top-level collapse toggle widget 2018-03-01 00:03:47 -07:00
kennytm
71ce38eb9e
Rollup merge of #48381 - GuillaumeGomez:rustdoc-theme-securities, r=QuietMisdreavus
Rustdoc theme securities

Fixes #48375.
Fixes #48376.

r? @steveklabnik
cc @QuietMisdreavus
2018-02-28 19:15:31 +08:00
bors
89e5a0796e Auto merge of #47894 - vi:rustdoc_foldable_impls, r=GuillaumeGomez,QuietMisdreavus
rustdoc: Foldable impl blocks

Addresses #40363, #45720, #24483, #23986 and so on

* Expands and refactors collapseDocs and toggleAllDocs
* Adds [-] toggle to all impls (including inherent impl)
* Makes it hiding though main css file, not though element inline style

May need to be addressed:

* "[-]" and anchor link copier are overlaid a bit
* Inherent methods are also hidden by the global [-] toggle.
* Auto-collapsing "Iterator" and so on by default is not implemented yet
* Tested only shallowly and only in Chromiuim
* No tests. Are there tests for css/js part here?
* The new implementation may be a bit slower.

What next steps are need to be done before the integration?
2018-02-28 04:24:18 +00:00
Guillaume Gomez
5b61b615f5 Allow to not switch to a theme if it doesn't exist 2018-02-20 20:11:58 +01:00
Aaron Hill
64a1f6fbfd
Fix inlining 2018-02-18 16:29:25 -05:00
Aaron Hill
1531fbe9be
Cleanup formatting 2018-02-18 16:29:25 -05:00
Aaron Hill
6728f21d85
Generate documentation for auto-trait impls
A new section is added to both both struct and trait doc pages.

On struct/enum pages, a new 'Auto Trait Implementations' section displays any
synthetic implementations for auto traits. Currently, this is only done
for Send and Sync.

On trait pages, a new 'Auto Implementors' section displays all types
which automatically implement the trait. Effectively, this is a list of
all public types in the standard library.

Synthesized impls for a particular auto trait ('synthetic impls') take
into account generic bounds. For example, a type 'struct Foo<T>(T)' will
have 'impl<T> Send for Foo<T> where T: Send' generated for it.

Manual implementations of auto traits are also taken into account. If we have
the following types:

'struct Foo<T>(T)'
'struct Wrapper<T>(Foo<T>)'
'unsafe impl<T> Send for Wrapper<T>' // pretend that Wrapper<T> makes
this sound somehow

Then Wrapper will have the following impl generated:
'impl<T> Send for Wrapper<T>'
reflecting the fact that 'T: Send' need not hold for 'Wrapper<T>: Send'
to hold

Lifetimes, HRTBS, and projections (e.g. '<T as Iterator>::Item') are
taken into account by synthetic impls

However, if a type can *never* implement a particular auto trait
(e.g. 'struct MyStruct<T>(*const T)'), then a negative impl will be
generated (in this case, 'impl<T> !Send for MyStruct<T>')

All of this means that a user should be able to copy-paste a synthetic
impl into their code, without any observable changes in behavior
(assuming the rest of the program remains unchanged).
2018-02-18 16:29:24 -05:00
Guillaume Gomez
e9bcb4eb89 Hide theme button under menu in mobile mode and fix top margin issue (in mobile too) 2018-02-08 23:47:49 +01:00
Guillaume Gomez
dde3611281 Fix rendering issues on mobile 2018-02-03 13:13:29 +01:00
Vitaly _Vi Shukela
28efcfc083
rustdoc: Fix erroneous collapsing of second+ inherent impl. 2018-02-01 17:07:43 +03:00
Vitaly _Vi Shukela
a3acd10297
rustdoc: Auto-collapse all non-inherent impls 2018-02-01 16:53:29 +03:00
Vitaly _Vi Shukela
c904b1bef4
rustdoc: Fix some minor issues per reviewer 2018-01-31 17:35:57 +03:00
Vitaly _Vi Shukela
7cd0280226
rustdoc: Fix tidy errors found by travis 2018-01-31 04:02:51 +03:00
Vitaly _Vi Shukela
73f52d3d8f
rustdoc: Foldable impl blocks
Addresses #40363, #45720, #24483, #23986 and so on

* Expands and refactors collapseDocs and toggleAllDocs
* Adds [-] toggle to all impls (including inherent impl)
* Makes it hiding though main css file, not though element style

May need to be addressed:

* "[-]" and anchor link copier are overlaid a bit
* Inherent methods are also hidden by the global [-] toggle.
* Auto-collapsing "Iterator" and so on by default is not implemented yet
* Tested only shallowly and only in Chromiuim
* No tests. Are there tests for css/js part here?
* The new implementation may be a bit slower.
2018-01-31 03:48:16 +03:00
bors
4e3901d35f Auto merge of #47678 - kennytm:rollup, r=kennytm
Rollup of 14 pull requests

- Successful merges: #47423, #47425, #47440, #47541, #47549, #47554, #47558, #47610, #47635, #47655, #47661, #47662, #47667, #47672
- Failed merges:
2018-01-23 16:13:18 +00:00
Guillaume Gomez
7cc3cb29bd Fix quoted search 2018-01-22 22:49:44 +01:00
Guillaume Gomez
003b2bc1c6 Add possibility to have multiple themes 2018-01-21 17:34:55 +01:00
Guillaume Gomez
53d8ec0ecb Prepare main.js for tests 2018-01-12 22:51:34 +01:00
Guillaume Gomez
eea860f84c Fix search bar defocus 2018-01-05 01:14:10 +01:00
Johannes Boczek
3153d23bb7 Indentation fix
Fixed intentaion (tabs -> spaces)
Added trailing newline
2018-01-02 19:58:06 +01:00
Johannes Boczek
0772b6faed Defocus search bar in rustdoc pages
Escape now removes focus from the search bar
2018-01-02 19:47:44 +01:00
Guillaume Gomez
7f5c2f9249 Fix sidebar on ios 2017-12-20 01:53:18 +01:00
Guillaume Gomez
25e5af8a27 Rollup merge of #46824 - GuillaumeGomez:doc-sidebar, r=QuietMisdreavus
Fix dynamic crates listing in doc sidebar

Fixes #46687.

r? @QuietMisdreavus
2017-12-18 23:08:40 +01:00
Guillaume Gomez
cf18b1f22a Fix dynamic crates listing in doc sidebar 2017-12-18 21:15:46 +01:00
Guillaume Gomez
97c18f420e Improve results a bit 2017-12-15 15:42:38 +01:00
Guillaume Gomez
6351ebb7e5 make doc search more relevant 2017-12-15 14:44:49 +01:00
Guillaume Gomez
557236c508 Fix type filter in rustdoc js 2017-12-12 00:19:36 +01:00
Guillaume Gomez
423e5ac6f3 Fix JS errors 2017-12-07 22:55:14 +01:00
Guillaume Gomez
71b70feb1f Greatly improve sidebar when width < 700px 2017-12-07 22:42:46 +01:00
bors
bb1bd88ec3 Auto merge of #46221 - GuillaumeGomez:doc-script-load-speedup, r=nrc
Speedup search loading when search url is received

Fixes #45971.

r? @nrc

cc @rust-lang/docs
2017-12-07 09:47:01 +00:00
bors
d10b04d3df Auto merge of #45898 - JRegimbal:master, r=QuietMisdreavus
Change "Types/modules" title of search tab to be more accurate

From issue #45787. Used "In name" as per suggestion from @Seeker14491.
2017-12-06 03:02:17 +00:00
JRegimbal
41df62ce29 Changed tab names to those agreed upon.
Tabs are "In Names", "In Parameters", and "In Return Types".
2017-12-05 17:39:50 -05:00
Guillaume Gomez
30734c4e68 Fix deduplication of items 2017-12-01 20:55:25 +01:00
Guillaume Gomez
0a1219809d Fix global search 2017-11-26 13:13:14 +01:00
bors
ca8ef26293 Auto merge of #46081 - GuillaumeGomez:fix-path-search, r=QuietMisdreavus
Fix path search

Fixes #46015.

r? @QuietMisdreavus
2017-11-25 02:43:48 +00:00
Guillaume Gomez
de3a291455 Speedup search loading when search url is received 2017-11-23 21:19:48 +01:00
bors
421a2113a8 Auto merge of #45039 - QuietMisdreavus:doc-spotlight, r=GuillaumeGomez,QuietMisdreavus
show in docs whether the return type of a function impls Iterator/Read/Write

Closes #25928

This PR makes it so that when rustdoc documents a function, it checks the return type to see whether it implements a handful of specific traits. If so, it will print the impl and any associated types. Rather than doing this via a whitelist within rustdoc, i chose to do this by a new `#[doc]` attribute parameter, so things like `Future` could tap into this if desired.

### Known shortcomings

~~The printing of impls currently uses the `where` class over the whole thing to shrink the font size relative to the function definition itself. Naturally, when the impl has a where clause of its own, it gets shrunken even further:~~ (This is no longer a problem because the design changed and rendered this concern moot.)

The lookup currently just looks at the top-level type, not looking inside things like Result or Option, which renders the spotlights on Read/Write a little less useful:

<details><summary>`File::{open, create}` don't have spotlight info (pic of old design)</summary>

![image](https://user-images.githubusercontent.com/5217170/31209495-e59d027e-a950-11e7-9998-ceefceb71c07.png)

</details>

All three of the initially spotlighted traits are generically implemented on `&mut` references. Rustdoc currently treats a `&mut T` reference-to-a-generic as an impl on the reference primitive itself. `&mut Self` counts as a generic in the eyes of rustdoc. All this combines to create this lovely scene on `Iterator::by_ref`:

<details><summary>`Iterator::by_ref` spotlights Iterator, Read, and Write (pic of old design)</summary>

![image](https://user-images.githubusercontent.com/5217170/31209554-50b271ca-a951-11e7-928b-4f83416c8681.png)

</details>
2017-11-21 03:03:28 +00:00
Guillaume Gomez
c00eaa9969 Strongly improve search path 2017-11-20 21:54:27 +01:00
Guillaume Gomez
ad6324f6f7 Fix path search in docs 2017-11-19 12:14:56 +01:00
Guillaume Gomez
6047a03659 Add tooltip for important traits display 2017-11-18 14:37:10 +01:00
bors
18250b0349 Auto merge of #46073 - GuillaumeGomez:rollup, r=GuillaumeGomez
Rollup of 4 pull requests

- Successful merges: #45767, #46044, #46066, #46071
- Failed merges:
2017-11-18 11:38:06 +00:00
Guillaume Gomez
85dcf2ecb6 Improve modal display and add JS events 2017-11-17 22:50:15 +01:00
Guillaume Gomez
aca1bd7d7e First step for important traits UI 2017-11-17 22:50:15 +01:00
QuietMisdreavus
cbe4ac3079 spotlight Iterator/Read/Write impls on function return types 2017-11-17 22:50:15 +01:00
Guillaume Gomez
955c054ab1 Fix primitive types not showing up 2017-11-17 22:33:02 +01:00