-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Tracking issue for #[doc(keyword = "...")] #51315
Comments
Does this actually need to be stabilized? Even |
It could be very useful for proc-macros. :) |
cc @danielhenrymantilla - do you know if this works/is useful for proc-macros? |
The fact that: #[cfg(any())]
#[doc(keyword = "foo")]
mod foo {} already compiles fine means that a proc-macro can be put instead of
Ok, I have had some enlightenment all of a sudden, and I may know what @GuillaumeGomez meant by that: it would be a way to "document" special keywords a macro may take, either as direct params of a That can be an actually very nice use case, but, in this case, using the mechanics to document a language keyword for custom proc-macros keywords is a bit hacky, and it does impact the resulting ergonomics of it:
|
Exactly! Sorry, I should have precised my words. :) |
I can't seemed to get this working. #[doc(keyword = "hello")]
/// Hello world
mod hello {} Also, what happens if there is no |
@pickfire I didn't understand your comment. The best I can recommend you is to look at how we use it in the std library, maybe that will answer your questions. :) |
I did look at how it is used in standard library. The code I show above is in |
Needless to say it's surprising considering that it works perfectly for the std right? 😆 You maybe just missed something? But normally, you just need to enable the feature and then to add |
Have you tried using |
@danielhenrymantilla Completely forgot about that one... Good catch, thanks a lot! |
Thanks for showing that. I didn't know it uses only hard-coded keywords, maybe rust should give an error when using invalid keywords? At least that won't confuse other users. |
I think it should allow all keywords. The goal being to be able to document macro specific keywords in the end... |
…=jyn514 Extend doc keyword feature by allowing any ident Part of rust-lang#51315. As suggested by `@danielhenrymantilla` in [this comment](rust-lang#51315 (comment)), this PR extends `#[doc(keyword = "...")]` to allow any ident to be used as keyword. The final goal is to allow (proc-)macro crates' owners to write documentation of the keywords they might introduce. r? `@jyn514`
…=jyn514 Extend doc keyword feature by allowing any ident Part of rust-lang#51315. As suggested by ``@danielhenrymantilla`` in [this comment](rust-lang#51315 (comment)), this PR extends `#[doc(keyword = "...")]` to allow any ident to be used as keyword. The final goal is to allow (proc-)macro crates' owners to write documentation of the keywords they might introduce. r? ``@jyn514``
=== stdout === === stderr === error[E0658]: `#[doc(keyword)]` is experimental --> /home/runner/work/glacier/glacier/ices/83512.rs:2:5 | 2 | #[doc(keyword = "match")] | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #51315 <rust-lang/rust#51315> for more information = help: add `#![feature(doc_keyword)]` to the crate attributes to enable error[E0601]: `main` function not found in crate `83512` --> /home/runner/work/glacier/glacier/ices/83512.rs:1:1 | 1 | / trait Foo { 2 | | #[doc(keyword = "match")] 3 | | fn quux() {} 4 | | } | |_^ consider adding a `main` function to `/home/runner/work/glacier/glacier/ices/83512.rs` error: `#[doc(keyword = "...")]` can only be used on modules --> /home/runner/work/glacier/glacier/ices/83512.rs:2:11 | 2 | #[doc(keyword = "match")] | ^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors Some errors have detailed explanations: E0601, E0658. For more information about an error, try `rustc --explain E0601`. ==============
Implemented in #51140.
The text was updated successfully, but these errors were encountered: