Skip to content
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

Generate documentation for static methods #215

Closed
tuguzT opened this issue Nov 8, 2022 · 3 comments
Closed

Generate documentation for static methods #215

tuguzT opened this issue Nov 8, 2022 · 3 comments

Comments

@tuguzT
Copy link

tuguzT commented Nov 8, 2022

I think it would be nice to generate documentation for impl block and for static methods which are generated by Constructor, IsVariant and Unwrap derive macros.

For example, something like this:

#[derive(IsVariant)]
enum Maybe<T> {
    Just(T),
    Nothing
}

Generates this:

/// Check if [`Maybe`] is a value of some variant.
impl<T> Maybe<T> {
    /// Returns `true` if [`Maybe`] is a [`Just`](Maybe::Just) value.
    pub fn is_just(&self) -> bool {
        match self {Self::Just(..) => true, _ => false}
    }
    /// Returns `true` if [`Maybe`] is a [`Nothing`](Maybe::Nothing) value.
    pub fn is_nothing(&self) -> bool {
        match self {Self::Nothing => true, _ => false}
    }
}

This will be helpful for crates which use documentation lints, such as #![warn(missing_docs)].

@phip1611
Copy link
Contributor

phip1611 commented Nov 8, 2022

This will be helpful for crates which use documentation lints, such as

What if the derived code uses #[automatically_derived]? I thought that linters would then skip such code

@tuguzT
Copy link
Author

tuguzT commented Nov 8, 2022

Never heard about this attribute before 🤔.

If it works not only for trait implementations, this can be a solution to the problem.

@tuguzT tuguzT closed this as completed Oct 12, 2023
@tyranron
Copy link
Collaborator

Just to note, the #[automatically_derived] was added here: #203

Documentation to some such methods was added here: #179

So this issue shouldn't appear on latest master and 1.0.0-beta.* releases.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants