6 releases (breaking)

0.9.1 Nov 4, 2024
0.9.0 Oct 29, 2024
0.8.0 Oct 21, 2024
0.7.1 Oct 16, 2024
0.1.0 Aug 23, 2024

#2343 in Procedural macros

Download history 6853/week @ 2024-11-15 6850/week @ 2024-11-22 7760/week @ 2024-11-29 8994/week @ 2024-12-06 8086/week @ 2024-12-13 4309/week @ 2024-12-20 2525/week @ 2024-12-27 4067/week @ 2025-01-03 3776/week @ 2025-01-10 3405/week @ 2025-01-17 3717/week @ 2025-01-24 3723/week @ 2025-01-31 5756/week @ 2025-02-07 5957/week @ 2025-02-14 6719/week @ 2025-02-21 4536/week @ 2025-02-28

23,521 downloads per month
Used in 6 crates (via documented)

MIT license

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