Skip to content
This repository was archived by the owner on May 5, 2026. It is now read-only.

Commit afca077

Browse files
noahgiftclaude
andcommitted
Apply cargo fmt formatting fixes
Standardize code formatting across all crates to pass CI checks. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent c76d32a commit afca077

59 files changed

Lines changed: 1518 additions & 990 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

crates/presentar-cli/src/main.rs

Lines changed: 98 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,10 @@ fn main() {
157157
Commands::Serve { port, dir, watch } => {
158158
serve(port, dir, watch);
159159
}
160-
Commands::Bundle { output, no_optimize } => {
160+
Commands::Bundle {
161+
output,
162+
no_optimize,
163+
} => {
161164
bundle(output, no_optimize);
162165
}
163166
Commands::New { name } => {
@@ -450,7 +453,14 @@ fn watch_and_rebuild(dir: &PathBuf) {
450453

451454
fn rebuild_wasm() {
452455
let status = Command::new("wasm-pack")
453-
.args(["build", "crates/presentar", "--target", "web", "--out-dir", "../../www/pkg"])
456+
.args([
457+
"build",
458+
"crates/presentar",
459+
"--target",
460+
"web",
461+
"--out-dir",
462+
"../../www/pkg",
463+
])
454464
.stdout(std::process::Stdio::null())
455465
.stderr(std::process::Stdio::null())
456466
.status();
@@ -466,7 +476,14 @@ fn bundle(output: PathBuf, no_optimize: bool) {
466476

467477
// Build with wasm-pack
468478
let status = Command::new("wasm-pack")
469-
.args(["build", "crates/presentar", "--target", "web", "--release", "--out-dir"])
479+
.args([
480+
"build",
481+
"crates/presentar",
482+
"--target",
483+
"web",
484+
"--release",
485+
"--out-dir",
486+
])
470487
.arg(format!("../../{}", output.join("pkg").display()))
471488
.status()
472489
.expect("wasm-pack failed");
@@ -687,7 +704,11 @@ fn analyze_manifest_quality(manifest: &presentar_yaml::Manifest) -> QualityScore
687704
let structural_score = {
688705
let widget_score = (widget_count.min(20) as f64 / 20.0) * 10.0; // Up to 10 points for widgets
689706
let section_score = (section_count.min(5) as f64 / 5.0) * 8.0; // Up to 8 points for sections
690-
let layout_score = if manifest.layout.columns > 0 { 7.0 } else { 0.0 }; // 7 points for grid layout
707+
let layout_score = if manifest.layout.columns > 0 {
708+
7.0
709+
} else {
710+
0.0
711+
}; // 7 points for grid layout
691712
widget_score + section_score + layout_score
692713
};
693714

@@ -755,11 +776,10 @@ fn analyze_manifest_quality(manifest: &presentar_yaml::Manifest) -> QualityScore
755776
// Consistency (10 points max)
756777
let consistency_score = {
757778
// Check for consistent naming conventions
758-
let ids_consistent = manifest
759-
.layout
760-
.sections
761-
.iter()
762-
.all(|s| s.id.chars().all(|c| c.is_ascii_lowercase() || c == '-' || c == '_'));
779+
let ids_consistent = manifest.layout.sections.iter().all(|s| {
780+
s.id.chars()
781+
.all(|c| c.is_ascii_lowercase() || c == '-' || c == '_')
782+
});
763783

764784
let widgets_have_types = manifest
765785
.layout
@@ -972,7 +992,10 @@ fn deploy(
972992
if !skip_build {
973993
println!("Step 1: Building production bundle...");
974994
if dry_run {
975-
println!(" [dry-run] Would run: presentar bundle --output {}", source.display());
995+
println!(
996+
" [dry-run] Would run: presentar bundle --output {}",
997+
source.display()
998+
);
976999
} else {
9771000
bundle(source.clone(), false);
9781001
}
@@ -981,7 +1004,10 @@ fn deploy(
9811004

9821005
// Verify source directory exists
9831006
if !dry_run && !source.exists() {
984-
eprintln!("Error: Source directory '{}' does not exist", source.display());
1007+
eprintln!(
1008+
"Error: Source directory '{}' does not exist",
1009+
source.display()
1010+
);
9851011
eprintln!("Run 'presentar bundle' first or use --skip-build with existing files");
9861012
std::process::exit(1);
9871013
}
@@ -1030,8 +1056,12 @@ fn deploy_to_s3(
10301056
println!("Files that would be uploaded:");
10311057
for (path, content_type) in &files {
10321058
let rel_path = path.strip_prefix(source).unwrap_or(path);
1033-
println!(" {} ({}, {} bytes)", rel_path.display(), content_type,
1034-
fs::metadata(path).map(|m| m.len()).unwrap_or(0));
1059+
println!(
1060+
" {} ({}, {} bytes)",
1061+
rel_path.display(),
1062+
content_type,
1063+
fs::metadata(path).map(|m| m.len()).unwrap_or(0)
1064+
);
10351065
}
10361066
} else {
10371067
// Upload files using AWS CLI
@@ -1094,7 +1124,10 @@ fn deploy_to_s3(
10941124
println!("Dry run complete. No files were uploaded.");
10951125
} else {
10961126
println!("Deployment complete!");
1097-
println!(" URL: https://{}.s3.{}.amazonaws.com/index.html", bucket, region);
1127+
println!(
1128+
" URL: https://{}.s3.{}.amazonaws.com/index.html",
1129+
bucket, region
1130+
);
10981131
if distribution.is_some() {
10991132
println!(" Note: CloudFront may take a few minutes to propagate");
11001133
}
@@ -1109,8 +1142,11 @@ fn deploy_to_cloudflare(source: &PathBuf, project: Option<&str>, dry_run: bool)
11091142
println!(" Project: {}", project);
11101143

11111144
if dry_run {
1112-
println!(" [dry-run] Would run: npx wrangler pages deploy {} --project-name {}",
1113-
source.display(), project);
1145+
println!(
1146+
" [dry-run] Would run: npx wrangler pages deploy {} --project-name {}",
1147+
source.display(),
1148+
project
1149+
);
11141150
} else {
11151151
let status = Command::new("npx")
11161152
.args(["wrangler", "pages", "deploy"])
@@ -1138,7 +1174,10 @@ fn deploy_to_vercel(source: &PathBuf, dry_run: bool) {
11381174
println!("Step 2: Deploying to Vercel...");
11391175

11401176
if dry_run {
1141-
println!(" [dry-run] Would run: vercel deploy {} --prod", source.display());
1177+
println!(
1178+
" [dry-run] Would run: vercel deploy {} --prod",
1179+
source.display()
1180+
);
11421181
} else {
11431182
let status = Command::new("vercel")
11441183
.args(["deploy", "--prod"])
@@ -1165,7 +1204,10 @@ fn deploy_to_netlify(source: &PathBuf, dry_run: bool) {
11651204
println!("Step 2: Deploying to Netlify...");
11661205

11671206
if dry_run {
1168-
println!(" [dry-run] Would run: netlify deploy --dir {} --prod", source.display());
1207+
println!(
1208+
" [dry-run] Would run: netlify deploy --dir {} --prod",
1209+
source.display()
1210+
);
11691211
} else {
11701212
let status = Command::new("netlify")
11711213
.args(["deploy", "--prod"])
@@ -1200,7 +1242,11 @@ fn deploy_to_local(source: &PathBuf, dest: Option<&str>, dry_run: bool) {
12001242
println!(" [dry-run] Would copy {} files", files.len());
12011243
for (path, _) in &files {
12021244
let rel_path = path.strip_prefix(source).unwrap_or(path);
1203-
println!(" {} -> {}", rel_path.display(), dest_path.join(rel_path).display());
1245+
println!(
1246+
" {} -> {}",
1247+
rel_path.display(),
1248+
dest_path.join(rel_path).display()
1249+
);
12041250
}
12051251
} else {
12061252
// Use cp -r for simplicity
@@ -1510,23 +1556,41 @@ layout:
15101556
#[test]
15111557
fn test_get_content_type() {
15121558
assert_eq!(get_content_type(&PathBuf::from("index.html")), "text/html");
1513-
assert_eq!(get_content_type(&PathBuf::from("app.js")), "application/javascript");
1514-
assert_eq!(get_content_type(&PathBuf::from("app.wasm")), "application/wasm");
1559+
assert_eq!(
1560+
get_content_type(&PathBuf::from("app.js")),
1561+
"application/javascript"
1562+
);
1563+
assert_eq!(
1564+
get_content_type(&PathBuf::from("app.wasm")),
1565+
"application/wasm"
1566+
);
15151567
assert_eq!(get_content_type(&PathBuf::from("style.css")), "text/css");
1516-
assert_eq!(get_content_type(&PathBuf::from("data.json")), "application/json");
1517-
assert_eq!(get_content_type(&PathBuf::from("logo.svg")), "image/svg+xml");
1568+
assert_eq!(
1569+
get_content_type(&PathBuf::from("data.json")),
1570+
"application/json"
1571+
);
1572+
assert_eq!(
1573+
get_content_type(&PathBuf::from("logo.svg")),
1574+
"image/svg+xml"
1575+
);
15181576
assert_eq!(get_content_type(&PathBuf::from("photo.png")), "image/png");
15191577
assert_eq!(get_content_type(&PathBuf::from("photo.jpg")), "image/jpeg");
15201578
assert_eq!(get_content_type(&PathBuf::from("photo.jpeg")), "image/jpeg");
15211579
assert_eq!(get_content_type(&PathBuf::from("anim.gif")), "image/gif");
1522-
assert_eq!(get_content_type(&PathBuf::from("favicon.ico")), "image/x-icon");
1580+
assert_eq!(
1581+
get_content_type(&PathBuf::from("favicon.ico")),
1582+
"image/x-icon"
1583+
);
15231584
assert_eq!(get_content_type(&PathBuf::from("font.woff")), "font/woff");
15241585
assert_eq!(get_content_type(&PathBuf::from("font.woff2")), "font/woff2");
15251586
assert_eq!(get_content_type(&PathBuf::from("font.ttf")), "font/ttf");
15261587
assert_eq!(get_content_type(&PathBuf::from("config.yaml")), "text/yaml");
15271588
assert_eq!(get_content_type(&PathBuf::from("config.yml")), "text/yaml");
15281589
assert_eq!(get_content_type(&PathBuf::from("readme.txt")), "text/plain");
1529-
assert_eq!(get_content_type(&PathBuf::from("unknown.xyz")), "application/octet-stream");
1590+
assert_eq!(
1591+
get_content_type(&PathBuf::from("unknown.xyz")),
1592+
"application/octet-stream"
1593+
);
15301594
}
15311595

15321596
#[test]
@@ -1563,9 +1627,15 @@ layout:
15631627
let files = collect_deploy_files(&temp_dir);
15641628

15651629
assert_eq!(files.len(), 3);
1566-
assert!(files.iter().any(|(p, t)| p.ends_with("index.html") && t == "text/html"));
1567-
assert!(files.iter().any(|(p, t)| p.ends_with("app.js") && t == "application/javascript"));
1568-
assert!(files.iter().any(|(p, t)| p.ends_with("app.wasm") && t == "application/wasm"));
1630+
assert!(files
1631+
.iter()
1632+
.any(|(p, t)| p.ends_with("index.html") && t == "text/html"));
1633+
assert!(files
1634+
.iter()
1635+
.any(|(p, t)| p.ends_with("app.js") && t == "application/javascript"));
1636+
assert!(files
1637+
.iter()
1638+
.any(|(p, t)| p.ends_with("app.wasm") && t == "application/wasm"));
15691639

15701640
// Cleanup
15711641
let _ = fs::remove_dir_all(&temp_dir);

crates/presentar-core/src/accessibility.rs

Lines changed: 52 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -346,9 +346,9 @@ impl AccessibilityTree {
346346
return None;
347347
}
348348

349-
let current_idx = self.focus.and_then(|id| {
350-
self.focus_order.iter().position(|&fid| fid == id)
351-
});
349+
let current_idx = self
350+
.focus
351+
.and_then(|id| self.focus_order.iter().position(|&fid| fid == id));
352352

353353
let next_idx = match current_idx {
354354
Some(idx) => (idx + 1) % self.focus_order.len(),
@@ -368,9 +368,9 @@ impl AccessibilityTree {
368368
return None;
369369
}
370370

371-
let current_idx = self.focus.and_then(|id| {
372-
self.focus_order.iter().position(|&fid| fid == id)
373-
});
371+
let current_idx = self
372+
.focus
373+
.and_then(|id| self.focus_order.iter().position(|&fid| fid == id));
374374

375375
let prev_idx = match current_idx {
376376
Some(idx) if idx > 0 => idx - 1,
@@ -455,8 +455,7 @@ impl HitTester {
455455

456456
/// Find the deepest accessible element at the given point.
457457
pub fn hit_test(&self, point: Point) -> Option<&AccessibleNode> {
458-
self.hit_test_id(point)
459-
.and_then(|id| self.tree.get(id))
458+
self.hit_test_id(point).and_then(|id| self.tree.get(id))
460459
}
461460

462461
/// Find the ID of the deepest accessible element at the given point.
@@ -466,7 +465,11 @@ impl HitTester {
466465
}
467466

468467
/// Recursive hit test implementation.
469-
fn hit_test_recursive(&self, node_id: AccessibleNodeId, point: Point) -> Option<AccessibleNodeId> {
468+
fn hit_test_recursive(
469+
&self,
470+
node_id: AccessibleNodeId,
471+
point: Point,
472+
) -> Option<AccessibleNodeId> {
470473
let node = self.tree.get(node_id)?;
471474

472475
if !node.contains_point(point) {
@@ -760,7 +763,10 @@ mod tests {
760763
assert_eq!(node.name, Some("Submit".to_string()));
761764
assert_eq!(node.description, Some("Submit the form".to_string()));
762765
assert!(node.focusable);
763-
assert_eq!(node.properties.get("aria-pressed"), Some(&"false".to_string()));
766+
assert_eq!(
767+
node.properties.get("aria-pressed"),
768+
Some(&"false".to_string())
769+
);
764770
}
765771

766772
// AccessibilityTree tests
@@ -775,7 +781,11 @@ mod tests {
775781
fn test_tree_insert_and_get() {
776782
let mut tree = AccessibilityTree::new();
777783
let id = tree.next_id();
778-
let node = AccessibleNode::new(id, AccessibleRole::Generic, Rect::new(0.0, 0.0, 100.0, 100.0));
784+
let node = AccessibleNode::new(
785+
id,
786+
AccessibleRole::Generic,
787+
Rect::new(0.0, 0.0, 100.0, 100.0),
788+
);
779789
tree.insert(node);
780790
tree.set_root(id);
781791

@@ -788,7 +798,11 @@ mod tests {
788798
fn test_tree_remove() {
789799
let mut tree = AccessibilityTree::new();
790800
let id = tree.next_id();
791-
let node = AccessibleNode::new(id, AccessibleRole::Generic, Rect::new(0.0, 0.0, 100.0, 100.0));
801+
let node = AccessibleNode::new(
802+
id,
803+
AccessibleRole::Generic,
804+
Rect::new(0.0, 0.0, 100.0, 100.0),
805+
);
792806
tree.insert(node);
793807

794808
let removed = tree.remove(id);
@@ -801,8 +815,16 @@ mod tests {
801815
let mut tree = AccessibilityTree::new();
802816
let id1 = tree.next_id();
803817
let id2 = tree.next_id();
804-
tree.insert(AccessibleNode::new(id1, AccessibleRole::Generic, Rect::default()));
805-
tree.insert(AccessibleNode::new(id2, AccessibleRole::Generic, Rect::default()));
818+
tree.insert(AccessibleNode::new(
819+
id1,
820+
AccessibleRole::Generic,
821+
Rect::default(),
822+
));
823+
tree.insert(AccessibleNode::new(
824+
id2,
825+
AccessibleRole::Generic,
826+
Rect::default(),
827+
));
806828

807829
tree.clear();
808830
assert!(tree.is_empty());
@@ -828,7 +850,11 @@ mod tests {
828850
fn test_tree_focus_non_focusable() {
829851
let mut tree = AccessibilityTree::new();
830852
let id = tree.next_id();
831-
let node = AccessibleNode::new(id, AccessibleRole::Generic, Rect::new(0.0, 0.0, 100.0, 50.0));
853+
let node = AccessibleNode::new(
854+
id,
855+
AccessibleRole::Generic,
856+
Rect::new(0.0, 0.0, 100.0, 50.0),
857+
);
832858
tree.insert(node);
833859

834860
assert!(!tree.set_focus(id));
@@ -906,7 +932,11 @@ mod tests {
906932
fn test_hit_test_single_node() {
907933
let mut tree = AccessibilityTree::new();
908934
let id = tree.next_id();
909-
let node = AccessibleNode::new(id, AccessibleRole::Button, Rect::new(10.0, 10.0, 100.0, 50.0));
935+
let node = AccessibleNode::new(
936+
id,
937+
AccessibleRole::Button,
938+
Rect::new(10.0, 10.0, 100.0, 50.0),
939+
);
910940
tree.insert(node);
911941
tree.set_root(id);
912942

@@ -1007,11 +1037,8 @@ mod tests {
10071037
);
10081038

10091039
let child_id = tree.next_id();
1010-
let mut child = AccessibleNode::button(
1011-
child_id,
1012-
"Button",
1013-
Rect::new(50.0, 50.0, 100.0, 100.0),
1014-
);
1040+
let mut child =
1041+
AccessibleNode::button(child_id, "Button", Rect::new(50.0, 50.0, 100.0, 100.0));
10151042
child.parent = Some(parent_id);
10161043
child.focusable = true;
10171044
parent.children.push(child_id);
@@ -1078,7 +1105,10 @@ mod tests {
10781105
.root(AccessibleRole::Generic, Rect::new(0.0, 0.0, 800.0, 600.0))
10791106
.push_child(AccessibleRole::Button, Rect::new(10.0, 10.0, 100.0, 50.0))
10801107
.pop()
1081-
.push_child(AccessibleRole::TextInput, Rect::new(10.0, 70.0, 200.0, 30.0))
1108+
.push_child(
1109+
AccessibleRole::TextInput,
1110+
Rect::new(10.0, 70.0, 200.0, 30.0),
1111+
)
10821112
.pop()
10831113
.build();
10841114

0 commit comments

Comments
 (0)