-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Rename #[doc(spotlight)]
to #[doc(notable_trait)]
#80965
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -88,26 +88,28 @@ Book][unstable-doc-cfg] and [its tracking issue][issue-doc-cfg]. | |
[unstable-doc-cfg]: ../unstable-book/language-features/doc-cfg.html | ||
[issue-doc-cfg]: https://github.com/rust-lang/rust/issues/43781 | ||
|
||
### Adding your trait to the "Important Traits" dialog | ||
|
||
Rustdoc keeps a list of a few traits that are believed to be "fundamental" to a given type when | ||
implemented on it. These traits are intended to be the primary interface for their types, and are | ||
often the only thing available to be documented on their types. For this reason, Rustdoc will track | ||
when a given type implements one of these traits and call special attention to it when a function | ||
returns one of these types. This is the "Important Traits" dialog, visible as a circle-i button next | ||
to the function, which, when clicked, shows the dialog. | ||
|
||
In the standard library, the traits that qualify for inclusion are `Iterator`, `io::Read`, and | ||
`io::Write`. However, rather than being implemented as a hard-coded list, these traits have a | ||
special marker attribute on them: `#[doc(spotlight)]`. This means that you could apply this | ||
attribute to your own trait to include it in the "Important Traits" dialog in documentation. | ||
|
||
The `#[doc(spotlight)]` attribute currently requires the `#![feature(doc_spotlight)]` feature gate. | ||
For more information, see [its chapter in the Unstable Book][unstable-spotlight] and [its tracking | ||
issue][issue-spotlight]. | ||
|
||
[unstable-spotlight]: ../unstable-book/language-features/doc-spotlight.html | ||
[issue-spotlight]: https://github.com/rust-lang/rust/issues/45040 | ||
### Adding your trait to the "Notable traits" dialog | ||
|
||
Rustdoc keeps a list of a few traits that are believed to be "fundamental" to | ||
types that implement them. These traits are intended to be the primary interface | ||
for their implementers, and are often most of the API available to be documented | ||
on their types. For this reason, Rustdoc will track when a given type implements | ||
one of these traits and call special attention to it when a function returns one | ||
of these types. This is the "Notable traits" dialog, accessible as a circled `i` | ||
button next to the function, which, when clicked, shows the dialog. | ||
|
||
In the standard library, some of the traits that are part of this list are | ||
`Iterator`, `Future`, `io::Read`, and `io::Write`. However, rather than being | ||
implemented as a hard-coded list, these traits have a special marker attribute | ||
on them: `#[doc(notable_trait)]`. This means that you can apply this attribute | ||
to your own trait to include it in the "Notable traits" dialog in documentation. | ||
|
||
The `#[doc(notable_trait)]` attribute currently requires the `#![feature(doc_notable_trait)]` | ||
feature gate. For more information, see [its chapter in the Unstable Book][unstable-notable_trait] | ||
and [its tracking issue][issue-notable_trait]. | ||
|
||
[unstable-notable_trait]: ../unstable-book/language-features/doc-notable-trait.html | ||
[issue-notable_trait]: https://github.com/rust-lang/rust/issues/45040 | ||
Comment on lines
+93
to
+112
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: is there a reason you rewrapped this? Did you change any of the text or just the wrapping? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did change the text; I changed mentions of "spotlight" to "notable trait", and I tweaked some of the wording. Sorry for the re-wrap, I know it's hard to review. I use gqap in Vim whenever I add text so that I don't end up with super long lines. Here's the Git word-diff output, which should hopefully be easier to review: diff --git a/old.md b/new.md
index 02a6f7b..92322be 100644
--- a/old.md
+++ b/new.md
@@ -1,20 +1,22 @@
### Adding your trait to the [-"Important Traits"-]{+"Notable traits"+} dialog
Rustdoc keeps a list of a few traits that are believed to be "fundamental" to
[-a given type when-]
[-implemented on it.-]{+types that implement them.+} These traits are intended to be the primary interface
for their [-types,-]{+implementers,+} and are often {+most of+} the [-only thing-]{+API+} available to be documented
on their types. For this reason, Rustdoc will track when a given type implements
one of these traits and call special attention to it when a function returns one
of these types. This is the [-"Important Traits"-]{+"Notable traits"+} dialog, [-visible-]{+accessible+} as a [-circle-i-]{+circled `i`+}
button next to the function, which, when clicked, shows the dialog.
In the standard library, {+some of+} the traits that [-qualify for inclusion-]{+are part of this list+} are
`Iterator`, {+`Future`,+} `io::Read`, and `io::Write`. However, rather than being
implemented as a hard-coded list, these traits have a special marker attribute
on them: [-`#[doc(spotlight)]`.-]{+`#[doc(notable_trait)]`.+} This means that you [-could-]{+can+} apply this attribute
to your own trait to include it in the [-"Important Traits"-]{+"Notable traits"+} dialog in documentation.
The [-`#[doc(spotlight)]`-]{+`#[doc(notable_trait)]`+} attribute currently requires the [-`#![feature(doc_spotlight)]`-]{+`#![feature(doc_notable_trait)]`+}
feature gate. For more information, see [its chapter in the Unstable [-Book][unstable-spotlight]-]{+Book][unstable-notable_trait]+}
and [its tracking [-issue][issue-spotlight].-]{+issue][issue-notable_trait].+}
[-[unstable-spotlight]: ../unstable-book/language-features/doc-spotlight.html-]
[-[issue-spotlight]:-]{+[unstable-notable_trait]: ../unstable-book/language-features/doc-notable-trait.html+}
{+[issue-notable_trait]:+} https://github.com/rust-lang/rust/issues/45040 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ok cool, I am not sure all those changes are improvements but they at least don't seem strictly worse. |
||
|
||
### Exclude certain dependencies from documentation | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# `doc_notable_trait` | ||
|
||
The tracking issue for this feature is: [#45040] | ||
|
||
The `doc_notable_trait` feature allows the use of the `#[doc(notable_trait)]` | ||
attribute, which will display the trait in a "Notable traits" dialog for | ||
functions returning types that implement the trait. For example, this attribute | ||
is applied to the `Iterator`, `Future`, `io::Read`, and `io::Write` traits in | ||
the standard library. | ||
|
||
You can do this on your own traits like so: | ||
|
||
``` | ||
#![feature(doc_notable_trait)] | ||
|
||
#[doc(notable_trait)] | ||
pub trait MyTrait {} | ||
|
||
pub struct MyStruct; | ||
impl MyTrait for MyStruct {} | ||
|
||
/// The docs for this function will have a button that displays a dialog about | ||
/// `MyStruct` implementing `MyTrait`. | ||
pub fn my_fn() -> MyStruct { MyStruct } | ||
``` | ||
|
||
This feature was originally implemented in PR [#45039]. | ||
|
||
See also its documentation in [the rustdoc book][rustdoc-book-notable_trait]. | ||
|
||
[#45040]: https://github.com/rust-lang/rust/issues/45040 | ||
[#45039]: https://github.com/rust-lang/rust/pull/45039 | ||
[rustdoc-book-notable_trait]: ../../rustdoc/unstable-features.html#adding-your-trait-to-the-notable-traits-dialog |
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// ignore-tidy-linelength | ||
// check-pass | ||
// run-rustfix | ||
|
||
#![feature(doc_notable_trait)] | ||
|
||
#[doc(notable_trait)] | ||
//~^ WARN unknown `doc` attribute `spotlight` | ||
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
trait MyTrait {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
// ignore-tidy-linelength | ||
// check-pass | ||
// run-rustfix | ||
|
||
#![feature(doc_notable_trait)] | ||
|
||
#[doc(spotlight)] | ||
//~^ WARN unknown `doc` attribute `spotlight` | ||
//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
trait MyTrait {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
warning: unknown `doc` attribute `spotlight` | ||
--> $DIR/doc-spotlight.rs:7:7 | ||
| | ||
LL | #[doc(spotlight)] | ||
| ^^^^^^^^^ help: use `notable_trait` instead | ||
| | ||
= note: `#[warn(invalid_doc_attributes)]` on by default | ||
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! | ||
= note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> | ||
= note: `doc(spotlight)` was renamed to `doc(notable_trait)` | ||
= note: `doc(spotlight)` is now a no-op | ||
|
||
warning: 1 warning emitted | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[doc(notable_trait)] //~ ERROR: `#[doc(notable_trait)]` is experimental | ||
trait SomeTrait {} | ||
|
||
fn main() {} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
error[E0658]: `#[doc(notable_trait)]` is experimental | ||
--> $DIR/feature-gate-doc_notable_trait.rs:1:1 | ||
| | ||
LL | #[doc(notable_trait)] | ||
| ^^^^^^^^^^^^^^^^^^^^^ | ||
| | ||
= note: see issue #45040 <https://github.com/rust-lang/rust/issues/45040> for more information | ||
= help: add `#![feature(doc_notable_trait)]` to the crate attributes to enable | ||
|
||
error: aborting due to previous error | ||
|
||
For more information about this error, try `rustc --explain E0658`. |
This file was deleted.
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.
Should this be a
warn
ing?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.
Nah, this seems fine.