11 releases (6 breaking)

0.21.1 Jun 9, 2023
0.20.0 Nov 7, 2022
0.12.0 Jul 31, 2022
0.11.0 Dec 15, 2021
0.9.0 Jul 22, 2021

#156 in Rust patterns

Download history 1104/week @ 2024-03-13 771/week @ 2024-03-20 638/week @ 2024-03-27 995/week @ 2024-04-03 534/week @ 2024-04-10 840/week @ 2024-04-17 746/week @ 2024-04-24 1048/week @ 2024-05-01 781/week @ 2024-05-08 885/week @ 2024-05-15 991/week @ 2024-05-22 1353/week @ 2024-05-29 1122/week @ 2024-06-05 830/week @ 2024-06-12 918/week @ 2024-06-19 958/week @ 2024-06-26

4,072 downloads per month
Used in 14 crates (3 directly)

MIT license

220KB
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.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/.

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.9–3MB
~68K SLoC