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

documented

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

14 releases (8 breaking)

0.9.1 Nov 4, 2024
0.7.1 Oct 16, 2024
0.5.0 Jun 1, 2024
0.3.0 Jan 25, 2024
0.1.2 Jun 7, 2023

#192 in Rust patterns

Download history 821/week @ 2024-08-21 1404/week @ 2024-08-28 3055/week @ 2024-09-04 3068/week @ 2024-09-11 2929/week @ 2024-09-18 3315/week @ 2024-09-25 5141/week @ 2024-10-02 8854/week @ 2024-10-09 10988/week @ 2024-10-16 9054/week @ 2024-10-23 9074/week @ 2024-10-30 5702/week @ 2024-11-06 7539/week @ 2024-11-13 8506/week @ 2024-11-20 7053/week @ 2024-11-27 7539/week @ 2024-12-04

32,114 downloads per month
Used in 6 crates (4 directly)

MIT license

15KB
130 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