-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reintroduce spotlight / "important traits" feature #74370
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9845075
Revert "Remove "important traits" feature"
Manishearth 3cecd60
Revert "Remove spotlight usage"
Manishearth c90fb71
Move spotlight next to the return type
Manishearth 734afb4
Make spotlight show on hover
Manishearth ae6c7e6
Review comments for JS
Manishearth 0625b29
Add Ayu theme for spotlight
Manishearth a474b27
Remove !important on border-color and background-color
Manishearth c621a54
Don't position:relative on all pres
Manishearth File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
src/doc/unstable-book/src/language-features/doc-spotlight.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
# `doc_spotlight` | ||
|
||
The tracking issue for this feature is: [#45040] | ||
|
||
The `doc_spotlight` feature allows the use of the `spotlight` parameter to the `#[doc]` attribute, | ||
to "spotlight" a specific trait on the return values of functions. Adding a `#[doc(spotlight)]` | ||
attribute to a trait definition will make rustdoc print extra information for functions which return | ||
a type that implements that trait. This attribute is applied to the `Iterator`, `io::Read`, and | ||
`io::Write` traits in the standard library. | ||
|
||
You can do this on your own traits, like this: | ||
|
||
``` | ||
#![feature(doc_spotlight)] | ||
|
||
#[doc(spotlight)] | ||
pub trait MyTrait {} | ||
|
||
pub struct MyStruct; | ||
impl MyTrait for MyStruct {} | ||
|
||
/// The docs for this function will have an extra line about `MyStruct` implementing `MyTrait`, | ||
/// without having to write that yourself! | ||
pub fn my_fn() -> MyStruct { MyStruct } | ||
``` | ||
|
||
This feature was originally implemented in PR [#45039]. | ||
|
||
[#45040]: https://github.com/rust-lang/rust/issues/45040 | ||
[#45039]: https://github.com/rust-lang/rust/pull/45039 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This isn't a good way to find applicable impls because it doesn't take into account things like generic parameters and mutability. For example:
and
I'd imagine this will need to use a mechanism similar to how auto trait and blankets impls are found.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Given that this is reintroducing an old feature that was previously accepted in this form, can we handle this as a followup?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like, I want to ladn this so we can gather more community feedback on this feature and grow it. It's a feature that existed in this form for a while and was recently removed, my priority is getting it back in so we can improve it.