JelteF/derive_more

Generate documentation for static methods

Closed this issue · 3 comments

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)].

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

Never heard about this attribute before 🤔.

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

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.