diff --git a/benches/bench_json.rs b/benches/bench_json.rs index 58380e27..162111d4 100644 --- a/benches/bench_json.rs +++ b/benches/bench_json.rs @@ -6,7 +6,7 @@ extern crate criterion; use std::path::Path; use criterion::{black_box, Criterion}; -use ssg::data::{ManifestData, TxtData, CnameData, HumansData, SiteMapData}; +use ssg::models::data::{ManifestData, TxtData, CnameData, HumansData, SiteMapData}; use ssg::modules::json::{manifest, txt, cname, human, sitemap}; pub fn bench_json(c: &mut Criterion) { diff --git a/src/compiler.rs b/src/compiler.rs index 1de22499..a87d87d2 100644 --- a/src/compiler.rs +++ b/src/compiler.rs @@ -2,10 +2,10 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use crate::{ - data::{FileData, RssData, PageData}, macro_log_info, macro_cleanup_directories, macro_create_directories, macro_metadata_option,macro_set_rss_data_fields, + models::data::{FileData, RssData, PageData}, modules::{ cname::create_cname_data, html::generate_html, diff --git a/src/lib.rs b/src/lib.rs index 9d50c7fa..20c6a60e 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -116,32 +116,28 @@ #![crate_type = "lib"] use crate::utilities::serve::start; -use cli::print_banner; +use term::cli::print_banner; use compiler::compile; use std::{error::Error, path::Path}; /// The `cli` module contains functions for the command-line interface. - pub mod cli; + pub mod term; /// The `compiler` module contains functions for the compilation process. pub mod compiler; - /// The `data` module contains the structs. - pub mod data; - /// The `loggers` module contains functions for logging. pub mod loggers; /// The `macros` module contains functions for generating macros. pub mod macros; + /// The `models` module contains the structs. + pub mod models; + /// The `modules` module contains the application modules. pub mod modules; - /// The `parser` module contains functions for parsing command-line - /// arguments and options. - pub mod process; - /// The `utilities` module contains utility functions. pub mod utilities; @@ -167,8 +163,8 @@ pub fn run() -> Result<(), Box> { print_banner(); // Build the CLI and parse the arguments - let matches = cli::build()?; - process::args(&matches)?; + let matches = term::cli::build()?; + term::process::args(&matches)?; if let Some(site_name) = matches.get_one::("new") { // Start the server using the specified server address and site name. diff --git a/src/data.rs b/src/models/data.rs similarity index 100% rename from src/data.rs rename to src/models/data.rs diff --git a/src/models/mod.rs b/src/models/mod.rs new file mode 100644 index 00000000..014467b2 --- /dev/null +++ b/src/models/mod.rs @@ -0,0 +1,5 @@ +// Copyright © 2023 Shokunin Static Site Generator. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 OR MIT + +/// The `data` module contains the structs. +pub mod data; diff --git a/src/modules/cname.rs b/src/modules/cname.rs index 47bfbc36..533c5668 100644 --- a/src/modules/cname.rs +++ b/src/modules/cname.rs @@ -1,7 +1,7 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::data::CnameData; +use crate::models::data::CnameData; use std::collections::HashMap; /// Function to create CnameData diff --git a/src/modules/human.rs b/src/modules/human.rs index 4d94ed2e..2a74f809 100644 --- a/src/modules/human.rs +++ b/src/modules/human.rs @@ -1,7 +1,7 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::data::HumansData; +use crate::models::data::HumansData; use std::collections::HashMap; /// Function to create HumansData diff --git a/src/modules/json.rs b/src/modules/json.rs index ba463d50..e4dfd03c 100644 --- a/src/modules/json.rs +++ b/src/modules/json.rs @@ -7,7 +7,7 @@ use std::{ }; use serde_json::{json, Map}; -use crate::data::{ +use crate::models::data::{ CnameData, HumansData, ManifestData, SiteMapData, TxtData }; diff --git a/src/modules/manifest.rs b/src/modules/manifest.rs index 39f52e8c..d469ef69 100644 --- a/src/modules/manifest.rs +++ b/src/modules/manifest.rs @@ -1,7 +1,7 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::{data::{IconData, ManifestData}, macro_metadata_option}; +use crate::{models::data::{IconData, ManifestData}, macro_metadata_option}; use std::collections::HashMap; /// Function to create ManifestData diff --git a/src/modules/metadata.rs b/src/modules/metadata.rs index d5355a1b..2ac03ee2 100644 --- a/src/modules/metadata.rs +++ b/src/modules/metadata.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use crate::{ - data:: MetaTagGroups, + models::data:: MetaTagGroups, modules::{ frontmatter::extract, keywords::extract_keywords, @@ -33,7 +33,7 @@ use std::collections::HashMap; /// # Examples /// /// ```rust -/// use ssg::data::FileData; +/// use ssg::models::data::FileData; /// use ssg::modules::metadata::extract_and_prepare_metadata; /// /// let file_content = "---\n\n# Front Matter (YAML)\n\nauthor: \"Jane Doe\"\ncategory: \"Rust\"\ndescription: \"A blog about Rust programming.\"\nlayout: \"post\"\npermalink: \"https://example.com/blog/rust\"\ntags: \"rust,programming\"\ntitle: \"Rust\"\n\n---\n\n# Content\n\nThis is a blog about Rust programming.\n"; diff --git a/src/modules/metatags.rs b/src/modules/metatags.rs index d2f3f8fe..2ba3d5ab 100644 --- a/src/modules/metatags.rs +++ b/src/modules/metatags.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT use std::collections::HashMap; -use crate::data::{MetaTag, MetaTagGroups}; +use crate::models::data::{MetaTag, MetaTagGroups}; use crate::{macro_generate_tags_from_list, macro_generate_tags_from_fields}; // Type alias for better readability diff --git a/src/modules/navigation.rs b/src/modules/navigation.rs index 8b037a2d..cf3af3fb 100644 --- a/src/modules/navigation.rs +++ b/src/modules/navigation.rs @@ -1,4 +1,4 @@ -use crate::data::FileData; +use crate::models::data::FileData; use crate::utilities::directory::to_title_case; use std::path::Path; diff --git a/src/modules/rss.rs b/src/modules/rss.rs index a42a74a2..62cc5466 100644 --- a/src/modules/rss.rs +++ b/src/modules/rss.rs @@ -1,7 +1,7 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::data::RssData; +use crate::models::data::RssData; use crate::macro_write_element; use quick_xml::{ events::{BytesDecl, BytesEnd, BytesStart, Event}, diff --git a/src/modules/sitemap.rs b/src/modules/sitemap.rs index ccee458a..75af1d1d 100644 --- a/src/modules/sitemap.rs +++ b/src/modules/sitemap.rs @@ -1,7 +1,7 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::data::SiteMapData; +use crate::models::data::SiteMapData; use std::collections::HashMap; /// Function to create SiteMapData diff --git a/src/modules/tags.rs b/src/modules/tags.rs index 8d58ab0f..a56109d9 100644 --- a/src/modules/tags.rs +++ b/src/modules/tags.rs @@ -1,7 +1,7 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::data::{FileData, TagsData, PageData}; +use crate::models::data::{FileData, TagsData, PageData}; use crate::utilities::directory::to_title_case; use std::{io::{Read, Write}, collections::HashMap, path::Path, fs}; @@ -19,7 +19,7 @@ use std::{io::{Read, Write}, collections::HashMap, path::Path, fs}; /// # Example /// /// ```rust -/// use ssg::data::FileData; +/// use ssg::models::data::FileData; /// use ssg::modules::tags::generate_tags; /// use std::collections::HashMap; /// @@ -159,7 +159,7 @@ pub fn create_tags_data( /// /// ```rust /// use std::collections::HashMap; -/// use ssg::data::PageData; +/// use ssg::models::data::PageData; /// use ssg::modules::tags::generate_tags_html; /// /// let mut global_tags_data = HashMap::new(); diff --git a/src/modules/txt.rs b/src/modules/txt.rs index 04b9ea3f..5397170f 100644 --- a/src/modules/txt.rs +++ b/src/modules/txt.rs @@ -1,7 +1,7 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::data::TxtData; +use crate::models::data::TxtData; use std::collections::HashMap; /// Function to create TxtData diff --git a/src/cli.rs b/src/term/cli.rs similarity index 97% rename from src/cli.rs rename to src/term/cli.rs index f75d50c3..9593fae0 100644 --- a/src/cli.rs +++ b/src/term/cli.rs @@ -35,8 +35,8 @@ use clap::{Arg, ArgMatches, Command, Error}; /// # Examples /// /// ``` -/// use ssg::cli; -/// let cmd = cli::build().unwrap(); +/// use ssg::term::cli::build; +/// let cmd = build().unwrap(); /// /// ``` pub fn build() -> Result { @@ -103,7 +103,7 @@ pub fn build() -> Result { /// # Examples /// /// ``` -/// use ssg::cli::print_banner; +/// use ssg::term::cli::print_banner; /// /// print_banner(); /// ``` diff --git a/src/term/mod.rs b/src/term/mod.rs new file mode 100644 index 00000000..89efadb2 --- /dev/null +++ b/src/term/mod.rs @@ -0,0 +1,8 @@ +// Copyright © 2023 Shokunin Static Site Generator. All rights reserved. +// SPDX-License-Identifier: Apache-2.0 OR MIT + + /// The `cli` module contains functions for the command-line interface. + pub mod cli; + + /// The `parser` module contains functions for parsing command-line arguments and options. + pub mod process; diff --git a/src/process.rs b/src/term/process.rs similarity index 100% rename from src/process.rs rename to src/term/process.rs diff --git a/src/utilities/file.rs b/src/utilities/file.rs index 82f3f581..eedc0828 100644 --- a/src/utilities/file.rs +++ b/src/utilities/file.rs @@ -1,7 +1,7 @@ // Copyright © 2023 Shokunin Static Site Generator. All rights reserved. // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::data::FileData; +use crate::models::data::FileData; use quick_xml::escape::escape; use std::{fs, io, path::Path}; diff --git a/src/utilities/write.rs b/src/utilities/write.rs index ebed415e..7775a199 100644 --- a/src/utilities/write.rs +++ b/src/utilities/write.rs @@ -2,7 +2,7 @@ // SPDX-License-Identifier: Apache-2.0 OR MIT -use crate::data::FileData; +use crate::models::data::FileData; use crate::utilities::minification::minify_html; use std::error::Error; use std::fs; diff --git a/tests/test_compiler.rs b/tests/test_compiler.rs index fe20b117..d71aedf7 100644 --- a/tests/test_compiler.rs +++ b/tests/test_compiler.rs @@ -3,7 +3,7 @@ mod tests { use std::error::Error; use ssg::{ - data::RssData, + models::data::RssData, modules::{frontmatter::extract, html::generate_html, rss::generate_rss}, }; diff --git a/tests/test_data.rs b/tests/test_data.rs index c63f48c2..a25f21b5 100644 --- a/tests/test_data.rs +++ b/tests/test_data.rs @@ -1,7 +1,7 @@ #[cfg(test)] mod tests { - use ssg::data::{ + use ssg::models::data::{ CnameData, FileData, IconData, ManifestData, SiteMapData, TxtData, }; diff --git a/tests/test_json.rs b/tests/test_json.rs index c6241055..9a9218ff 100644 --- a/tests/test_json.rs +++ b/tests/test_json.rs @@ -3,7 +3,7 @@ mod tests { // Import necessary dependencies use serde_json::{json, Value}; use ssg::{ - data::{CnameData, ManifestData, TxtData}, + models::data::{CnameData, ManifestData, TxtData}, modules::json::{cname, manifest, txt}, }; diff --git a/tests/test_navigation.rs b/tests/test_navigation.rs index a9a8b9d7..b6710027 100644 --- a/tests/test_navigation.rs +++ b/tests/test_navigation.rs @@ -1,6 +1,6 @@ #[cfg(test)] mod tests { - use ssg::{data::FileData, modules::navigation::generate_navigation}; + use ssg::{models::data::FileData, modules::navigation::generate_navigation}; #[test] fn test_generate_navigation() { diff --git a/tests/test_process.rs b/tests/test_process.rs index 58fdcca2..81a77723 100644 --- a/tests/test_process.rs +++ b/tests/test_process.rs @@ -1,7 +1,7 @@ #[cfg(test)] mod tests { use clap::{Arg, Command}; - use ssg::process::args; + use ssg::term::process::args; #[test] fn test_args_required_args_missing() { diff --git a/tests/test_rss.rs b/tests/test_rss.rs index 0fb61dca..91dc2d44 100644 --- a/tests/test_rss.rs +++ b/tests/test_rss.rs @@ -3,7 +3,7 @@ mod tests { use std::io::Cursor; use quick_xml::Writer; - use ssg::{data::RssData, modules::rss::generate_rss}; + use ssg::{models::data::RssData, modules::rss::generate_rss}; // Test the default constructor of RssData #[test]