💡 chore: add documentation to the code (#302)

This commit is contained in:
neon_arch 2023-11-18 21:23:22 +03:00
parent 38ba4bd6cb
commit c1a5b7086a
18 changed files with 154 additions and 29 deletions

View file

@ -1,8 +1,12 @@
//!
//! A module that handles the engines tab for setting page view in the `websurfx` frontend.
use maud::{html, Markup};
/// A functions that handles the html code for the cookies tab for the settings page for the search page.
///
/// # Returns
///
/// It returns the compiled html markup code for the cookies tab.
pub fn cookies() -> Markup {
html!(
div class="cookies tab"{

View file

@ -1,8 +1,16 @@
//!
//! A module that handles the engines tab for setting page view in the `websurfx` frontend.
use maud::{html, Markup};
/// A functions that handles the html code for the engines tab for the settings page for the search page.
///
/// # Arguments
///
/// * `engine_names` - It takes the list of all available engine names as an argument.
///
/// # Returns
///
/// It returns the compiled html markup code for the engines tab.
pub fn engines(engine_names: &[&String]) -> Markup {
html!(
div class="engines tab"{

View file

@ -1,10 +1,15 @@
//!
//! A module that handles the general tab for setting page view in the `websurfx` frontend.
use maud::{html, Markup};
const SAFE_SEARCH_LEVELS: [(u8, &'static str); 3] = [(0, "None"), (1, "Low"), (2, "Moderate")];
/// A constant holding the named safe search level options for the corresponding values 0, 1 and 2.
const SAFE_SEARCH_LEVELS: [(u8, &str); 3] = [(0, "None"), (1, "Low"), (2, "Moderate")];
/// A functions that handles the html code for the general tab for the settings page for the search page.
///
/// # Returns
///
/// It returns the compiled html markup code for the general tab.
pub fn general() -> Markup {
html!(
div class="general tab active"{

View file

@ -1,6 +1,7 @@
//!
//! This module provides other modules to handle the partials for the tabs for the settings page
//! view in the `websurfx` frontend.
pub mod general;
pub mod engines;
pub mod cookies;
pub mod engines;
pub mod general;
pub mod user_interface;

View file

@ -1,9 +1,21 @@
//!
//! A module that handles the user interface tab for setting page view in the `websurfx` frontend.
use crate::handler::paths::{file_path, FileType};
use maud::{html, Markup};
use std::fs::read_dir;
/// A helper function that helps in building the list of all available colorscheme/theme names
/// present in the colorschemes and themes folder respectively.
///
/// # Arguments
///
/// * `style_type` - It takes the style type of the values `theme` and `colorscheme` as an
/// argument.
///
/// # Error
///
/// Returns a list of colorscheme/theme names as a vector of tuple strings on success otherwise
/// returns a standard error message.
fn style_option_list(
style_type: &str,
) -> Result<Vec<(String, String)>, Box<dyn std::error::Error + '_>> {
@ -14,13 +26,18 @@ fn style_option_list(
style_type,
))? {
let style_name = file?.file_name().to_str().unwrap().replace(".css", "");
style_option_names.push((style_name.clone(), style_name.replace("-", " ")));
style_option_names.push((style_name.clone(), style_name.replace('-', " ")));
}
Ok(style_option_names)
}
/// A functions that handles the html code for the user interface tab for the settings page for the search page.
///
/// # Error
///
/// It returns the compiled html markup code for the user interface tab on success otherwise
/// returns a standard error message.
pub fn user_interface() -> Result<Markup, Box<dyn std::error::Error>> {
Ok(html!(
div class="user_interface tab"{