diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2020-07-16 11:18:55 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-07-16 11:18:55 -0700 |
| commit | fc098170ce8934e1887ec7978c5b8d198c140a2a (patch) | |
| tree | 46e4cdabeb12a1cb268e8b19c03d224c8777960b /src/test/rustdoc | |
| parent | 61fccf05f90b1a99a62ccd811152c4eeec57fba3 (diff) | |
| parent | c621a54eeb71248927dff8ac0c76f279cf756f28 (diff) | |
| download | rust-fc098170ce8934e1887ec7978c5b8d198c140a2a.tar.gz rust-fc098170ce8934e1887ec7978c5b8d198c140a2a.zip | |
Rollup merge of #74370 - Manishearth:re-spotlight, r=GuillaumeGomez
Reintroduce spotlight / "important traits" feature
(Reopened version of https://github.com/rust-lang/rust/pull/74111 because Github is broken, see discussion there)
Fixes https://github.com/rust-lang/rust/issues/73785
This PR reintroduces the "spotlight" ("important traits") feature.
A couple changes have been made:
As there were concerns about its visibility, it has been moved to be next to the return type, as opposed to being on the side.
It also no longer produces a modal, it shows the traits on hover, and it can be clicked on to pin the hover bubble.


It also works fine on mobile:

Diffstat (limited to 'src/test/rustdoc')
| -rw-r--r-- | src/test/rustdoc/doc-spotlight.rs | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/src/test/rustdoc/doc-spotlight.rs b/src/test/rustdoc/doc-spotlight.rs new file mode 100644 index 00000000000..ddd46c3c215 --- /dev/null +++ b/src/test/rustdoc/doc-spotlight.rs @@ -0,0 +1,36 @@ +#![feature(doc_spotlight)] + +pub struct Wrapper<T> { + inner: T, +} + +impl<T: SomeTrait> SomeTrait for Wrapper<T> {} + +#[doc(spotlight)] +pub trait SomeTrait { + // @has doc_spotlight/trait.SomeTrait.html + // @has - '//code[@class="content"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>' + fn wrap_me(self) -> Wrapper<Self> where Self: Sized { + Wrapper { + inner: self, + } + } +} + +pub struct SomeStruct; +impl SomeTrait for SomeStruct {} + +impl SomeStruct { + // @has doc_spotlight/struct.SomeStruct.html + // @has - '//code[@class="content"]' 'impl SomeTrait for SomeStruct' + // @has - '//code[@class="content"]' 'impl<T: SomeTrait> SomeTrait for Wrapper<T>' + pub fn new() -> SomeStruct { + SomeStruct + } +} + +// @has doc_spotlight/fn.bare_fn.html +// @has - '//code[@class="content"]' 'impl SomeTrait for SomeStruct' +pub fn bare_fn() -> SomeStruct { + SomeStruct +} |
