https://github.com/anixe/doku
fn(Code) -> Docs
https://github.com/anixe/doku
documentation documentation-generator json rust rust-lang serialization
Last synced: 10 months ago
JSON representation
fn(Code) -> Docs
- Host: GitHub
- URL: https://github.com/anixe/doku
- Owner: anixe
- License: mit
- Created: 2021-07-08T08:04:34.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-06-09T08:13:25.000Z (about 3 years ago)
- Last Synced: 2025-07-29T04:13:40.153Z (11 months ago)
- Topics: documentation, documentation-generator, json, rust, rust-lang, serialization
- Language: Rust
- Homepage:
- Size: 372 KB
- Stars: 85
- Watchers: 5
- Forks: 4
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Doku [![crates-badge]][crates-link] [![docs-badge]][docs-link]
[crates-badge]: https://img.shields.io/crates/v/doku.svg
[crates-link]: https://crates.io/crates/doku
[docs-badge]: https://img.shields.io/badge/docs.rs-latest-informational
[docs-link]: https://docs.rs/doku
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
```toml
[dependencies]
doku = "0.21"
```
```rust
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::());
println!("```");
println!();
println!("```toml");
println!("{}", doku::to_toml::());
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](./doku/examples); there's also a
documentation at .
## 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:
- [the JSON pretty-printer](./doku/src/printers/json.rs),
- [the TOML pretty-printer](./doku/src/printers/toml.rs),
- [the data model](./doku/src/objects.rs),
- [the derive macro](./doku-derive/src/lib.rs).
There are also integration tests at [./doku/tests](./doku/tests).
## License
Licensed under the MIT license.