From f4c7d5d060c824e941babeab6b2f4c9e71538a07 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 12 Jan 2021 00:46:01 +0000 Subject: [PATCH] otterlib: wip preview, generates a thing Signed-off-by: Ian Jackson --- src/bin/otterlib.rs | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/src/bin/otterlib.rs b/src/bin/otterlib.rs index d0b22285..98e48479 100644 --- a/src/bin/otterlib.rs +++ b/src/bin/otterlib.rs @@ -40,18 +40,24 @@ fn preview(items: Vec) { let mut uos = vec![]; pc.add_ui_operations(&mut uos).context("add uos")?; let uos = uos.into_iter().map(|uo| uo.opname).collect::>(); - Ok::<_,AE>((pc, uos)) + Ok::<_,AE>((spec.clone(), pc, uos)) })().with_context(|| format!("{:?}", &spec)) }).collect::,_>>()?; - let max_faces = pieces.iter().map(|(p,_)| p.nfaces()).max().unwrap_or(1); - let max_uos = pieces.iter().map(|(_,uos)| uos.len()).max().unwrap_or(0); - - println!(""); - for (pc, uos) in &pieces { - println!("", pc.describe_html(None).0); - for face in 0..max_faces { - println!("
{}"); + let max_faces = pieces.iter().map(|(_,p,_)| p.nfaces()).max().unwrap_or(1); + let max_uos = pieces.iter().map(|(..,uos)| uos.len()).max().unwrap_or(0); + + println!(r#""#); + for (spec, pc, uos) in &pieces { + println!(r#""#); + println!(r#""#, pc.describe_html(None).0); + let only1 = pc.nfaces() == 1; + for face in 0..(if only1 { 1 } else { max_faces }) { + print!(r#"
{}"#, &spec.lib); + println!(r#"{}"#, &spec.item); + println!(r#"{}"#); if face < pc.nfaces() { let pri = PieceRenderInstructions { id: default(), -- 2.30.2