Skip to content

Commit

Permalink
refactor(ssg): 🎨 optimisations and cleaning up
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastienrousseau committed Apr 4, 2024
1 parent 06fb02b commit 68d1f4b
Show file tree
Hide file tree
Showing 35 changed files with 377 additions and 138 deletions.
226 changes: 167 additions & 59 deletions Cargo.lock

Large diffs are not rendered by default.

61 changes: 48 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ name = "ssg"
readme = "README.md"
repository = "https://github.com/sebastienrousseau/shokunin"
rust-version = "1.71.1"
version = "0.0.26"
version = "0.0.27"
include = [
"/CONTRIBUTING.md",
"/LICENSE-APACHE",
Expand All @@ -46,26 +46,26 @@ harness = false
path = "benches/bench.rs"

[dependencies]
clap = "4.5.1"
comrak = "0.21.0"
clap = "4.5.4"
comrak = "0.22.0"
dtt = "0.0.5"
env_logger = "0.11.2"
env_logger = "0.11.3"
lazy_static = "1.4.0"
log = {version="0.4.21", features = ["std"] }
minify-html = "0.15.0"
printpdf = "0.7.0"
pulldown-cmark = "0.10.2"
quick-xml = "0.31.0"
regex = "1.10.3"
reqwest = { version = "0.11.24", features = ["blocking", "json"] }
rlg = "0.0.2"
regex = "1.10.4"
reqwest = { version = "0.12.2", features = ["blocking", "json"] }
rlg = "0.0.3"
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.114"
serde_json = "1.0.115"
tempfile = "3.10.1"
toml = "0.8.10"
toml = "0.8.12"
uuid = { version = "1.8.0", features = ["v4"] }
vrd = "0.0.6"
yaml-rust = "0.4.5"
vrd = "0.0.5"
printpdf = "0.7.0"
pulldown-cmark = "0.10.0"
uuid = { version = "1.7.0", features = ["v4"] }

# Unix platforms use OpenSSL for now to provide SSL functionality
[target.'cfg(all(unix, not(target_os = "macos")))'.dependencies]
Expand All @@ -86,6 +86,41 @@ default = []
[package.metadata.docs.rs]
all-features = true

# Linting config
[lints.rust]

## Forbid
missing_debug_implementations = "forbid"
missing_docs = "warn"
non_ascii_idents = "forbid"
unreachable_pub = "forbid"

## Deny
dead_code = "deny"
deprecated_in_future = "deny"
ellipsis_inclusive_range_patterns = "deny"
explicit_outlives_requirements = "deny"
future_incompatible = "deny"
keyword_idents = "deny"
macro_use_extern_crate = "deny"
meta_variable_misuse = "deny"
missing_fragment_specifier = "deny"
noop_method_call = "deny"
pointer_structural_match = "deny"
rust_2018_idioms = "deny"
rust_2021_compatibility = "deny"
single_use_lifetimes = "deny"
trivial_casts = "deny"
trivial_numeric_casts = "deny"
unused = "deny"
unused_features = "deny"
unused_import_braces = "deny"
unused_labels = "deny"
unused_lifetimes = "deny"
unused_macro_rules = "deny"
unused_qualifications = "deny"
variant_size_differences = "deny"

[profile.dev]
codegen-units = 256
debug = true
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ following to your `Cargo.toml` file:

```toml
[dependencies]
shokunin = "0.0.26"
shokunin = "0.0.27"
```

Add the following to your `main.rs` file:
Expand Down Expand Up @@ -306,6 +306,6 @@ of useful suggestions on how to improve this project.
[crates-badge]: https://img.shields.io/crates/v/ssg.svg?style=for-the-badge 'Crates.io badge'
[divider]: https://kura.pro/common/images/elements/divider.svg "divider"
[docs-badge]: https://img.shields.io/docsrs/ssg.svg?style=for-the-badge 'Docs.rs badge'
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.26-orange.svg?style=for-the-badge 'Lib.rs badge'
[libs-badge]: https://img.shields.io/badge/lib.rs-v0.0.27-orange.svg?style=for-the-badge 'Lib.rs badge'
[license-badge]: https://img.shields.io/crates/l/ssg.svg?style=for-the-badge 'License badge'
[made-with-rust-badge]: https://img.shields.io/badge/rust-f04041?style=for-the-badge&labelColor=c0282d&logo=rust 'Made With Rust badge'
2 changes: 1 addition & 1 deletion TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

<!-- markdownlint-enable MD033 MD041 -->

# Shokunin Static Site Generator (SSG) v0.0.26 🦀
# Shokunin Static Site Generator (SSG) v0.0.27 🦀

The fastest Rust-based Static Site Generator (SSG) for building professional
websites and blogs.
Expand Down
2 changes: 1 addition & 1 deletion benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
// SPDX-License-Identifier: Apache-2.0 OR MIT

//! This crate is responsible for benchmarking various components of the application.

#![allow(missing_docs)]
extern crate criterion;
use criterion::Criterion;

/// This is a module for benchmarking file operations.
Expand Down
9 changes: 6 additions & 3 deletions benches/bench_file.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
// Copyright © 2024-2024 Shokunin Static Site Generator. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT

extern crate criterion;

use criterion::{black_box, Criterion};
use ssg::utilities::file::add;
use std::path::PathBuf;

pub fn bench_file(c: &mut Criterion) {
/// Runs a benchmark that measures the performance of the `add` function.
///
/// # Arguments
///
/// * `c` - A reference to a `Criterion` instance.
pub(crate) fn bench_file(c: &mut Criterion) {
let path = PathBuf::from("content");
c.bench_function("add function", |b| {
b.iter(|| {
Expand Down
116 changes: 112 additions & 4 deletions benches/bench_frontmatter.rs
Original file line number Diff line number Diff line change
@@ -1,26 +1,134 @@
// Copyright © 2024-2024 Shokunin Static Site Generator. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT

extern crate criterion;

use criterion::{black_box, Criterion};
use ssg::modules::frontmatter::{extract, parse_yaml_document};

pub fn bench_extract(c: &mut Criterion) {
/// Benchmarks the extraction of frontmatter from a content string.
///
/// This function sets up a benchmark for the `extract` function, which extracts
/// the frontmatter from a content string. The content string is hardcoded in
/// this function.
///
/// # Arguments
///
/// * `c` - A mutable reference to a `Criterion` instance, which is used to
/// define and run benchmarks.
///
/// # Example
///
/// ```rust
/// use criterion::{criterion_group, criterion_main, Criterion};

Check failure on line 21 in benches/bench_frontmatter.rs

View workflow job for this annotation

GitHub Actions / Lint

needless `fn main` in doctest
/// use shokunin_static_site_generator::ssg::modules::frontmatter::bench_extract;
///
/// fn main() {
/// let mut group = criterion_group::CriterionGroup::new();
/// group.bench_function("extract", |b| bench_extract(b));
/// criterion_main(group);
/// }
/// ```
///
/// # Panics
///
/// This function does not panic.
pub(crate) fn bench_extract(c: &mut Criterion) {

Check failure on line 34 in benches/bench_frontmatter.rs

View workflow job for this annotation

GitHub Actions / Lint

function `bench_extract` is never used
let content = r#"
---
title: "Test"
---
"#;

// Benchmarks the execution of the `extract` function.
//
// This function sets up a benchmark for the execution of the `extract`
// function, which extracts the frontmatter from a content string. The
// content string is hardcoded in this function.
//
// # Arguments
//
// * `b` - A mutable reference to a `Bencher` instance, which is used to
// define and run benchmarks.
//
// # Example
//
// ```rust
// use criterion::{criterion_group, criterion_main, Criterion};
// use shokunin_static_site_generator::ssg::modules::frontmatter::bench_extract;
//
// fn main() {
// let mut group = criterion_group::CriterionGroup::new();
// group.bench_function("extract", |b| bench_extract(b));
// criterion_main(group);
// }
// ```
//
// # Panics
//
// This function does not panic.
c.bench_function("extract", |b| {
b.iter(|| extract(black_box(content)))
});
}

pub fn bench_parse_yaml_document(c: &mut Criterion) {
/// Benchmarks the parsing of YAML document from a content string.
///
/// This function sets up a benchmark for the `parse_yaml_document` function,
/// which parses a YAML document from a content string. The content string is
/// hardcoded in this function.
///
/// # Arguments
///
/// * `c` - A mutable reference to a `Criterion` instance, which is used to
/// define and run benchmarks.
///
/// # Example
///
/// ```rust
/// use criterion::{criterion_group, criterion_main, Criterion};

Check failure on line 87 in benches/bench_frontmatter.rs

View workflow job for this annotation

GitHub Actions / Lint

needless `fn main` in doctest
/// use shokunin_static_site_generator::ssg::modules::frontmatter::bench_parse_yaml_document;
///
/// fn main() {
/// let mut group = criterion_group::CriterionGroup::new();
/// group.bench_function("parse_yaml_document", |b| bench_parse_yaml_document(b));
/// criterion_main(group);
/// }
/// ```
///
/// # Panics
///
/// This function does not panic.
pub(crate) fn bench_parse_yaml_document(c: &mut Criterion) {

Check failure on line 100 in benches/bench_frontmatter.rs

View workflow job for this annotation

GitHub Actions / Lint

function `bench_parse_yaml_document` is never used
let content = r#"
title: "Test"
"#;

// Benchmarks the execution of the `parse_yaml_document` function.
//
// This function sets up a benchmark for the execution of the `parse_yaml_document`
// function, which parses a YAML document from a content string. The
// content string is hardcoded in this function.
//
// # Arguments
//
// * `b` - A mutable reference to a `Bencher` instance, which is used to
// define and run benchmarks.
//
// # Example
//
// ```rust
// use criterion::{criterion_group, criterion_main, Criterion};
// use shokunin_static_site_generator::ssg::modules::frontmatter::bench_parse_yaml_document;
//
// fn main() {
// let mut group = criterion_group::CriterionGroup::new();
// group.bench_function("parse_yaml_document", |b| bench_parse_yaml_document(b));
// criterion_main(group);
// }
// ```
//
// # Panics
//
// This function does not panic.
c.bench_function("parse_yaml_document", |b| {
b.iter(|| parse_yaml_document(black_box(content)))
});
Expand Down
2 changes: 0 additions & 2 deletions benches/bench_html.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright © 2024-2024 Shokunin Static Site Generator. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT

extern crate criterion;

use criterion::{black_box, Criterion};
use ssg::modules::html::generate_html;

Expand Down
4 changes: 1 addition & 3 deletions benches/bench_json.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// Copyright © 2024-2024 Shokunin Static Site Generator. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT

extern crate criterion;

use std::path::Path;

use criterion::{black_box, Criterion};
Expand All @@ -11,7 +9,7 @@ use ssg::models::data::{
};
use ssg::modules::json::{cname, human, manifest, sitemap, txt};

pub fn bench_json(c: &mut Criterion) {
pub(crate) fn bench_json(c: &mut Criterion) {
let manifest_data = ManifestData {
name: String::from("Test Name"),
short_name: String::from("Test Short Name"),
Expand Down
4 changes: 1 addition & 3 deletions benches/bench_metatags.rs
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
// Copyright © 2024-2024 Shokunin Static Site Generator. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT

extern crate criterion;

use criterion::{black_box, Criterion};
use ssg::modules::metatags::generate_metatags;

pub fn bench_metatags(c: &mut Criterion) {
pub(crate) fn bench_metatags(c: &mut Criterion) {

Check failure on line 7 in benches/bench_metatags.rs

View workflow job for this annotation

GitHub Actions / Lint

function `bench_metatags` is never used

Check failure on line 7 in benches/bench_metatags.rs

View workflow job for this annotation

GitHub Actions / Check

function `bench_metatags` is never used
let meta = vec![
("description".to_owned(), "My web page".to_owned()),
("author".to_owned(), "John Doe".to_owned()),
Expand Down
4 changes: 1 addition & 3 deletions benches/bench_utilities.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
// Copyright © 2024-2024 Shokunin Static Site Generator. All rights reserved.
// SPDX-License-Identifier: Apache-2.0 OR MIT

extern crate criterion;

use criterion::{black_box, Criterion};
use ssg::utilities::directory::directory;
use tempfile::TempDir;

pub fn bench_utilities(c: &mut Criterion) {
pub(crate) fn bench_utilities(c: &mut Criterion) {
let tempdir = TempDir::new().unwrap();
let dir = tempdir.path().join("test_dir");

Expand Down
2 changes: 1 addition & 1 deletion content/404.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ viewport: "width=device-width, initial-scale=1, shrink-to-fit=no"
atom_link: "https://kaishi.one/404/rss.xml"
category: "Technology"
docs: "https://validator.w3.org/feed/docs/rss2.html"
generator: "Shokunin SSG (version 0.0.26)"
generator: "Shokunin SSG (version 0.0.27)"
item_description: "The page may have been removed or renamed. Please visit our homepage for more information."
item_guid: "https://kaishi.one/404/rss.xml"
item_link: "https://kaishi.one/404/rss.xml"
Expand Down
2 changes: 1 addition & 1 deletion content/contact.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewpor
atom_link: https://kaishi.one/contact/rss.xml
category: "Technology"
docs: https://validator.w3.org/feed/docs/rss2.html
generator: "Shokunin SSG (version 0.0.26)"
generator: "Shokunin SSG (version 0.0.27)"
item_description: RSS feed for the contact page of the Kaishi website.
item_guid: https://kaishi.one/contact/rss.xml
item_link: https://kaishi.one/contact/rss.xml
Expand Down
2 changes: 1 addition & 1 deletion content/features.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewpor
atom_link: https://kaishi.one/rss.xml
category: "Technology"
docs: https://validator.w3.org/feed/docs/rss2.html
generator: "Shokunin SSG (version 0.0.26)"
generator: "Shokunin SSG (version 0.0.27)"
item_description: RSS feed for the site
item_guid: https://kaishi.one/rss.xml
item_link: https://kaishi.one/rss.xml
Expand Down
2 changes: 1 addition & 1 deletion content/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewpor
atom_link: https://kaishi.one/rss.xml
category: "Technology"
docs: https://validator.w3.org/feed/docs/rss2.html
generator: "Shokunin SSG (version 0.0.26)"
generator: "Shokunin SSG (version 0.0.27)"
item_description: RSS feed for the site
item_guid: https://kaishi.one/rss.xml
item_link: https://kaishi.one/rss.xml
Expand Down
2 changes: 1 addition & 1 deletion content/offline.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewpor
atom_link: https://kaishi.one/rss.xml
category: "Technology"
docs: https://validator.w3.org/feed/docs/rss2.html
generator: "Shokunin SSG (version 0.0.26)"
generator: "Shokunin SSG (version 0.0.27)"
item_description: RSS feed for the site
item_guid: https://kaishi.one/rss.xml
item_link: https://kaishi.one/rss.xml
Expand Down
2 changes: 1 addition & 1 deletion content/post.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ viewport: "width=device-width, initial-scale=1, shrink-to-fit=no" ## The viewpor
atom_link: https://kaishi.one/rss.xml
category: "Technology"
docs: https://validator.w3.org/feed/docs/rss2.html
generator: "Shokunin SSG (version 0.0.26)"
generator: "Shokunin SSG (version 0.0.27)"
item_description: RSS feed for the site
item_guid: https://kaishi.one/rss.xml
item_link: https://kaishi.one/rss.xml
Expand Down
Loading

0 comments on commit 68d1f4b

Please sign in to comment.