7 unstable releases (3 breaking)

0.4.1 Apr 7, 2024
0.4.0 Apr 1, 2024
0.3.0 Jan 25, 2024
0.2.0 Nov 21, 2023
0.1.2 Jun 7, 2023

#10 in #documented

Download history 60/week @ 2023-12-22 33/week @ 2023-12-29 45/week @ 2024-01-05 73/week @ 2024-01-12 76/week @ 2024-01-19 82/week @ 2024-01-26 106/week @ 2024-02-02 50/week @ 2024-02-09 136/week @ 2024-02-16 214/week @ 2024-02-23 172/week @ 2024-03-01 221/week @ 2024-03-08 315/week @ 2024-03-15 110/week @ 2024-03-22 326/week @ 2024-03-29 357/week @ 2024-04-05

1,156 downloads per month
Used in 4 crates (via documented)

MIT license

8KB
168 lines

documented

Derive macro for accessing your type's documentation at runtime

crates.io

Quick start

use documented::{Documented, DocumentedFields, Error};

/// 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.
    Note the lack of spaces in front of this line.
*/
#[doc = "Attribute-style documentation is supported too."]
#[derive(Documented, DocumentedFields)]
struct BornIn69 {
    /// Doc comments on fields (and enum variants) are supported too using
    /// the `DocumentedFields` derive macro.
    ///
    /// Frankly, delicious.
    rawr: String,

    explosive: usize,
};

// `documented::Documented` usage:
// ==================================================

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.
Note the lack of spaces in front of this line.

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

// `documented::DocumentedFields` usage:
// ==================================================

let field_doc_str = "Doc comments on fields (and enum variants) are supported too using
the `DocumentedFields` derive macro.

Frankly, delicious.";
assert_eq!(BornIn69::FIELD_DOCS, [Some(field_doc_str), None]);
assert_eq!(BornIn69::get_field_docs("rawr"), Ok(field_doc_str));
assert_eq!(
    BornIn69::get_field_docs("explosive"),
    Err(Error::NoDocComments("explosive".to_string()))
);
assert_eq!(
    BornIn69::get_field_docs("gotcha"),
    Err(Error::NoSuchField("gotcha".to_string()))
);

Dependencies

~285–730KB
~17K SLoC