Crate documented

Source
Expand description

§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."
);

Enums§

Error
Errors of documented.

Traits§

Documented
Adds an associated constant DOCS on your type containing its documentation, allowing you to access its documentation at runtime.
DocumentedFields
Adds an associated constant FIELD_DOCS on your type containing the documentation of its fields, allowing you to access their documentation at runtime.
DocumentedFieldsOpt
The optional variant of DocumentedFields.
DocumentedOpt
The optional variant of Documented.
DocumentedVariants
Adds an associated function get_variant_docs to access the documentation on an enum variant.
DocumentedVariantsOpt
The optional variant of DocumentedVariants.

Attribute Macros§

docs_const
Macro to extract the documentation on any item that accepts doc comments and store it in a const variable.

Derive Macros§

Documented
Derive proc-macro for Documented trait.
DocumentedFields
Derive proc-macro for DocumentedFields trait.
DocumentedFieldsOpt
Derive proc-macro for DocumentedFieldsOpt trait.
DocumentedOpt
Derive proc-macro for DocumentedOpt trait.
DocumentedVariants
Derive proc-macro for DocumentedVariants trait.
DocumentedVariantsOpt
Derive proc-macro for DocumentedVariantsOpt trait.