#documentation #reflection #proc-macro

documented

Traits and derive macros for accessing your type's documentation at runtime

9 releases (4 breaking)

0.5.0 Jun 1, 2024
0.4.3 May 27, 2024
0.4.1 Apr 7, 2024
0.3.0 Jan 25, 2024
0.1.2 Jun 7, 2023

#317 in Rust patterns

Download history 247/week @ 2024-03-27 391/week @ 2024-04-03 258/week @ 2024-04-10 133/week @ 2024-04-17 265/week @ 2024-04-24 151/week @ 2024-05-01 127/week @ 2024-05-08 233/week @ 2024-05-15 483/week @ 2024-05-22 659/week @ 2024-05-29 379/week @ 2024-06-05 231/week @ 2024-06-12 350/week @ 2024-06-19 221/week @ 2024-06-26 228/week @ 2024-07-03 116/week @ 2024-07-10

943 downloads per month
Used in 4 crates (3 directly)

MIT license

8KB
69 lines

documented

Traits and derive macros for accessing your type's documentation at runtime

Quick start

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

/// Trying is the first step to failure.
#[derive(Documented, DocumentedFields, DocumentedVariants)]
enum AlwaysPlay {
    Kb1,
    /// But only if you are white.
    F6,
}

// Documented
assert_eq!(AlwaysPlay::DOCS, "Trying is the first step to failure.");

// DocumentedFields
assert_eq!(
    AlwaysPlay::FIELD_DOCS,
    [None, Some("But only if you are white.")]
);
assert_eq!(
    AlwaysPlay::get_field_docs("F6"),
    Ok("But only if you are white.")
);

// DocumentedVariants
assert_eq!(
    AlwaysPlay::F6.get_variant_docs(),
    Ok("But only if you are white.")
);

Dependencies

~0.6–1.1MB
~24K SLoC