Documented

Derive Macro Documented 

Source
#[derive(Documented)]
{
    // Attributes available to this derive:
    #[documented]
}
Expand description

Derive proc-macro for Documented trait.

§Example

use documented::Documented;

/// Nice.
/// Multiple single-line doc comments are supported.
///
/** Multi-line doc comments are supported too.
    Each line of the multi-line block is individually trimmed by default.
    Note the lack of spaces in front of this line.
*/
#[doc = "Attribute-style documentation is supported too."]
#[derive(Documented)]
struct BornIn69;

let doc_str = "Nice.
Multiple single-line doc comments are supported.

Multi-line doc comments are supported too.
Each line of the multi-line block is individually trimmed by default.
Note the lack of spaces in front of this line.

Attribute-style documentation is supported too.";
assert_eq!(BornIn69::DOCS, doc_str);

§Configuration

With the customise feature enabled, you can customise this macro’s behaviour using the #[documented(...)] attribute.

Currently, you can:

§1. set a default value when doc comments are absent like so:

#[derive(Documented)]
#[documented(default = "The answer is fries.")]
struct WhosTurnIsIt;

assert_eq!(WhosTurnIsIt::DOCS, "The answer is fries.");

This option is primarily designed for DocumentedFields and DocumentedVariants, so it’s probably not very useful here. But it could conceivably come in handy in some niche meta-programming contexts.

§2. disable line-trimming like so:

///     Terrible.
#[derive(Documented)]
#[documented(trim = false)]
struct Frankly;

assert_eq!(Frankly::DOCS, "     Terrible.");

If there are other configuration options you wish to have, please submit an issue or a PR.