Rust library to generate static websites
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: lint

+35 -14
+22 -7
crates/maudit/src/build/state.rs
··· 158 158 /// that all content sources should be re-initialized. 159 159 /// 160 160 /// Only considers files that look like content files (have common content extensions). 161 - pub fn get_affected_content_sources(&self, changed_files: &[PathBuf]) -> Option<FxHashSet<String>> { 161 + pub fn get_affected_content_sources( 162 + &self, 163 + changed_files: &[PathBuf], 164 + ) -> Option<FxHashSet<String>> { 162 165 let content_extensions = ["md", "mdx", "yaml", "yml", "json", "toml"]; 163 166 let mut affected_sources = FxHashSet::default(); 164 167 ··· 999 1002 state.track_content_file_source(file.clone(), "articles".to_string()); 1000 1003 1001 1004 assert_eq!(state.content_file_to_source.len(), 1); 1002 - assert_eq!(state.content_file_to_source.get(&file), Some(&"articles".to_string())); 1005 + assert_eq!( 1006 + state.content_file_to_source.get(&file), 1007 + Some(&"articles".to_string()) 1008 + ); 1003 1009 } 1004 1010 1005 1011 #[test] ··· 1027 1033 state.track_content_file_source(page.clone(), "pages".to_string()); 1028 1034 1029 1035 // Change both files 1030 - let affected = state.get_affected_content_sources(&[article, page]).unwrap(); 1036 + let affected = state 1037 + .get_affected_content_sources(&[article, page]) 1038 + .unwrap(); 1031 1039 assert_eq!(affected.len(), 2); 1032 1040 assert!(affected.contains("articles")); 1033 1041 assert!(affected.contains("pages")); ··· 1057 1065 let rust_file = PathBuf::from("/project/src/pages/index.rs"); 1058 1066 1059 1067 // Should return empty set (no content sources affected) 1060 - let affected = state.get_affected_content_sources(&[rust_file.clone()]).unwrap(); 1068 + let affected = state 1069 + .get_affected_content_sources(std::slice::from_ref(&rust_file)) 1070 + .unwrap(); 1061 1071 assert!(affected.is_empty()); 1062 1072 1063 1073 // Mixed: content file + non-content file 1064 - let affected = state.get_affected_content_sources(&[article, rust_file]).unwrap(); 1074 + let affected = state 1075 + .get_affected_content_sources(&[article, rust_file]) 1076 + .unwrap(); 1065 1077 assert_eq!(affected.len(), 1); 1066 1078 assert!(affected.contains("articles")); 1067 1079 } ··· 1096 1108 // Articles source mappings should be removed 1097 1109 assert!(!state.content_file_to_source.contains_key(&article1)); 1098 1110 assert!(!state.content_file_to_source.contains_key(&article2)); 1099 - 1111 + 1100 1112 // But routes mappings should be preserved (cleared separately per-route) 1101 1113 assert!(state.content_file_to_routes.contains_key(&article1)); 1102 1114 assert!(state.content_file_to_routes.contains_key(&article2)); ··· 1104 1116 // Pages should remain completely unchanged 1105 1117 assert!(state.content_file_to_source.contains_key(&page)); 1106 1118 assert!(state.content_file_to_routes.contains_key(&page)); 1107 - assert_eq!(state.content_file_to_source.get(&page), Some(&"pages".to_string())); 1119 + assert_eq!( 1120 + state.content_file_to_source.get(&page), 1121 + Some(&"pages".to_string()) 1122 + ); 1108 1123 } 1109 1124 1110 1125 #[test]
+12 -6
crates/maudit/src/content.rs
··· 1 1 //! Core functions and structs to define the content sources of your website. 2 2 //! 3 3 //! Content sources represent the content of your website, such as articles, blog posts, etc. Then, content sources can be passed to [`coronate()`](crate::coronate), through the [`content_sources!`](crate::content_sources) macro, to be loaded. 4 - use std::{any::Any, cell::RefCell, path::PathBuf, sync::Arc}; 4 + use std::{ 5 + any::Any, 6 + cell::RefCell, 7 + path::{Path, PathBuf}, 8 + sync::Arc, 9 + }; 5 10 6 11 use rustc_hash::{FxHashMap, FxHashSet}; 7 12 ··· 50 55 51 56 /// Record that a content file was accessed. 52 57 /// This is called internally when entries are accessed. 53 - fn track_content_file_access(file_path: &PathBuf) { 58 + fn track_content_file_access(file_path: &Path) { 54 59 ACCESSED_CONTENT_FILES.with(|cell| { 55 60 if let Some(ref mut set) = *cell.borrow_mut() { 56 - set.insert(file_path.clone()); 61 + set.insert(file_path.to_path_buf()); 57 62 } 58 63 }); 59 64 } ··· 419 424 420 425 // Track file access for incremental builds 421 426 if let Some(entry) = &entry 422 - && let Some(ref file_path) = entry.file_path { 423 - track_content_file_access(file_path); 424 - } 427 + && let Some(ref file_path) = entry.file_path 428 + { 429 + track_content_file_access(file_path); 430 + } 425 431 426 432 entry 427 433 }
+1 -1
e2e/fixtures/incremental-build/src/main.rs
··· 1 - use maudit::{content_sources, coronate, routes, BuildOptions, BuildOutput}; 1 + use maudit::{BuildOptions, BuildOutput, content_sources, coronate, routes}; 2 2 3 3 mod content; 4 4 mod pages;