Crates.io | config-docs |
lib.rs | config-docs |
version | 0.1.0 |
source | src |
created_at | 2024-11-25 17:24:09.552419 |
updated_at | 2024-11-25 17:24:09.552419 |
description | A trait and derive macro to generate documentation for your structs |
homepage | |
repository | |
max_upload_size | |
id | 1460513 |
size | 7,021 |
This crate adds a trait with a derive macro to create a documentation for your struct in code. This is useful for things like configuration objects that should be documented in your app.
This project came into place for a small project I'm working on and is in no means perfect. If you have any suggestions, please consider contributing on Github
use config_docs::ConfigDocs;
#[derive(ConfigDocs)]
struct Config {
/// Holds the colors for your app
colors: ColorConfig,
/// Holds the keybinds for your app
keybinds: KeybindConfig,
}
#[derive(ConfigDocs)]
struct ColorConfig {
/// The foreground color for your app as a hex value
fg: String,
/// The background color for your app as a hex value
bg: String,
}
#[derive(ConfigDocs)]
struct KeybindConfig {
/// Show the help inside your app
help: String,
/// Quit your app
quit: String
}
assert_eq!(Config::config_docs(), &[
("colors", "Holds the colors for your app"),
("fg", "The foreground color for your app as a hex value"),
("bg", "The background color for your app as a hex value"),
("keybinds", "Holds the keybinds for your app"),
("help", "Show the help inside your app"),
("quit", "Quit your app")
])