#documentation #reflection #macro-derive #run-time #proc-macro #attributes #accessing

documented

Derive and attribute macros for accessing your type's documentation at runtime

13 releases (7 breaking)

new 0.8.0 Oct 21, 2024
0.6.0 Sep 5, 2024
0.5.0 Jun 1, 2024
0.3.0 Jan 25, 2024
0.1.2 Jun 7, 2023

#218 in Rust patterns

Download history 205/week @ 2024-07-04 142/week @ 2024-07-11 240/week @ 2024-07-18 283/week @ 2024-07-25 338/week @ 2024-08-01 714/week @ 2024-08-08 823/week @ 2024-08-15 787/week @ 2024-08-22 1461/week @ 2024-08-29 3319/week @ 2024-09-05 3009/week @ 2024-09-12 3199/week @ 2024-09-19 3153/week @ 2024-09-26 6292/week @ 2024-10-03 9460/week @ 2024-10-10 10621/week @ 2024-10-17

30,297 downloads per month
Used in 6 crates (4 directly)

MIT license

13KB
128 lines

documented

Derive and attribute macros for accessing your type's documentation at runtime

Quick start

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

/// Trying is the first step to failure.
#[derive(Documented, DocumentedFields, DocumentedVariants)]
enum AlwaysPlay {
    /// And Kb8.
    #[allow(dead_code)]
    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,
    ["And Kb8.", "But only if you are white."]
);
assert_eq!(AlwaysPlay::get_field_docs("Kb1"), Ok("And Kb8."));

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

Dependencies

~1–1.6MB
~31K SLoC