diff --git a/doctree/Cargo.toml b/doctree/Cargo.toml index 7108d38..2b212af 100644 --- a/doctree/Cargo.toml +++ b/doctree/Cargo.toml @@ -2,6 +2,9 @@ name = "doctree" version = "0.1.0" edition = "2024" +[lib] +path = "src/lib.rs" + [dependencies] walkdir = "2.3.3" diff --git a/doctree/src/collection.rs b/doctree/src/collection.rs index 5ccff8e..7e5874a 100644 --- a/doctree/src/collection.rs +++ b/doctree/src/collection.rs @@ -156,8 +156,11 @@ impl Collection { // Check if the path is valid if self.path.as_os_str().is_empty() { // If the path is empty, we're working with a collection loaded from Redis - // Return a placeholder content for demonstration purposes - return Ok(format!("Content for {} in collection {}\nThis is a placeholder since the actual file path is not available.", page_name, self.name)); + // Return an error since the actual file path is not available + return Err(DocTreeError::IoError(std::io::Error::new( + std::io::ErrorKind::NotFound, + format!("File path not available for {} in collection {}", page_name, self.name) + ))); } // Read the file diff --git a/doctree/src/doctree.rs b/doctree/src/doctree.rs index a98005d..086e3a2 100644 --- a/doctree/src/doctree.rs +++ b/doctree/src/doctree.rs @@ -4,11 +4,11 @@ use std::sync::{Arc, Mutex}; use std::fs; use serde::Deserialize; -use crate::collection::{Collection, CollectionBuilder}; +use crate::collection::Collection; use crate::error::{DocTreeError, Result}; use crate::storage::RedisStorage; use crate::include::process_includes; -use crate::utils::{name_fix, ensure_md_extension}; +use crate::utils::name_fix; /// Configuration for a collection from a .collection file #[derive(Deserialize, Default, Debug)] diff --git a/doctree/src/utils.rs b/doctree/src/utils.rs index 5c1c296..327a4ae 100644 --- a/doctree/src/utils.rs +++ b/doctree/src/utils.rs @@ -78,20 +78,3 @@ pub fn ensure_md_extension(name: &str) -> String { name.to_string() } } - -/// Get the file extension from a path -/// -/// # Arguments -/// -/// * `path` - The path to check -/// -/// # Returns -/// -/// The file extension or an empty string -pub fn get_extension(path: &str) -> String { - Path::new(path) - .extension() - .and_then(|ext| ext.to_str()) - .unwrap_or("") - .to_string() -} \ No newline at end of file