documented_macros

Derive Macro Documented

source
#[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 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.