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. - Documented
Fields - Adds an associated constant
FIELD_DOCS
on your type containing the documentation of its fields, allowing you to access their documentation at runtime. - Documented
Fields Opt - The optional variant of
DocumentedFields
. - Documented
Opt - The optional variant of
Documented
. - Documented
Variants - Adds an associated function
get_variant_docs
to access the documentation on an enum variant. - Documented
Variants Opt - 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. - Documented
Fields - Derive proc-macro for
DocumentedFields
trait. - Documented
Fields Opt - Derive proc-macro for
DocumentedFieldsOpt
trait. - Documented
Opt - Derive proc-macro for
DocumentedOpt
trait. - Documented
Variants - Derive proc-macro for
DocumentedVariants
trait. - Documented
Variants Opt - Derive proc-macro for
DocumentedVariantsOpt
trait.