How does tokio get the cool 'Supported on feature="something" only' annotation in Docs.rs?
I thought this was really useful. Is there a way for me to add this kind of annotation to a specific function in a crate?
How does tokio get the cool 'Supported on feature="something" only' annotation in Docs.rs?
I thought this was really useful. Is there a way for me to add this kind of annotation to a specific function in a crate?
It's a nightly only feature.
Cool thanks!
Is there a way to put it in a crate such that it only enables it on Nightly and then just ignores it on stable?
When I put the #![feature(doc_cfg)]
in the crate it will not compile on stable ( which makes sense ). Can I make it conditional?
You can use #[cfg_attr(condition, attr)]
to set them conditionally, and you can set docs.rs-only features: https://docs.rs/about/metadata
If you search for docsrs in the Tokio codebase, both the rs source and Cargo.toml
, you will see how Tokio did it.
Thanks, I found it now. Initially I was confused because I was looking for annotations on the functions in the source on docs.rs, but I didn't find anything.
It's inside the cfg_*
macros that Tokio use.
This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.