https://github.com/cyqsimon/documented
Macros for accessing your type's documentation at runtime.
https://github.com/cyqsimon/documented
derive-macro documentation rust
Last synced: about 1 year ago
JSON representation
Macros for accessing your type's documentation at runtime.
- Host: GitHub
- URL: https://github.com/cyqsimon/documented
- Owner: cyqsimon
- License: mit
- Created: 2023-06-05T14:25:13.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2024-10-29T05:49:22.000Z (over 1 year ago)
- Last Synced: 2024-10-30T10:20:43.465Z (over 1 year ago)
- Topics: derive-macro, documentation, rust
- Language: Rust
- Homepage:
- Size: 242 KB
- Stars: 26
- Watchers: 1
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# documented
Derive and attribute macros for accessing your type's documentation at runtime
- [crates.io](https://crates.io/crates/documented)
- [docs.rs](https://docs.rs/documented/latest/documented/)
## Quick start
```rust
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."
);
```