Crates.io | doku |
lib.rs | doku |
version | 0.21.1 |
source | src |
created_at | 2021-07-22 12:38:24.885967 |
updated_at | 2023-06-09 08:13:53.670416 |
description | A framework for documenting Rust data structures |
homepage | |
repository | https://github.com/anixe/doku |
max_upload_size | |
id | 425885 |
size | 362,594 |
Doku is a framework for documenting Rust data structures - it allows to generate aesthetic, human-friendly descriptions of configuration types, requests / responses, and so on.
Say goodbye to stale, hand-written documentation - with Doku, code is the documentation!
[dependencies]
doku = "0.21"
use doku::Document;
use serde::Deserialize;
#[derive(Deserialize, Document)]
struct Config {
/// Database's engine
db_engine: DbEngine,
/// Database's host
#[doku(example = "localhost")]
db_host: String,
/// Database's port
#[doku(example = "5432")]
db_port: usize,
}
#[derive(Deserialize, Document)]
enum DbEngine {
#[serde(rename = "pgsql")]
PostgreSQL,
#[serde(rename = "mysql")]
MySQL,
}
fn main() {
println!("```json");
println!("{}", doku::to_json::<Config>());
println!("```");
println!();
println!("```toml");
println!("{}", doku::to_toml::<Config>());
println!("```");
}
{
// Database's engine
"db_engine": "pgsql" | "mysql",
// Database's host
"db_host": "localhost",
// Database's port
"db_port": 5432
}
# Database's engine
db_engine = "pgsql" | "mysql"
# Database's host
db_host = "localhost"
# Database's port
db_port = 5432
You'll find more examples in ./doku/examples; there's also a documentation at https://docs.rs/doku/.
Found a bug, have an idea? Please let us know on GitHub - patches are welcome, too!
If you want to try hacking on Doku, the entry points are:
There are also integration tests at ./doku/tests.
Licensed under the MIT license.