Skip to content

Commit

Permalink
Generate config docs from code
Browse files Browse the repository at this point in the history
  • Loading branch information
Nutomic committed Sep 20, 2021
1 parent 1e7f3a4 commit 5169eb8
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 7 deletions.
46 changes: 46 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ activitystreams = "0.7.0-alpha.11"
actix-rt = { version = "2.2.0", default-features = false }
serde_json = { version = "1.0.66", features = ["preserve_order"] }
clokwerk = "0.3.5"
doku = { git = "https://github.com/anixe/doku", branch = "issue/1" }

[dev-dependencies.cargo-husky]
version = "1.5.0"
Expand Down
1 change: 1 addition & 0 deletions crates/utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,4 @@ jsonwebtoken = "7.2.0"
deser-hjson = "1.0.2"
smart-default = "0.6.0"
webpage = { version = "1.3.0", default-features = false, features = ["serde"] }
doku = { git = "https://github.com/anixe/doku", branch = "issue/1" }
16 changes: 9 additions & 7 deletions crates/utils/src/settings/structs.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use doku::prelude::*;
use serde::Deserialize;
use std::net::{IpAddr, Ipv4Addr};

#[derive(Debug, Deserialize, Clone, SmartDefault)]
#[derive(Debug, Deserialize, Clone, SmartDefault, Doku)]
#[serde(default)]
pub struct Settings {
#[serde(default)]
Expand All @@ -19,6 +20,7 @@ pub struct Settings {
#[default("unset")]
pub hostname: String,
#[default(IpAddr::V4(Ipv4Addr::new(0, 0, 0, 0)))]
#[doku(as = "String")]
pub bind: IpAddr,
#[default(8536)]
pub port: u16,
Expand All @@ -34,7 +36,7 @@ pub struct Settings {
pub actor_name_max_length: usize,
}

#[derive(Debug, Deserialize, Clone, SmartDefault)]
#[derive(Debug, Deserialize, Clone, SmartDefault, Doku)]
#[serde(default)]
pub struct CaptchaConfig {
#[default(false)]
Expand All @@ -43,7 +45,7 @@ pub struct CaptchaConfig {
pub difficulty: String,
}

#[derive(Debug, Deserialize, Clone, SmartDefault)]
#[derive(Debug, Deserialize, Clone, SmartDefault, Doku)]
#[serde(default)]
pub struct DatabaseConfig {
#[default("lemmy")]
Expand All @@ -60,7 +62,7 @@ pub struct DatabaseConfig {
pub pool_size: u32,
}

#[derive(Debug, Deserialize, Clone)]
#[derive(Debug, Deserialize, Clone, Doku)]
pub struct EmailConfig {
pub smtp_server: String,
pub smtp_login: Option<String>,
Expand All @@ -69,7 +71,7 @@ pub struct EmailConfig {
pub use_tls: bool,
}

#[derive(Debug, Deserialize, Clone, SmartDefault)]
#[derive(Debug, Deserialize, Clone, SmartDefault, Doku)]
#[serde(default)]
pub struct FederationConfig {
#[default(false)]
Expand All @@ -82,7 +84,7 @@ pub struct FederationConfig {
pub strict_allowlist: bool,
}

#[derive(Debug, Deserialize, Clone, SmartDefault)]
#[derive(Debug, Deserialize, Clone, SmartDefault, Doku)]
#[serde(default)]
pub struct RateLimitConfig {
#[default(180)]
Expand All @@ -103,7 +105,7 @@ pub struct RateLimitConfig {
pub image_per_second: i32,
}

#[derive(Debug, Deserialize, Clone, SmartDefault)]
#[derive(Debug, Deserialize, Clone, SmartDefault, Doku)]
pub struct SetupConfig {
pub admin_username: String,
pub admin_password: String,
Expand Down
1 change: 1 addition & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ embed_migrations!();

#[actix_web::main]
async fn main() -> Result<(), LemmyError> {
println!("{}", doku::to_json_val(&Settings::default()));
env_logger::init();
let settings = Settings::get();

Expand Down

0 comments on commit 5169eb8

Please sign in to comment.