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