From 2d121ef5c864c1b3bf547a9b55e87dc273408b62 Mon Sep 17 00:00:00 2001 From: MedzikUser Date: Tue, 21 Jun 2022 12:51:22 +0200 Subject: [PATCH] doc: set doc `html_root_url` and small update --- core/src/lib.rs | 4 +++- core/src/main.rs | 3 +-- database/src/lib.rs | 2 ++ server/src/lib.rs | 2 ++ types/src/auth/login.rs | 1 - types/src/config/mod.rs | 4 ++-- types/src/config/types.rs | 5 +++-- types/src/database/user.rs | 12 ++++++------ types/src/errors/auth.rs | 1 - types/src/errors/database.rs | 1 - types/src/errors/server.rs | 8 ++++---- types/src/lib.rs | 2 ++ 12 files changed, 25 insertions(+), 20 deletions(-) diff --git a/core/src/lib.rs b/core/src/lib.rs index 24c4d1d..7b7e4a2 100644 --- a/core/src/lib.rs +++ b/core/src/lib.rs @@ -38,4 +38,6 @@ //! //! ## Configure //! -//! Go to [config](../homedisk_types/config/index.html) module +//! Go to [config](homedisk_types::config) module + +#![doc(html_root_url = "https://homedisk-doc.medzik.xyz")] diff --git a/core/src/main.rs b/core/src/main.rs index 7ea100d..a0e11bf 100644 --- a/core/src/main.rs +++ b/core/src/main.rs @@ -38,7 +38,6 @@ async fn main() { .expect("start http server"); } -/// Init logger fn init_logger() -> anyhow::Result<()> { use std::fs::File; @@ -55,7 +54,7 @@ fn init_logger() -> anyhow::Result<()> { WriteLogger::new( LevelFilter::Info, Config::default(), - File::create("logs.log").expect("create logs file"), + File::create("logs.log")?, ), ])?; diff --git a/database/src/lib.rs b/database/src/lib.rs index deab2c0..63621ad 100644 --- a/database/src/lib.rs +++ b/database/src/lib.rs @@ -1,3 +1,5 @@ +#![doc(html_root_url = "https://homedisk-doc.medzik.xyz")] + mod sqlite; pub use homedisk_types::database::User; diff --git a/server/src/lib.rs b/server/src/lib.rs index e876dc2..9efe447 100644 --- a/server/src/lib.rs +++ b/server/src/lib.rs @@ -1,3 +1,5 @@ +#![doc(html_root_url = "https://homedisk-doc.medzik.xyz")] + mod auth; mod error; mod fs; diff --git a/types/src/auth/login.rs b/types/src/auth/login.rs index c18776a..612d2ac 100644 --- a/types/src/auth/login.rs +++ b/types/src/auth/login.rs @@ -15,7 +15,6 @@ pub struct Request { /// HTTP `/auth/login` Response #[derive(Debug, Serialize, Deserialize, Clone, Zeroize, ZeroizeOnDrop)] pub enum Response { - #[allow(missing_docs)] LoggedIn { /// User access token access_token: String, diff --git a/types/src/config/mod.rs b/types/src/config/mod.rs index d05a373..164a40d 100644 --- a/types/src/config/mod.rs +++ b/types/src/config/mod.rs @@ -2,7 +2,7 @@ //! //! Path to a config file is `config.toml` in the system configuration directory (`~/.config/homedisk/config.toml`). //! -//! Example config: +//! ## Example config //! //! ```toml //! [http] @@ -18,7 +18,7 @@ //! path = "/home/homedisk" # # Directory where user files will be stored //! ``` //! -//! ## External docs +//! ### External docs //! - [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) mod types; diff --git a/types/src/config/types.rs b/types/src/config/types.rs index 483f85e..ec3caf1 100644 --- a/types/src/config/types.rs +++ b/types/src/config/types.rs @@ -24,7 +24,7 @@ pub struct ConfigHTTP { pub host: String, /// Port HTTP Port pub port: u16, - /// CORS Domains (e.g ["site1.example.com", "site2.example.com"]) + /// [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) Domains (e.g ["site1.example.com", "site2.example.com"]) pub cors: Vec, } @@ -46,7 +46,8 @@ pub struct ConfigStorage { #[cfg(feature = "config")] impl Config { - /// Parse configuration file + /// Parse configuration file. + /// /// ```no_run /// use homedisk_types::config::Config; /// diff --git a/types/src/database/user.rs b/types/src/database/user.rs index 04fa5d4..523f98e 100644 --- a/types/src/database/user.rs +++ b/types/src/database/user.rs @@ -13,10 +13,11 @@ pub struct User { } impl User { - /// **Note this doesn't create a new user in the database!** + /// The function create a unique user UUID and create SHA-512 hash from salted user password + /// and returns the [User] type. + /// + /// **Note: This doesn't create a user in the database!** /// - /// This function creates a unique UUID for a user and creates a password hash using SHA-512 - /// and returns in the User type /// ``` /// use homedisk_types::database::User; /// @@ -50,9 +51,8 @@ impl User { } } - /// User directory - /// function returns the directory where the user file is located - /// e.g. + /// The function returns the directory where the user file is located. + /// /// ``` /// use homedisk_types::database::User; /// diff --git a/types/src/errors/auth.rs b/types/src/errors/auth.rs index 744e9b1..3b2df0c 100644 --- a/types/src/errors/auth.rs +++ b/types/src/errors/auth.rs @@ -3,7 +3,6 @@ use serde::{Deserialize, Serialize}; /// HTTP `/auth/*` Errors #[derive(Debug, Clone, Serialize, Deserialize, thiserror::Error)] pub enum Error { - /// User not found! /// Username or Password incorrect. #[error("user not found")] UserNotFound, diff --git a/types/src/errors/database.rs b/types/src/errors/database.rs index 29b13e9..e502419 100644 --- a/types/src/errors/database.rs +++ b/types/src/errors/database.rs @@ -1,7 +1,6 @@ /// Database Error #[derive(Debug, thiserror::Error)] pub enum Error { - /// User not found! /// Username or Password incorrect. #[error("user not found")] UserNotFound, diff --git a/types/src/errors/server.rs b/types/src/errors/server.rs index bc9bd7a..e9d18e4 100644 --- a/types/src/errors/server.rs +++ b/types/src/errors/server.rs @@ -18,16 +18,16 @@ pub enum Error { /// Missing Json in Content-Type Header. #[error("missing json content type")] MissingJsonContentType, - /// Failed to deserialize json. + /// Failed to deserialize JSON. #[error("error deserialize json")] JsonDataError, - /// Syntax error in JSON + /// Syntax error in JSON. #[error("json syntax error")] JsonSyntaxError, - /// Failed to extract the Request body + /// Failed to extract the Request body. #[error("failed to extract the request body")] BytesRejection, - /// Other error + /// Other error. #[error("unknown error - {0}")] Other(String), } diff --git a/types/src/lib.rs b/types/src/lib.rs index c30b5c0..d0a1ea4 100644 --- a/types/src/lib.rs +++ b/types/src/lib.rs @@ -1,3 +1,5 @@ +#![doc(html_root_url = "https://homedisk-doc.medzik.xyz")] + pub mod auth; pub mod config; #[cfg(feature = "database")]