diff --git a/Cargo.toml b/Cargo.toml index 5d784bd..6e26114 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,3 +28,10 @@ version = "1.0.152" [dependencies.userstyles] git = "https://git.bauke.xyz/Bauke/userstyles" rev = "8aa9ad3" + +[lints.clippy] +missing_docs_in_private_items = "warn" + +[lints.rust] +missing_docs = "warn" +unsafe_code = "forbid" diff --git a/source/copy.rs b/source/copy.rs index 76d5bd7..c6b18e6 100644 --- a/source/copy.rs +++ b/source/copy.rs @@ -1,10 +1,14 @@ +//! The logic for files that need be directly copied over. + use std::{fs, path::Path, process::Command}; use color_eyre::Result; +/// Struct to contain functionality for copying. pub struct Copy; impl Copy { + /// Copy all the files to their respective destinations. pub fn write( build_dir: &Path, public_dir: &Path, diff --git a/source/main.rs b/source/main.rs index 3d3c943..08589c7 100644 --- a/source/main.rs +++ b/source/main.rs @@ -1,3 +1,7 @@ +//! # Bauke 🦖 XYZ +//! +//! > **Bauke's website.** + use std::{ fs, path::{Path, PathBuf}, @@ -27,6 +31,7 @@ fn main() -> Result<()> { Ok(()) } +/// Write the userstyle files to the right place in the build directory. fn build_userstyles(build_dir: &Path) -> Result<()> { for target in userstyles::ALL_USERSTYLES { let style = userstyles::Userstyle::load(target)?; diff --git a/source/minify.rs b/source/minify.rs index d87f7d2..448b8a8 100644 --- a/source/minify.rs +++ b/source/minify.rs @@ -1,8 +1,8 @@ +//! Code for minifying. + use color_eyre::Result; -/** -Minify HTML using [`minify-html`]. -*/ +/// Minify HTML using [`minify-html`]. pub fn html(data: String) -> Result { let minify_config = minify_html::Cfg { do_not_minify_doctype: true, diff --git a/source/scss/mod.rs b/source/scss/mod.rs index caae318..2d32e1e 100644 --- a/source/scss/mod.rs +++ b/source/scss/mod.rs @@ -1,3 +1,5 @@ +//! Logic for building and writing the SCSS. + use std::{ fs::{create_dir_all, write}, path::Path, @@ -9,9 +11,11 @@ use rsass::{ output::{Format, Style}, }; +/// Struct to contain functionality for building the SCSS. pub struct Scss; impl Scss { + /// Build the SCSS and write the CSS to their respective places. pub fn write(public_dir: &Path, source_dir: &Path) -> Result<()> { let css_dir = public_dir.join("css"); create_dir_all(&css_dir)?; diff --git a/source/templates/mod.rs b/source/templates/mod.rs index f31097b..580545b 100644 --- a/source/templates/mod.rs +++ b/source/templates/mod.rs @@ -1,3 +1,5 @@ +//! The main [`askama`] templates. + use std::{ fs::{create_dir_all, write}, path::Path, @@ -6,13 +8,16 @@ use std::{ use askama::Template; use color_eyre::Result; +/// The template for the home page. #[derive(Debug, Template)] #[template(path = "index.html")] pub struct Index { + /// The text for the `` element. pub page_title: String, } impl Index { + /// Build, minify and write the template. pub fn write(public_dir: &Path) -> Result<()> { let destination = public_dir.join("index.html"); create_dir_all(destination.parent().unwrap())?; diff --git a/source/video/filters.rs b/source/video/filters.rs index 6e96f93..3352b75 100644 --- a/source/video/filters.rs +++ b/source/video/filters.rs @@ -1,10 +1,6 @@ -/*! -Filters for Askama templates. -*/ +//! Custom filters for [`askama`] templates. -/** -Get the DRG mod link and title from a given ID. -*/ +/// Get the DRG mod link and title from a given ID. pub fn drg_mod(mod_id: &str) -> askama::Result<(String, &str)> { let mods = std::collections::HashMap::<_, _>::from_iter([ ("brighter-objects", "Brighter Objects"), @@ -16,15 +12,13 @@ pub fn drg_mod(mod_id: &str) -> askama::Result<(String, &str)> { Ok((format!("https://drg.mod.io/{mod_id}"), mod_title)) } -/** -Turn a timestamp with format `mm:ss` into its total seconds. - -## Examples - -- `00:30` -> 30 seconds -- `01:00` -> 60 seconds -- `01:30` -> 90 seconds -*/ +/// Turn a timestamp with format `mm:ss` into its total seconds. +/// +/// ## Examples +/// +/// - `00:30` -> 30 seconds +/// - `01:00` -> 60 seconds +/// - `01:30` -> 90 seconds pub fn timestamp_to_seconds(timestamp: &str) -> askama::Result<i32> { let mut split = timestamp.split(':'); let minutes = split.next().map(str::parse::<i32>).unwrap().unwrap(); diff --git a/source/video/mod.rs b/source/video/mod.rs index 357ee15..f59f370 100644 --- a/source/video/mod.rs +++ b/source/video/mod.rs @@ -1,3 +1,5 @@ +//! Templates, data structures and logic for the video pages. + use std::{fs, path::Path}; use { @@ -8,6 +10,7 @@ use { mod filters; +/// The template for videos. #[derive(Debug, Template)] #[template(path = "video.html")] pub struct VideoTemplate { @@ -27,6 +30,7 @@ pub struct VideoTemplate { pub video_id: String, } +/// The frontmatter data for a video. #[derive(Debug, Deserialize)] pub struct VideoData { /// Deep Rock Galactic data. @@ -46,6 +50,7 @@ pub struct VideoData { pub tags: Vec<String>, } +/// Data for speedrun videos. #[derive(Debug, Deserialize)] pub struct SpeedrunData { /// Video chapters as with timestamps and chapter titles. @@ -61,12 +66,14 @@ pub struct SpeedrunData { pub mods: Option<Vec<String>>, } +/// Additional data for Deep Rock Galactic videos. #[derive(Debug, Deserialize)] pub struct DeepRockGalacticData { /// Deep Rock Galactic mods used in the run. pub mods: Option<Vec<String>>, } +/// Compile and write all the found videos to their respective locations. pub fn write_all(public_dir: &Path) -> Result<()> { let video_datas = { let mut data = vec![];