5 releases (3 breaking)

new 0.8.0 Oct 21, 2024
0.7.1 Oct 16, 2024
0.7.0 Oct 16, 2024
0.6.0 Sep 5, 2024
0.1.0 Aug 23, 2024

#2022 in Procedural macros

Download history 124/week @ 2024-08-19 2/week @ 2024-08-26 496/week @ 2024-09-02 1947/week @ 2024-09-09 1669/week @ 2024-09-16 1974/week @ 2024-09-23 2469/week @ 2024-09-30 7132/week @ 2024-10-07 8026/week @ 2024-10-14

19,645 downloads per month
Used in 4 crates (via documented)

MIT license

49KB
816 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

~0.6–1.2MB
~24K SLoC