9 releases (5 breaking)

0.20.0 Nov 7, 2022
0.12.0 Jul 31, 2022
0.11.0 Dec 15, 2021
0.10.2 Nov 3, 2021
0.2.0-alpha.2 Oct 21, 2022

#162 in Data structures

Download history 143/week @ 2022-12-02 173/week @ 2022-12-09 189/week @ 2022-12-16 198/week @ 2022-12-23 172/week @ 2022-12-30 134/week @ 2023-01-06 123/week @ 2023-01-13 198/week @ 2023-01-20 265/week @ 2023-01-27 255/week @ 2023-02-03 161/week @ 2023-02-10 300/week @ 2023-02-17 585/week @ 2023-02-24 91/week @ 2023-03-03 88/week @ 2023-03-10 113/week @ 2023-03-17

930 downloads per month
Used in 13 crates (2 directly)

MIT license

215KB
5K SLoC

Doku   crates-badge docs-badge

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!

Example

[dependencies]
doku = "0.20"
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/.

Contributing

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.

License

Licensed under the MIT license.

Dependencies

~1.3–2.5MB
~59K SLoC