Skip to content

Add support for #[doc(since="version")] attribute #74182

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

Open
dodomorandi opened this issue Jul 9, 2020 · 10 comments
Open

Add support for #[doc(since="version")] attribute #74182

dodomorandi opened this issue Jul 9, 2020 · 10 comments
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.

Comments

@dodomorandi
Copy link

To the present day, the internal crates like core and std can annotate things with #[stable(since="version")]. This is extremely useful for users, especially because rustdoc is able to write this information in the rendered documentation.

Unfortunately, this kind of feature is not available for normal crates. Take, for instance, tokio::runtime::Handle::current: this function is available since version 0.2.8 of the tokio crate (not sure about 0.2.7, that's not the point), but this information is not available at a first glimpse.

IMHO, adding the possibility of annotating functions, structs and traits (and maybe something I missed) with #[doc(since="version")] would give more doc power to crates' authors. Moreover, it should be possible to leverage the current implementation of stable(since="version") in order to introduce the feature without reinventing the wheel.

@jonas-schievink jonas-schievink added C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. labels Jul 9, 2020
@GuillaumeGomez
Copy link
Member

We had been asked about it in the past too but it got rejected at that time. However I am very favorable to this add.

@jyn514
Copy link
Member

jyn514 commented Dec 15, 2020

This is a duplicate of #74182 (created earlier, but with less discussion).

@jyn514 jyn514 closed this as completed Dec 15, 2020
@dodomorandi
Copy link
Author

@jyn514 Sorry, I think you posted the wrong duplicated issue, because it is just this one 😄

@jyn514
Copy link
Member

jyn514 commented Dec 15, 2020

Oh oops, thanks! I meant to link to #79663.

@pietroalbini
Copy link
Member

I don't think this is the same feature as #79663: that issue is about having a way to mark items as unstable, while this is just to add a "since 1.2.3" near the function signature.

@jyn514
Copy link
Member

jyn514 commented Dec 17, 2020

@pietroalbini staged_api does both those things. I guess it depends whether you count #79663 as a request to stabilize all of staged_api or just deprecations.

@pietroalbini
Copy link
Member

I think it's better to keep this and staged_api separate.

Stabilizing #[unstable(...)] sounds a lot more complex than this issue (would that mean #![feature()] for crates too? which channels can use crate unstable features? how does that interact with api stability?), while this issue just proposes adding a way to annotate functions on rustdoc with the version number they were introduced in.

@jyn514 jyn514 reopened this Dec 17, 2020
@Cldfire
Copy link
Contributor

Cldfire commented Jan 6, 2021

It could be neat for this attribute to support linking to the changelog for the version specified (inspired by the Rust Search Extension):

Image

Screen Shot 2021-01-06 at 3 00 37 PM

This would probably require a way to globally specify a root changelog URL for a given crate.

@archer-321
Copy link

In addition to being useful as a hint in the rendered API documentation, this annotation could be helpful for tools in automatically detecting minimal dependency versions. Even if not all of a library is annotated, tools would know they can start testing with "at least version X".

Testing whether a using crate still compiles with some version obviously doesn't catch all kinds of breaking changes in an API, so unless the entire API is annotated with this attribute, automatic minimal dependency version detection would never be reliable. However, this attribute still allows for an "educated guess" in those cases.

@jyn514
Copy link
Member

jyn514 commented Mar 29, 2023

Major new features like this should have an RFC IMO.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-request Category: A feature request, i.e: not implemented / a PR. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

7 participants