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]
|
||||
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"
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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<String> {
|
||||
let minify_config = minify_html::Cfg {
|
||||
do_not_minify_doctype: true,
|
||||
|
|
|
@ -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)?;
|
||||
|
|
|
@ -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 `<title>` 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())?;
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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![];
|
||||
|
|
Loading…
Reference in New Issue