Compare commits

..

No commits in common. "b35047a1af671ce7dce16a6863aaf81f4ba3e640" and "c2ef25c9cf40c9e72a1af0e4a53fb490b759f639" have entirely different histories.

4 changed files with 261 additions and 294 deletions

504
Cargo.lock generated

File diff suppressed because it is too large Load diff

View file

@ -10,17 +10,17 @@ description = "A command-line static site generator"
homepage = "https://roxy-docs.netlify.app" homepage = "https://roxy-docs.netlify.app"
[dependencies] [dependencies]
glob = "~0.3.1" glob = "0.3.1"
syntect = "~5.2.0" syntect = "5.1.0"
roxy_markdown_parser = "~0.1.0" roxy_markdown_parser = "0.1.0"
roxy_tera_parser = "~0.1.0" roxy_tera_parser = "0.1.0"
roxy_markdown_tera_rewriter = "~0.1.0" roxy_markdown_tera_rewriter = "0.1.0"
roxy_syntect = "~0.1.0" roxy_syntect = "0.1.0"
roxy_core = "~0.1.1" roxy_core = "0.1.1"
clap = { version = "~4.5.22", features = ["derive"] } clap = { version = "4.4.17", features = ["derive"] }
toml = "~0.8.19" toml = "0.8.8"
tera = "~1.20" tera = "1.19.1"
serde = { version = "~1.0.215", features = ["derive"]} serde = { version = "1.0.195", features = ["derive"]}
slugify = "~0.1.0" slugify = "0.1.0"
anyhow = "~1.0.94" anyhow = "1.0.79"

View file

@ -48,7 +48,7 @@ impl Context {
} }
} }
pub fn from_files<'a, T: AsRef<Path> + std::fmt::Debug>( pub fn from_files<'a, T: AsRef<Path>>(
files: Vec<&PathBuf>, files: Vec<&PathBuf>,
file_path: &'a FilePath<T>, file_path: &'a FilePath<T>,
) -> Result<Context> { ) -> Result<Context> {

View file

@ -16,7 +16,7 @@ impl<'a, P: AsRef<Path> + 'a> FilePath<'a, P> {
pub fn new(input: &'a P, output: &'a P) -> Self { pub fn new(input: &'a P, output: &'a P) -> Self {
Self { Self {
input: Self::make_recursive(input), input: Self::make_recursive(input),
root_dir: Self::strip_wildcards(Self::strip_dot(&input)), root_dir: Self::strip_wildcards(input),
output, output,
slug_word_limit: Default::default(), slug_word_limit: Default::default(),
} }
@ -30,10 +30,6 @@ impl<'a, P: AsRef<Path> + 'a> FilePath<'a, P> {
!path.as_ref().contains("*") !path.as_ref().contains("*")
} }
fn strip_dot(path: &P) -> &Path {
path.as_ref().strip_prefix("./").unwrap_or(path.as_ref())
}
fn strip_wildcards<P2: AsRef<Path> + ?Sized>(path: &'a P2) -> PathBuf { fn strip_wildcards<P2: AsRef<Path> + ?Sized>(path: &'a P2) -> PathBuf {
path.as_ref() path.as_ref()
.ancestors() .ancestors()
@ -81,20 +77,3 @@ impl<'a, P: AsRef<Path> + 'a> FilePath<'a, P> {
value.as_ref().strip_prefix(&self.root_dir) value.as_ref().strip_prefix(&self.root_dir)
} }
} }
#[cfg(test)]
mod tests {
use std::path::Path;
use super::FilePath;
#[test]
fn relative_paths() {
let relative = FilePath::new(&"./in", &"./out");
let bare = FilePath::new(&"in", &"out");
let path = "in/nested/deeply/test.md" ;
let expected = Path::new("nested/deeply/test.md");
assert_eq!(expected, relative.strip_root(&path).unwrap());
assert_eq!(expected, bare.strip_root(&path).unwrap());
}
}