-
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
Revamp rustdoc docs about documentation using cfg
#76855
Conversation
|
Hmm, you're right that |
Traditionally, we keep a very clean separation here; we only talk about stable things in stable docs, and unstable things in unstable docs. However, I think the rustdoc team should document its tool the way it wants to, and this is an odd case. I'm fine with this either way. |
Ok, I moved |
2787f9d
to
bc12abe
Compare
ping @ollie27 - does the new documentation look good to you? |
@@ -100,28 +100,16 @@ Note: Because of how `macro_rules` macros are scoped in Rust, the intra-doc link | |||
These features operate by extending the `#[doc]` attribute, and thus can be caught by the compiler | |||
and enabled with a `#![feature(...)]` attribute in your crate. | |||
|
|||
### Documenting platform-/feature-specific information | |||
### `#[doc(cfg)]`: Recording what platforms or features are required for code to be present |
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.
I'm not super happy with this wording, but I'm not sure how better to say it.
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.
Conditional documentation?
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.
No, the documentation is usually unconditional, e.g. cfg(any(doc, unix))
, but the code is only present when the cfg
is set.
r? @ollie27 |
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.
Looks good to me. r=me with that one typo fixed and the commits squashed.
a3352dc
to
3c7433d
Compare
- Move `cfg(doc)` out of `unstable-features`. It's not unstable. - Remove outdated reference to `everybody_loops`. - Improve wording in various places - Give an example of code this allows (and does not allow) - Link to `cfg(doc)` in `doc(cfg)` documentation. Since one is stable and the other is not, don't combine them. - Cleanup wording for `doc(cfg)` - Incorporate changes from rust-lang#76849 - Mention that `doc(cfg)` is also for features
3c7433d
to
dc5a000
Compare
@bors r=ollie27 rollup |
📌 Commit dc5a000 has been approved by |
Rollup of 13 pull requests Successful merges: - rust-lang#76388 (Add a note about the panic behavior of math operations on time objects) - rust-lang#76855 (Revamp rustdoc docs about documentation using `cfg`) - rust-lang#76995 (Reduce boilerplate with the matches! macro) - rust-lang#77228 (Add missing examples for MaybeUninit) - rust-lang#77528 (Avoid unchecked casts in net parser) - rust-lang#77534 (Disallow overriding forbid in same scope) - rust-lang#77555 (Allow anyone to set regression labels) - rust-lang#77558 (Rename bootstrap/defaults/{config.toml.PROFILE => config.PROFILE.toml}) - rust-lang#77559 (Fix rustdoc warnings about invalid Rust syntax) - rust-lang#77560 (Fix LitKind's byte buffer to use refcounted slice) - rust-lang#77573 (Hint doc use convert::identity relative link) - rust-lang#77587 (Fix span for unicode escape suggestion.) - rust-lang#77591 (Record `expansion_that_defined` into crate metadata) Failed merges: r? `@ghost`
cfg(doc)
out ofunstable-features
. It's not unstable.everybody_loops
.cfg(doc)
indoc(cfg)
documentation. Since one is stableand the other is not, don't combine them.
doc(cfg)
doc(cfg)
is also for featuresAddresses #76849 (comment).
Obsoletes #76849 (I made sure to fix the weird dashes too).
r? @steveklabnik