Generate doc string from error string or vice versa
Sometimes an error enum's display can also be used as its documentation.
#[derive(Debug, thiserror::Error)]
enum Foo {
/// A Bar Error Occurred
#[error("a bar error occurred")]
Bar,
/// Something happened with baz
#[error("something happened with baz")]
Baz,
}
It would be useful to use the same string for documentation generation with something to tell thiserror to also use that as a doc string. Something like the following:
#[error("Something happened with baz", doc = true)]
Baz,
could expand to:
/// Something happened with baz
#[error("Something happened with baz")]
Baz,
Or something like the following:
/// Something happened with baz
#[error(doc = true)]
Baz,
could expand to:
/// Something happened with baz
#[error("Something happened with baz")]
Baz,
Is this something that other people think would be useful? Would this make sense to implement? The ui would likely need to be fleshed out a little bit.
I would prefer not to support this in this crate. But there are other crates for deriving Display based on a doc comment.
(I would've personally closed this as "not planned" instead of "completed")
Why not support this tho? Adding doc comment in thiserror_impl::derive_error seems trivial and would make cargo doc documentation more explicit. I don't think this feature would require a lot of maintenance from you, as a maintainer.