diff --git a/src/wasm-lib/derive-docs/src/lib.rs b/src/wasm-lib/derive-docs/src/lib.rs index 5a1d30c237..84f28badbb 100644 --- a/src/wasm-lib/derive-docs/src/lib.rs +++ b/src/wasm-lib/derive-docs/src/lib.rs @@ -805,7 +805,7 @@ fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> pr quote! { #[tokio::test(flavor = "multi_thread")] - async fn #test_name_mock() { + async fn #test_name_mock() -> miette::Result<()> { let program = crate::Program::parse_no_errs(#code_block).unwrap(); let ctx = crate::ExecutorContext { engine: std::sync::Arc::new(Box::new(crate::engine::conn_mock::EngineConnection::new().await.unwrap())), @@ -815,15 +815,33 @@ fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> pr context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()).await.unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + return Err(miette::Report::new(crate::errors::Report { + error: e, + filename: format!("{}{}", #fn_name, #index), + kcl_source: #code_block.to_string(), + })); + } + Ok(()) } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] - async fn #test_name() { + async fn #test_name() -> miette::Result<()> { let code = #code_block; // Note, `crate` must be kcl_lib - let result = crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm, None).await.unwrap(); + let result = match crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm, None).await { + Err(crate::errors::ExecError::Kcl(e)) => { + return Err(miette::Report::new(crate::errors::Report { + error: e, + filename: format!("{}{}", #fn_name, #index), + kcl_source: #code_block.to_string(), + })); + } + Err(other_err)=> panic!("{}", other_err), + Ok(img) => img, + }; twenty_twenty::assert_image(&format!("tests/outputs/{}.png", #output_test_name_str), &result, 0.99); + Ok(()) } } } diff --git a/src/wasm-lib/derive-docs/tests/args_with_lifetime.gen b/src/wasm-lib/derive-docs/tests/args_with_lifetime.gen index 0b93b33a85..5d0e51d5ab 100644 --- a/src/wasm-lib/derive-docs/tests/args_with_lifetime.gen +++ b/src/wasm-lib/derive-docs/tests/args_with_lifetime.gen @@ -14,9 +14,16 @@ mod test_examples_someFn { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "someFn", 0usize), + kcl_source: "someFn()".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/args_with_refs.gen b/src/wasm-lib/derive-docs/tests/args_with_refs.gen index 08b80d4b21..311ecdbb67 100644 --- a/src/wasm-lib/derive-docs/tests/args_with_refs.gen +++ b/src/wasm-lib/derive-docs/tests/args_with_refs.gen @@ -14,9 +14,16 @@ mod test_examples_someFn { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "someFn", 0usize), + kcl_source: "someFn()".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/array.gen b/src/wasm-lib/derive-docs/tests/array.gen index b4016e3b5f..43250ff0cf 100644 --- a/src/wasm-lib/derive-docs/tests/array.gen +++ b/src/wasm-lib/derive-docs/tests/array.gen @@ -15,9 +15,16 @@ mod test_examples_show { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "show", 0usize), + kcl_source: "This is another code block.\nyes sirrr.\nshow".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] @@ -52,9 +59,16 @@ mod test_examples_show { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "show", 1usize), + kcl_source: "This is code.\nIt does other shit.\nshow".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/box.gen b/src/wasm-lib/derive-docs/tests/box.gen index fc220c90d6..a3cb0a3ca6 100644 --- a/src/wasm-lib/derive-docs/tests/box.gen +++ b/src/wasm-lib/derive-docs/tests/box.gen @@ -15,9 +15,16 @@ mod test_examples_show { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "show", 0usize), + kcl_source: "This is code.\nIt does other shit.\nshow".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/doc_comment_with_code.gen b/src/wasm-lib/derive-docs/tests/doc_comment_with_code.gen index 01292dabd5..bfc8b45bcc 100644 --- a/src/wasm-lib/derive-docs/tests/doc_comment_with_code.gen +++ b/src/wasm-lib/derive-docs/tests/doc_comment_with_code.gen @@ -16,9 +16,16 @@ mod test_examples_my_func { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "my_func", 0usize), + kcl_source: "This is another code block.\nyes sirrr.\nmyFunc".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] @@ -53,9 +60,16 @@ mod test_examples_my_func { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "my_func", 1usize), + kcl_source: "This is code.\nIt does other shit.\nmyFunc".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/lineTo.gen b/src/wasm-lib/derive-docs/tests/lineTo.gen index 52b909dcad..81d33ad3d5 100644 --- a/src/wasm-lib/derive-docs/tests/lineTo.gen +++ b/src/wasm-lib/derive-docs/tests/lineTo.gen @@ -16,9 +16,16 @@ mod test_examples_line_to { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "line_to", 0usize), + kcl_source: "This is another code block.\nyes sirrr.\nlineTo".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] @@ -53,9 +60,16 @@ mod test_examples_line_to { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "line_to", 1usize), + kcl_source: "This is code.\nIt does other shit.\nlineTo".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/min.gen b/src/wasm-lib/derive-docs/tests/min.gen index f42a101295..2bdf27b804 100644 --- a/src/wasm-lib/derive-docs/tests/min.gen +++ b/src/wasm-lib/derive-docs/tests/min.gen @@ -15,9 +15,16 @@ mod test_examples_min { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "min", 0usize), + kcl_source: "This is another code block.\nyes sirrr.\nmin".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] @@ -52,9 +59,16 @@ mod test_examples_min { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "min", 1usize), + kcl_source: "This is code.\nIt does other shit.\nmin".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/option.gen b/src/wasm-lib/derive-docs/tests/option.gen index edbec4ca4c..a403385c56 100644 --- a/src/wasm-lib/derive-docs/tests/option.gen +++ b/src/wasm-lib/derive-docs/tests/option.gen @@ -15,9 +15,16 @@ mod test_examples_show { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "show", 0usize), + kcl_source: "This is code.\nIt does other shit.\nshow".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/option_input_format.gen b/src/wasm-lib/derive-docs/tests/option_input_format.gen index 26f56a3abc..8f6db8514d 100644 --- a/src/wasm-lib/derive-docs/tests/option_input_format.gen +++ b/src/wasm-lib/derive-docs/tests/option_input_format.gen @@ -15,9 +15,16 @@ mod test_examples_import { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "import", 0usize), + kcl_source: "This is code.\nIt does other shit.\nimport".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/return_vec_box_sketch.gen b/src/wasm-lib/derive-docs/tests/return_vec_box_sketch.gen index 31c5155ff5..42b89d2a57 100644 --- a/src/wasm-lib/derive-docs/tests/return_vec_box_sketch.gen +++ b/src/wasm-lib/derive-docs/tests/return_vec_box_sketch.gen @@ -15,9 +15,16 @@ mod test_examples_import { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "import", 0usize), + kcl_source: "This is code.\nIt does other shit.\nimport".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/return_vec_sketch.gen b/src/wasm-lib/derive-docs/tests/return_vec_sketch.gen index 2f2d87f1c6..cde6535d98 100644 --- a/src/wasm-lib/derive-docs/tests/return_vec_sketch.gen +++ b/src/wasm-lib/derive-docs/tests/return_vec_sketch.gen @@ -15,9 +15,16 @@ mod test_examples_import { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "import", 0usize), + kcl_source: "This is code.\nIt does other shit.\nimport".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/show.gen b/src/wasm-lib/derive-docs/tests/show.gen index 8ca23679da..dafbd161ac 100644 --- a/src/wasm-lib/derive-docs/tests/show.gen +++ b/src/wasm-lib/derive-docs/tests/show.gen @@ -15,9 +15,16 @@ mod test_examples_show { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "show", 0usize), + kcl_source: "This is code.\nIt does other shit.\nshow".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/derive-docs/tests/test_args_with_exec_state.gen b/src/wasm-lib/derive-docs/tests/test_args_with_exec_state.gen index 428784f1e9..0815683062 100644 --- a/src/wasm-lib/derive-docs/tests/test_args_with_exec_state.gen +++ b/src/wasm-lib/derive-docs/tests/test_args_with_exec_state.gen @@ -14,9 +14,16 @@ mod test_examples_some_function { settings: Default::default(), context_type: crate::execution::ContextType::Mock, }; - ctx.run(program.into(), &mut crate::ExecState::new()) - .await - .unwrap(); + if let Err(e) = ctx.run(program.into(), &mut crate::ExecState::new()).await { + let report = crate::errors::Report { + error: e, + filename: format!("{}{}", "some_function", 0usize), + kcl_source: "someFunction()".to_string(), + }; + let report = miette::Report::new(report); + let report = format!("{:?}", report); + panic!("Miette: {report}"); + } } #[tokio::test(flavor = "multi_thread", worker_threads = 5)] diff --git a/src/wasm-lib/kcl/src/std/appearance.rs b/src/wasm-lib/kcl/src/std/appearance.rs index cb08e95878..bb15350e2a 100644 --- a/src/wasm-lib/kcl/src/std/appearance.rs +++ b/src/wasm-lib/kcl/src/std/appearance.rs @@ -97,7 +97,7 @@ pub async fn appearance(_exec_state: &mut ExecState, args: Args) -> Result line(end = [center[0] + 10, center[1] - 10]) /// |> line(end = [center[0] + 10, center[1] + 10]) /// |> line(end = [center[0] - 10, center[1] + 10]) -/// |> close(%) +/// |> close() /// |> extrude(length = 10) /// } /// diff --git a/src/wasm-lib/kcl/src/std/array.rs b/src/wasm-lib/kcl/src/std/array.rs index 110bad79c1..34cfa7e285 100644 --- a/src/wasm-lib/kcl/src/std/array.rs +++ b/src/wasm-lib/kcl/src/std/array.rs @@ -177,7 +177,7 @@ pub async fn reduce(exec_state: &mut ExecState, args: Args) -> Result close(%) +/// decagon(5.0) |> close() /// ``` #[stdlib { name = "reduce", diff --git a/src/wasm-lib/kcl/src/std/chamfer.rs b/src/wasm-lib/kcl/src/std/chamfer.rs index 9c4d6c864f..fbe6ab1347 100644 --- a/src/wasm-lib/kcl/src/std/chamfer.rs +++ b/src/wasm-lib/kcl/src/std/chamfer.rs @@ -81,7 +81,7 @@ pub async fn chamfer(exec_state: &mut ExecState, args: Args) -> Result close(%, $line1) -/// |> extrude(20, %) +/// |> extrude(20) /// |> chamfer({ /// length = 10, /// tags = [getOppositeEdge(line1)] @@ -93,8 +93,8 @@ pub async fn chamfer(exec_state: &mut ExecState, args: Args) -> Result line([0, 2], %) /// |> line([-2, 0], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) -/// |> extrude(10, %) +/// |> close() +/// |> extrude(10) /// ``` #[stdlib { name = "chamfer", diff --git a/src/wasm-lib/kcl/src/std/convert.rs b/src/wasm-lib/kcl/src/std/convert.rs index 22c851f910..d2471241fb 100644 --- a/src/wasm-lib/kcl/src/std/convert.rs +++ b/src/wasm-lib/kcl/src/std/convert.rs @@ -26,7 +26,7 @@ pub async fn int(_exec_state: &mut ExecState, args: Args) -> Result circle({ center = [0, 0], radius = 2 }, %) -/// |> extrude(5, %) +/// |> extrude(5) /// |> patternTransform(n, fn(id) { /// return { translate = [4 * id, 0, 0] } /// }, %) diff --git a/src/wasm-lib/kcl/src/std/extrude.rs b/src/wasm-lib/kcl/src/std/extrude.rs index 0aa1fa343e..9f136c1940 100644 --- a/src/wasm-lib/kcl/src/std/extrude.rs +++ b/src/wasm-lib/kcl/src/std/extrude.rs @@ -50,8 +50,8 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result line([-5, -2], %) -/// |> close(%) -/// |> extrude(10, %) +/// |> close() +/// |> extrude(10) /// ``` /// /// ```no_run @@ -71,7 +71,7 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result line([-4, 10], %) /// |> line([-5, -2], %) -/// |> close(%) +/// |> close() /// /// example = extrude(10, exampleSketch) /// ``` diff --git a/src/wasm-lib/kcl/src/std/fillet.rs b/src/wasm-lib/kcl/src/std/fillet.rs index 81277303db..ed899a6721 100644 --- a/src/wasm-lib/kcl/src/std/fillet.rs +++ b/src/wasm-lib/kcl/src/std/fillet.rs @@ -212,7 +212,7 @@ pub async fn get_opposite_edge(exec_state: &mut ExecState, args: Args) -> Result /// angle = 240, /// length = 10, /// }, %, $referenceEdge) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// |> fillet({ @@ -285,7 +285,7 @@ pub async fn get_next_adjacent_edge(exec_state: &mut ExecState, args: Args) -> R /// angle = 240, /// length = 10, /// }, %, $referenceEdge) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// |> fillet({ @@ -370,7 +370,7 @@ pub async fn get_previous_adjacent_edge(exec_state: &mut ExecState, args: Args) /// angle = 240, /// length = 10, /// }, %, $referenceEdge) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// |> fillet({ diff --git a/src/wasm-lib/kcl/src/std/helix.rs b/src/wasm-lib/kcl/src/std/helix.rs index e4834e0799..b3af071eab 100644 --- a/src/wasm-lib/kcl/src/std/helix.rs +++ b/src/wasm-lib/kcl/src/std/helix.rs @@ -44,7 +44,7 @@ pub async fn helix(exec_state: &mut ExecState, args: Args) -> Result circle({ center: [5, 5], radius: 10 }, %) -/// |> extrude(10, %) +/// |> extrude(10) /// |> helix({ /// angleStart = 0, /// ccw = true, diff --git a/src/wasm-lib/kcl/src/std/loft.rs b/src/wasm-lib/kcl/src/std/loft.rs index a43bbba0b4..6c116f73d8 100644 --- a/src/wasm-lib/kcl/src/std/loft.rs +++ b/src/wasm-lib/kcl/src/std/loft.rs @@ -55,14 +55,14 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result line([0, -200], %) /// |> line([-200, 0], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) +/// |> close() /// /// triangleSketch = startSketchOn(offsetPlane('XY', 75)) /// |> startProfileAt([0, 125], %) /// |> line([-15, -30], %) /// |> line([30, 0], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) +/// |> close() /// /// loft([squareSketch, triangleSketch]) /// ``` @@ -75,7 +75,7 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result line([0, -200], %) /// |> line([-200, 0], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) +/// |> close() /// /// circleSketch0 = startSketchOn(offsetPlane('XY', 75)) /// |> circle({ center = [0, 100], radius = 50 }, %) @@ -94,7 +94,7 @@ pub async fn loft(exec_state: &mut ExecState, args: Args) -> Result line([0, -200], %) /// |> line([-200, 0], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) +/// |> close() /// /// circleSketch0 = startSketchOn(offsetPlane('XY', 75)) /// |> circle({ center = [0, 100], radius = 50 }, %) diff --git a/src/wasm-lib/kcl/src/std/math.rs b/src/wasm-lib/kcl/src/std/math.rs index b4055eb97a..6a70807d5e 100644 --- a/src/wasm-lib/kcl/src/std/math.rs +++ b/src/wasm-lib/kcl/src/std/math.rs @@ -61,7 +61,7 @@ pub async fn cos(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -91,7 +91,7 @@ pub async fn sin(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -121,7 +121,7 @@ pub async fn tan(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -176,7 +176,7 @@ pub async fn sqrt(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -213,7 +213,7 @@ pub async fn abs(_exec_state: &mut ExecState, args: Args) -> Result close(%) +/// |> close() /// /// baseExtrusion = extrude(5, sketch001) /// ``` @@ -241,7 +241,7 @@ pub async fn round(_exec_state: &mut ExecState, args: Args) -> Result lineTo([12, 10], %) /// |> line([round(7.02986), 0], %) /// |> yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// extrude001 = extrude(5, sketch001) /// ``` @@ -269,7 +269,7 @@ pub async fn floor(_exec_state: &mut ExecState, args: Args) -> Result lineTo([12, 10], %) /// |> line([floor(7.02986), 0], %) /// |> yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// extrude001 = extrude(5, sketch001) /// ``` @@ -297,7 +297,7 @@ pub async fn ceil(_exec_state: &mut ExecState, args: Args) -> Result lineTo([12, 10], %) /// |> line([ceil(7.02986), 0], %) /// |> yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// extrude001 = extrude(5, sketch001) /// ``` @@ -327,7 +327,7 @@ pub async fn min(_exec_state: &mut ExecState, args: Args) -> Result line([20, 0], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -364,7 +364,7 @@ pub async fn max(_exec_state: &mut ExecState, args: Args) -> Result line([20, 0], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -415,7 +415,7 @@ pub async fn pow(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -446,7 +446,7 @@ pub async fn acos(_exec_state: &mut ExecState, args: Args) -> Result line([5, 0], %) /// |> lineTo([12, 0], %) -/// |> close(%) +/// |> close() /// /// extrude001 = extrude(5, sketch001) /// ``` @@ -476,7 +476,7 @@ pub async fn asin(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// extrude001 = extrude(5, sketch001) /// ``` @@ -506,7 +506,7 @@ pub async fn atan(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// extrude001 = extrude(5, sketch001) /// ``` @@ -536,7 +536,7 @@ pub async fn atan2(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// extrude001 = extrude(5, sketch001) /// ``` @@ -585,7 +585,7 @@ pub async fn log(_exec_state: &mut ExecState, args: Args) -> Result line([log(100, 5), 0], %) /// |> line([5, 8], %) /// |> line([-10, 0], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -613,7 +613,7 @@ pub async fn log2(_exec_state: &mut ExecState, args: Args) -> Result line([log2(100), 0], %) /// |> line([5, 8], %) /// |> line([-10, 0], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -641,7 +641,7 @@ pub async fn log10(_exec_state: &mut ExecState, args: Args) -> Result line([log10(100), 0], %) /// |> line([5, 8], %) /// |> line([-10, 0], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -669,7 +669,7 @@ pub async fn ln(_exec_state: &mut ExecState, args: Args) -> Result line([ln(100), 15], %) /// |> line([5, -6], %) /// |> line([-10, -10], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -698,7 +698,7 @@ pub async fn e(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// example = extrude(10, exampleSketch) /// ``` @@ -727,7 +727,7 @@ pub async fn tau(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -757,7 +757,7 @@ pub async fn to_radians(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -787,7 +787,7 @@ pub async fn to_degrees(_exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` diff --git a/src/wasm-lib/kcl/src/std/patterns.rs b/src/wasm-lib/kcl/src/std/patterns.rs index 8833c354fc..cb7d1df6ed 100644 --- a/src/wasm-lib/kcl/src/std/patterns.rs +++ b/src/wasm-lib/kcl/src/std/patterns.rs @@ -153,7 +153,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res /// // Sketch 4 cylinders. /// sketch001 = startSketchOn('XZ') /// |> circle({ center = [0, 0], radius = 2 }, %) -/// |> extrude(5, %) +/// |> extrude(5) /// |> patternTransform(4, transform, %) /// ``` /// ```no_run @@ -166,7 +166,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res /// /// sketch001 = startSketchOn('XZ') /// |> circle({ center = [0, 0], radius = 2 }, %) -/// |> extrude(5, %) +/// |> extrude(5) /// |> patternTransform(4, transform, %) /// ``` /// ```no_run @@ -184,8 +184,8 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res /// |> lineTo(p2, %) /// |> lineTo(p3, %) /// |> lineTo(p0, %) -/// |> close(%) -/// |> extrude(length, %) +/// |> close() +/// |> extrude(length) /// } /// /// width = 20 @@ -223,8 +223,8 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res /// |> lineTo(p2, %) /// |> lineTo(p3, %) /// |> lineTo(p0, %) -/// |> close(%) -/// |> extrude(length, %) +/// |> close() +/// |> extrude(length) /// } /// /// width = 20 @@ -260,7 +260,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res /// fn layer() { /// return startSketchOn("XY") // or some other plane idk /// |> circle({ center = [0, 0], radius = 1 }, %, $tag1) -/// |> extrude(h, %) +/// |> extrude(h) /// } /// // The vase is 100 layers tall. /// // The 100 layers are replica of each other, with a slight transformation applied to each. @@ -281,7 +281,7 @@ pub async fn pattern_transform_2d(exec_state: &mut ExecState, args: Args) -> Res /// center: [0, 0], /// inscribed: false /// }, %) -/// |> extrude(4, %) +/// |> extrude(4) /// |> patternTransform(3, transform, %) /// ``` #[stdlib { @@ -752,7 +752,7 @@ pub async fn pattern_linear_3d(exec_state: &mut ExecState, args: Args) -> Result /// |> line([0, 2], %) /// |> line([3, 1], %) /// |> line([0, -4], %) -/// |> close(%) +/// |> close() /// /// example = extrude(1, exampleSketch) /// |> patternLinear3d({ @@ -907,7 +907,7 @@ pub async fn pattern_circular_2d(exec_state: &mut ExecState, args: Args) -> Resu /// |> line([0, 5], %) /// |> line([-1, 0], %) /// |> line([0, -5], %) -/// |> close(%) +/// |> close() /// |> patternCircular2d({ /// center = [0, 0], /// instances = 13, diff --git a/src/wasm-lib/kcl/src/std/planes.rs b/src/wasm-lib/kcl/src/std/planes.rs index bc6c35e51b..185343b3b5 100644 --- a/src/wasm-lib/kcl/src/std/planes.rs +++ b/src/wasm-lib/kcl/src/std/planes.rs @@ -71,7 +71,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result line([0, -200], %) /// |> line([-200, 0], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) +/// |> close() /// /// circleSketch = startSketchOn(offsetPlane('XY', 150)) /// |> circle({ center = [0, 100], radius = 50 }, %) @@ -87,7 +87,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result line([0, -200], %) /// |> line([-200, 0], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) +/// |> close() /// /// circleSketch = startSketchOn(offsetPlane('XZ', 150)) /// |> circle({ center = [0, 100], radius = 50 }, %) @@ -103,7 +103,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result line([0, -200], %) /// |> line([-200, 0], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) +/// |> close() /// /// circleSketch = startSketchOn(offsetPlane('YZ', 150)) /// |> circle({ center = [0, 100], radius = 50 }, %) @@ -119,7 +119,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result line([0, -200], %) /// |> line([-200, 0], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) +/// |> close() /// /// circleSketch = startSketchOn(offsetPlane('-XZ', -150)) /// |> circle({ center = [0, 100], radius = 50 }, %) @@ -137,7 +137,7 @@ pub async fn offset_plane(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([0, 0], %) /// |> line([10, 0], %) /// |> line([0, 10], %) -/// |> close(%) +/// |> close() /// ``` #[stdlib { diff --git a/src/wasm-lib/kcl/src/std/polar.rs b/src/wasm-lib/kcl/src/std/polar.rs index e559b85732..80eacf4048 100644 --- a/src/wasm-lib/kcl/src/std/polar.rs +++ b/src/wasm-lib/kcl/src/std/polar.rs @@ -40,7 +40,7 @@ pub async fn polar(_exec_state: &mut ExecState, args: Args) -> Result line([0, 5], %) /// |> line([segEndX(thing), 0], %) /// |> line([-20, 10], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` diff --git a/src/wasm-lib/kcl/src/std/revolve.rs b/src/wasm-lib/kcl/src/std/revolve.rs index e617153e79..e84dfccbe0 100644 --- a/src/wasm-lib/kcl/src/std/revolve.rs +++ b/src/wasm-lib/kcl/src/std/revolve.rs @@ -122,7 +122,7 @@ pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result line([-3.75, -4.5], %) /// |> line([0, -5.5], %) /// |> line([-2, 0], %) -/// |> close(%) +/// |> close() /// |> revolve({axis = 'y'}, %) // default angle is 360 /// ``` /// @@ -146,7 +146,7 @@ pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result line([-3.75, -4.5], %) /// |> line([0, -5.5], %) /// |> line([-2, 0], %) -/// |> close(%) +/// |> close() /// |> revolve({axis = 'y', angle = 180}, %) /// ``` /// @@ -160,15 +160,15 @@ pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result line([-3.75, -4.5], %) /// |> line([0, -5.5], %) /// |> line([-2, 0], %) -/// |> close(%) +/// |> close() /// |> revolve({axis = 'y', angle = 180}, %) /// part002 = startSketchOn(part001, 'end') /// |> startProfileAt([4.5, -5], %) /// |> line([0, 5], %) /// |> line([5, 0], %) /// |> line([0, -5], %) -/// |> close(%) -/// |> extrude(5, %) +/// |> close() +/// |> extrude(5) /// ``` /// /// ```no_run @@ -177,8 +177,8 @@ pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result line([0, 20], %) /// |> line([20, 0], %) /// |> line([0, -20], %) -/// |> close(%) -/// |> extrude(20, %) +/// |> close() +/// |> extrude(20) /// /// sketch001 = startSketchOn(box, "END") /// |> circle({ center = [10,10], radius = 4 }, %) @@ -194,8 +194,8 @@ pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result line([0, 20], %) /// |> line([20, 0], %) /// |> line([0, -20], %, $revolveAxis) -/// |> close(%) -/// |> extrude(20, %) +/// |> close() +/// |> extrude(20) /// /// sketch001 = startSketchOn(box, "END") /// |> circle({ center = [10,10], radius = 4 }, %) @@ -211,8 +211,8 @@ pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result line([0, 20], %) /// |> line([20, 0], %) /// |> line([0, -20], %, $revolveAxis) -/// |> close(%) -/// |> extrude(20, %) +/// |> close() +/// |> extrude(20) /// /// sketch001 = startSketchOn(box, "END") /// |> circle({ center = [10,10], radius = 4 }, %) @@ -229,7 +229,7 @@ pub async fn revolve(exec_state: &mut ExecState, args: Args) -> Result line([5, -5], %) /// |> line([5, 5], %) /// |> lineTo([profileStartX(%), profileStartY(%)], %) -/// |> close(%) +/// |> close() /// /// part001 = revolve({ /// axis = { diff --git a/src/wasm-lib/kcl/src/std/segment.rs b/src/wasm-lib/kcl/src/std/segment.rs index 2e4b706aa3..b5484d4a73 100644 --- a/src/wasm-lib/kcl/src/std/segment.rs +++ b/src/wasm-lib/kcl/src/std/segment.rs @@ -27,13 +27,13 @@ pub async fn segment_end(exec_state: &mut ExecState, args: Args) -> Result line([0, w], %, $line2) /// |> line([-w, 0], %, $line3) /// |> line([0, -w], %, $line4) -/// |> close(%) -/// |> extrude(5, %) +/// |> close() +/// |> extrude(5) /// /// fn cylinder(radius, tag) { /// return startSketchAt([0, 0]) /// |> circle({ radius = radius, center = segEnd(tag) }, %) -/// |> extrude(radius, %) +/// |> extrude(radius) /// } /// /// cylinder(1, line1) @@ -73,7 +73,7 @@ pub async fn segment_end_x(exec_state: &mut ExecState, args: Args) -> Result line([0, 5], %) /// |> line([segEndX(thing), 0], %) /// |> line([-20, 10], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -110,7 +110,7 @@ pub async fn segment_end_y(exec_state: &mut ExecState, args: Args) -> Result line([-10, 0], %) /// |> line([0, segEndY(thing)], %) /// |> line([-10, 0], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -146,13 +146,13 @@ pub async fn segment_start(exec_state: &mut ExecState, args: Args) -> Result line([0, w], %, $line2) /// |> line([-w, 0], %, $line3) /// |> line([0, -w], %, $line4) -/// |> close(%) -/// |> extrude(5, %) +/// |> close() +/// |> extrude(5) /// /// fn cylinder(radius, tag) { /// return startSketchAt([0, 0]) /// |> circle({ radius = radius, center = segStart(tag) }, %) -/// |> extrude(radius, %) +/// |> extrude(radius) /// } /// /// cylinder(1, line1) @@ -192,7 +192,7 @@ pub async fn segment_start_x(exec_state: &mut ExecState, args: Args) -> Result line([0, 5], %) /// |> line([20 - segStartX(thing), 0], %) /// |> line([-20, 10], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -229,7 +229,7 @@ pub async fn segment_start_y(exec_state: &mut ExecState, args: Args) -> Result line([-10, 0], %) /// |> line([0, 20-segStartY(thing)], %) /// |> line([-10, 0], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -265,7 +265,7 @@ pub async fn last_segment_x(_exec_state: &mut ExecState, args: Args) -> Result line([20, 5], %) /// |> line([lastSegX(%), 0], %) /// |> line([-15, 0], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -305,7 +305,7 @@ pub async fn last_segment_y(_exec_state: &mut ExecState, args: Args) -> Result line([20, 5], %) /// |> line([0, lastSegY(%)], %) /// |> line([-15, 0], %) -/// |> close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -351,7 +351,7 @@ pub async fn segment_length(exec_state: &mut ExecState, args: Args) -> Result close(%) +/// |> close() /// /// example = extrude(5, exampleSketch) /// ``` @@ -391,7 +391,7 @@ pub async fn segment_angle(exec_state: &mut ExecState, args: Args) -> Result angledLine([segAng(seg01), 10], %) /// |> line([-10, 0], %) /// |> angledLine([segAng(seg01), -15], %) -/// |> close(%) +/// |> close() /// /// example = extrude(4, exampleSketch) /// ``` @@ -433,7 +433,7 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result tangentialArcToRelative([0, -10], %) -/// |> close(%) +/// |> close() /// /// pillExtrude = extrude(10, pillSketch) /// ``` @@ -449,7 +449,7 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result tangentialArcToRelative([-10, 0], %) -/// |> close(%) +/// |> close() /// /// pillExtrude = extrude(10, pillSketch) /// ``` @@ -464,7 +464,7 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result line([0, 10], %) /// |> line([-20, 0], %) -/// |> close(%) +/// |> close() /// /// rectangleExtrude = extrude(10, rectangleSketch) /// ``` @@ -477,7 +477,7 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result angledLine([tangentToEnd(arc1), 20], %) -/// |> close(%) +/// |> close() /// ``` /// /// ```no_run @@ -488,7 +488,7 @@ pub async fn tangent_to_end(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([-5, 0], %) /// |> angledLine([tangentToEnd(circ), 10], %) /// |> line([-15, 0], %) -/// |> close(%) +/// |> close() /// ``` #[stdlib { name = "tangentToEnd", @@ -535,7 +535,7 @@ pub async fn angle_to_match_length_x(exec_state: &mut ExecState, args: Args) -> /// -angleToMatchLengthX(seg01, 7, %), /// 10 /// ], %) -/// |> close(%) +/// |> close() /// /// extrusion = extrude(5, sketch001) /// ``` @@ -599,7 +599,7 @@ pub async fn angle_to_match_length_y(exec_state: &mut ExecState, args: Args) -> /// length = 5, /// }, %) /// |> yLineTo(0, %) -/// |> close(%) +/// |> close() /// /// extrusion = extrude(5, sketch001) /// ``` diff --git a/src/wasm-lib/kcl/src/std/shapes.rs b/src/wasm-lib/kcl/src/std/shapes.rs index 1aca88cbef..bf8c898a2e 100644 --- a/src/wasm-lib/kcl/src/std/shapes.rs +++ b/src/wasm-lib/kcl/src/std/shapes.rs @@ -68,7 +68,7 @@ pub async fn circle(exec_state: &mut ExecState, args: Args) -> Result line([30, 0], %) /// |> line([0, 30], %) /// |> line([-30, 0], %) -/// |> close(%) +/// |> close() /// |> hole(circle({ center = [0, 15], radius = 5 }, %), %) /// /// example = extrude(5, exampleSketch) diff --git a/src/wasm-lib/kcl/src/std/shell.rs b/src/wasm-lib/kcl/src/std/shell.rs index 68762ed432..f76da3d488 100644 --- a/src/wasm-lib/kcl/src/std/shell.rs +++ b/src/wasm-lib/kcl/src/std/shell.rs @@ -43,8 +43,8 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result line([24, 0], %) /// |> line([0, -24], %) /// |> line([-24, 0], %) -/// |> close(%) -/// |> extrude(6, %) +/// |> close() +/// |> extrude(6) /// /// // Remove the end face for the extrusion. /// shell({ @@ -60,8 +60,8 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result line([24, 0], %) /// |> line([0, -24], %) /// |> line([-24, 0], %) -/// |> close(%) -/// |> extrude(6, %) +/// |> close() +/// |> extrude(6) /// /// // Remove the start face for the extrusion. /// shell({ @@ -77,8 +77,8 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result line([24, 0], %) /// |> line([0, -24], %) /// |> line([-24, 0], %, $myTag) -/// |> close(%) -/// |> extrude(6, %) +/// |> close() +/// |> extrude(6) /// /// // Remove a tagged face for the extrusion. /// shell({ @@ -94,8 +94,8 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result line([24, 0], %) /// |> line([0, -24], %) /// |> line([-24, 0], %, $myTag) -/// |> close(%) -/// |> extrude(6, %) +/// |> close() +/// |> extrude(6) /// /// // Remove a tagged face and the end face for the extrusion. /// shell({ @@ -112,16 +112,16 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result line([2 * size, 0], %) /// |> line([0, 2 * size], %) /// |> tangentialArcTo([-size, size], %) -/// |> close(%) -/// |> extrude(65, %) +/// |> close() +/// |> extrude(65) /// /// thing1 = startSketchOn(case, 'end') /// |> circle({ center = [-size / 2, -size / 2], radius = 25 }, %) -/// |> extrude(50, %) +/// |> extrude(50) /// /// thing2 = startSketchOn(case, 'end') /// |> circle({ center = [size / 2, -size / 2], radius = 25 }, %) -/// |> extrude(50, %) +/// |> extrude(50) /// /// // We put "case" in the shell function to shell the entire object. /// shell({ faces = ['start'], thickness = 5 }, case) @@ -135,16 +135,16 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result line([2 * size, 0], %) /// |> line([0, 2 * size], %) /// |> tangentialArcTo([-size, size], %) -/// |> close(%) -/// |> extrude(65, %) +/// |> close() +/// |> extrude(65) /// /// thing1 = startSketchOn(case, 'end') /// |> circle({ center = [-size / 2, -size / 2], radius = 25 }, %) -/// |> extrude(50, %) +/// |> extrude(50) /// /// thing2 = startSketchOn(case, 'end') /// |> circle({ center = [size / 2, -size / 2], radius = 25 }, %) -/// |> extrude(50, %) +/// |> extrude(50) /// /// // We put "thing1" in the shell function to shell the end face of the object. /// shell({ faces = ['end'], thickness = 5 }, thing1) @@ -160,16 +160,16 @@ pub async fn shell(exec_state: &mut ExecState, args: Args) -> Result line([2 * size, 0], %) /// |> line([0, 2 * size], %) /// |> tangentialArcTo([-size, size], %) -/// |> close(%) -/// |> extrude(65, %) +/// |> close() +/// |> extrude(65) /// /// thing1 = startSketchOn(case, 'end') /// |> circle({ center = [-size / 2, -size / 2], radius = 25 }, %) -/// |> extrude(50, %) +/// |> extrude(50) /// /// thing2 = startSketchOn(case, 'end') /// |> circle({ center = [size / 2, -size / 2], radius = 25 }, %) -/// |> extrude(50, %) +/// |> extrude(50) /// /// // We put "thing1" and "thing2" in the shell function to shell the end face of the object. /// shell({ faces = ['end'], thickness = 5 }, [thing1, thing2]) @@ -263,8 +263,8 @@ pub async fn hollow(exec_state: &mut ExecState, args: Args) -> Result line([24, 0], %) /// |> line([0, -24], %) /// |> line([-24, 0], %) -/// |> close(%) -/// |> extrude(6, %) +/// |> close() +/// |> extrude(6) /// |> hollow (0.25, %) /// ``` /// @@ -275,8 +275,8 @@ pub async fn hollow(exec_state: &mut ExecState, args: Args) -> Result line([24, 0], %) /// |> line([0, -24], %) /// |> line([-24, 0], %) -/// |> close(%) -/// |> extrude(6, %) +/// |> close() +/// |> extrude(6) /// |> hollow (0.5, %) /// ``` /// @@ -288,16 +288,16 @@ pub async fn hollow(exec_state: &mut ExecState, args: Args) -> Result line([2 * size, 0], %) /// |> line([0, 2 * size], %) /// |> tangentialArcTo([-size, size], %) -/// |> close(%) -/// |> extrude(65, %) +/// |> close() +/// |> extrude(65) /// /// thing1 = startSketchOn(case, 'end') /// |> circle({ center = [-size / 2, -size / 2], radius = 25 }, %) -/// |> extrude(50, %) +/// |> extrude(50) /// /// thing2 = startSketchOn(case, 'end') /// |> circle({ center = [size / 2, -size / 2], radius = 25 }, %) -/// |> extrude(50, %) +/// |> extrude(50) /// /// hollow(0.5, case) /// ``` diff --git a/src/wasm-lib/kcl/src/std/sketch.rs b/src/wasm-lib/kcl/src/std/sketch.rs index df937496c5..ba2325c992 100644 --- a/src/wasm-lib/kcl/src/std/sketch.rs +++ b/src/wasm-lib/kcl/src/std/sketch.rs @@ -110,14 +110,27 @@ pub async fn line(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([0, 0], %) +/// // The 'end' argument means it ends at exactly [10, 0]. +/// // This is an absolute measurement, it is NOT relative to +/// // the start of the sketch. /// |> line(end = [10, 0]) /// |> line(end = [0, 10]) /// |> line(end = [-10, 0], tag = "thirdLineOfBox") -/// |> close(%) +/// |> close() +/// |> extrude(length = 5) +/// +/// box = startSketchOn("XZ") +/// |> startProfileAt([10, 10], %) +/// // The 'to' argument means move the pen this much. +/// // So, [10, 0] is a relative distance away from the current point. +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10]) +/// |> line(to = [-10, 0], tag = "thirdLineOfBox") +/// |> close() +/// |> extrude(length = 5) /// -/// example = extrude(5, exampleSketch) /// ``` #[stdlib { name = "line", @@ -253,16 +266,16 @@ pub async fn x_line_to(exec_state: &mut ExecState, args: Args) -> Result line([8, -10], %) +/// |> line(to = [8, -10]) /// |> xLineTo(40, %) /// |> angledLine({ /// angle = 135, /// length = 30, /// }, %) /// |> xLineTo(10, %) -/// |> close(%) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "xLineTo", @@ -308,9 +321,9 @@ pub async fn y_line_to(exec_state: &mut ExecState, args: Args) -> Result yLineTo(0, %) -/// |> close(%) +/// |> close() /// -/// example = extrude(5, exampleSketch) +/// example = extrude(exampleSketch, length = 5) /// ``` #[stdlib { name = "yLineTo", @@ -354,16 +367,16 @@ pub async fn x_line(exec_state: &mut ExecState, args: Args) -> Result line([8, -10], %) +/// |> line(to = [8, -10]) /// |> xLine(10, %) /// |> angledLine({ /// angle = 120, /// length = 30, /// }, %) /// |> xLine(-15, %) -/// |> close(%) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "xLine", @@ -399,11 +412,11 @@ pub async fn y_line(exec_state: &mut ExecState, args: Args) -> Result line([8, -10], %) +/// |> line(to = [8, -10]) /// |> yLine(-5, %) -/// |> close(%) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "yLine", @@ -465,11 +478,11 @@ pub async fn angled_line(exec_state: &mut ExecState, args: Args) -> Result line([8, -10], %) +/// |> line(to = [8, -10]) /// |> yLineTo(0, %) -/// |> close(%) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "angledLine", @@ -549,10 +562,10 @@ pub async fn angled_line_of_x_length(exec_state: &mut ExecState, args: Args) -> /// |> startProfileAt([0, 0], %) /// |> angledLineOfXLength({ angle = 45, length = 10 }, %, $edge1) /// |> angledLineOfXLength({ angle = -15, length = 20 }, %, $edge2) -/// |> line([0, -5], %) -/// |> close(%, $edge3) +/// |> line(to = [0, -5]) +/// |> close(tag = $edge3) /// -/// extrusion = extrude(10, sketch001) +/// extrusion = extrude(sketch001, length = 10) /// ``` #[stdlib { name = "angledLineOfXLength", @@ -619,11 +632,11 @@ pub async fn angled_line_to_x(exec_state: &mut ExecState, args: Args) -> Result< /// exampleSketch = startSketchOn('XZ') /// |> startProfileAt([0, 0], %) /// |> angledLineToX({ angle = 30, to = 10 }, %) -/// |> line([0, 10], %) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [0, 10]) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "angledLineToX", @@ -682,14 +695,14 @@ pub async fn angled_line_of_y_length(exec_state: &mut ExecState, args: Args) -> /// ```no_run /// exampleSketch = startSketchOn('XZ') /// |> startProfileAt([0, 0], %) -/// |> line([10, 0], %) +/// |> line(to = [10, 0]) /// |> angledLineOfYLength({ angle = 45, length = 10 }, %) -/// |> line([0, 10], %) +/// |> line(to = [0, 10]) /// |> angledLineOfYLength({ angle = 135, length = 10 }, %) -/// |> line([-10, 0], %) -/// |> line([0, -30], %) +/// |> line(to = [-10, 0]) +/// |> line(to = [0, -30]) /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "angledLineOfYLength", @@ -745,11 +758,11 @@ pub async fn angled_line_to_y(exec_state: &mut ExecState, args: Args) -> Result< /// exampleSketch = startSketchOn('XZ') /// |> startProfileAt([0, 0], %) /// |> angledLineToY({ angle = 60, to = 20 }, %) -/// |> line([-20, 0], %) +/// |> line(to = [-20, 0]) /// |> angledLineToY({ angle = 70, to = 10 }, %) -/// |> close(%) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "angledLineToY", @@ -822,17 +835,17 @@ pub async fn angled_line_that_intersects(exec_state: &mut ExecState, args: Args) /// ```no_run /// exampleSketch = startSketchOn('XZ') /// |> startProfileAt([0, 0], %) -/// |> lineTo([5, 10], %) -/// |> lineTo([-10, 10], %, $lineToIntersect) -/// |> lineTo([0, 20], %) +/// |> line(end = [5, 10]) +/// |> line(end = [-10, 10], tag = $lineToIntersect) +/// |> line(end = [0, 20]) /// |> angledLineThatIntersects({ /// angle = 80, /// intersectTag = lineToIntersect, /// offset = 10 /// }, %) -/// |> close(%) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "angledLineThatIntersects", @@ -878,32 +891,32 @@ pub async fn start_sketch_at(exec_state: &mut ExecState, args: Args) -> Result line([10, 0], %) -/// |> line([0, 10], %) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10]) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(5, exampleSketch) +/// example = extrude(exampleSketch, length = 5) /// ``` /// /// ```no_run /// exampleSketch = startSketchAt([10, 10]) -/// |> line([10, 0], %) -/// |> line([0, 10], %) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10]) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(5, exampleSketch) +/// example = extrude(exampleSketch, length = 5) /// ``` /// /// ```no_run /// exampleSketch = startSketchAt([-10, 23]) -/// |> line([10, 0], %) -/// |> line([0, 10], %) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10]) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(5, exampleSketch) +/// example = extrude(exampleSketch, length = 5) /// ``` #[stdlib { name = "startSketchAt", @@ -981,83 +994,83 @@ pub async fn start_sketch_on(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([0, 0], %) -/// |> line([10, 0], %) -/// |> line([0, 10], %) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10]) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(5, exampleSketch) +/// example = extrude(exampleSketch, length = 5) /// /// exampleSketch002 = startSketchOn(example, 'end') /// |> startProfileAt([1, 1], %) -/// |> line([8, 0], %) -/// |> line([0, 8], %) -/// |> line([-8, 0], %) -/// |> close(%) +/// |> line(to = [8, 0]) +/// |> line(to = [0, 8]) +/// |> line(to = [-8, 0]) +/// |> close() /// -/// example002 = extrude(5, exampleSketch002) +/// example002 = extrude(exampleSketch002, length = 5) /// /// exampleSketch003 = startSketchOn(example002, 'end') /// |> startProfileAt([2, 2], %) -/// |> line([6, 0], %) -/// |> line([0, 6], %) -/// |> line([-6, 0], %) -/// |> close(%) +/// |> line(to = [6, 0]) +/// |> line(to = [0, 6]) +/// |> line(to = [-6, 0]) +/// |> close() /// -/// example003 = extrude(5, exampleSketch003) +/// example003 = extrude(exampleSketch003, length = 5) /// ``` /// /// ```no_run /// exampleSketch = startSketchOn("XY") /// |> startProfileAt([0, 0], %) -/// |> line([10, 0], %) -/// |> line([0, 10], %, $sketchingFace) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10], tag = $sketchingFace) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// /// exampleSketch002 = startSketchOn(example, sketchingFace) /// |> startProfileAt([1, 1], %) -/// |> line([8, 0], %) -/// |> line([0, 8], %) -/// |> line([-8, 0], %) -/// |> close(%, $sketchingFace002) +/// |> line(to = [8, 0]) +/// |> line(to = [0, 8]) +/// |> line(to = [-8, 0]) +/// |> close(tag = $sketchingFace002) /// -/// example002 = extrude(10, exampleSketch002) +/// example002 = extrude(exampleSketch002, length = 10) /// /// exampleSketch003 = startSketchOn(example002, sketchingFace002) /// |> startProfileAt([-8, 12], %) -/// |> line([0, 6], %) -/// |> line([6, 0], %) -/// |> line([0, -6], %) -/// |> close(%) +/// |> line(to = [0, 6]) +/// |> line(to = [6, 0]) +/// |> line(to = [0, -6]) +/// |> close() /// -/// example003 = extrude(5, exampleSketch003) +/// example003 = extrude(exampleSketch003, length = 5) /// ``` /// /// ```no_run /// exampleSketch = startSketchOn('XY') /// |> startProfileAt([4, 12], %) -/// |> line([2, 0], %) -/// |> line([0, -6], %) -/// |> line([4, -6], %) -/// |> line([0, -6], %) -/// |> line([-3.75, -4.5], %) -/// |> line([0, -5.5], %) -/// |> line([-2, 0], %) -/// |> close(%) +/// |> line(to = [2, 0]) +/// |> line(to = [0, -6]) +/// |> line(to = [4, -6]) +/// |> line(to = [0, -6]) +/// |> line(to = [-3.75, -4.5]) +/// |> line(to = [0, -5.5]) +/// |> line(to = [-2, 0]) +/// |> close() /// /// example = revolve({ axis: 'y', angle: 180 }, exampleSketch) /// /// exampleSketch002 = startSketchOn(example, 'end') /// |> startProfileAt([4.5, -5], %) -/// |> line([0, 5], %) -/// |> line([5, 0], %) -/// |> line([0, -5], %) -/// |> close(%) +/// |> line(to = [0, 5]) +/// |> line(to = [5, 0]) +/// |> line(to = [0, -5]) +/// |> close() /// -/// example002 = extrude(5, exampleSketch002) +/// example002 = extrude(exampleSketch002, length = 5) /// ``` /// /// ```no_run @@ -1070,12 +1083,12 @@ pub async fn start_sketch_on(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([0, 0], %) -/// |> line([100.0, 0], %) +/// |> line(to = [100.0, 0]) /// |> yLine(-100.0, %) /// |> xLine(-100.0, %) /// |> yLine(100.0, %) -/// |> close(%) -/// |> extrude(3.14, %) +/// |> close() +/// |> extrude(length = 3.14) /// ``` #[stdlib { name = "startSketchOn", @@ -1198,34 +1211,34 @@ pub async fn start_profile_at(exec_state: &mut ExecState, args: Args) -> Result< /// ```no_run /// exampleSketch = startSketchOn('XZ') /// |> startProfileAt([0, 0], %) -/// |> line([10, 0], %) -/// |> line([0, 10], %) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10]) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(5, exampleSketch) +/// example = extrude(exampleSketch, length = 5) /// ``` /// /// ```no_run /// exampleSketch = startSketchOn('-XZ') /// |> startProfileAt([10, 10], %) -/// |> line([10, 0], %) -/// |> line([0, 10], %) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10]) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(5, exampleSketch) +/// example = extrude(exampleSketch, length = 5) /// ``` /// /// ```no_run /// exampleSketch = startSketchOn('-XZ') /// |> startProfileAt([-10, 23], %) -/// |> line([10, 0], %) -/// |> line([0, 10], %) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10]) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(5, exampleSketch) +/// example = extrude(exampleSketch, length = 5) /// ``` #[stdlib { name = "startProfileAt", @@ -1390,9 +1403,9 @@ pub async fn profile_start(_exec_state: &mut ExecState, args: Args) -> Result startProfileAt([5, 2], %) /// |> angledLine({ angle = 120, length = 50 }, %, $seg01) /// |> angledLine({ angle = segAng(seg01) + 120, length = 50 }, %) -/// |> lineTo(profileStart(%), %) -/// |> close(%) -/// |> extrude(20, %) +/// |> line(%, to = profileStart(%)) +/// |> close() +/// |> extrude(length = 20) /// ``` #[stdlib { name = "profileStart" @@ -1417,20 +1430,20 @@ pub async fn close(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([0, 0], %) -/// |> line([10, 10]) -/// |> line([10, 0]) +/// |> line(to = [10, 10]) +/// |> line(to = [10, 0]) /// |> close() -/// |> extrude(10, %) +/// |> extrude(length = 10) /// ``` /// /// ```no_run /// exampleSketch = startSketchOn('-XZ') /// |> startProfileAt([0, 0], %) -/// |> line(end = [10, 0]) -/// |> line(end = [0, 10]) +/// |> line(to = [10, 0]) +/// |> line(to = [0, 10]) /// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "close", @@ -1550,14 +1563,14 @@ pub async fn arc(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([0, 0], %) -/// |> line([10, 0], %) +/// |> line(to = [10, 0]) /// |> arc({ /// angleStart = 0, /// angleEnd = 280, /// radius = 16 /// }, %) -/// |> close(%) -/// example = extrude(10, exampleSketch) +/// |> close() +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "arc", @@ -1661,8 +1674,8 @@ pub async fn arc_to(exec_state: &mut ExecState, args: Args) -> Result close(%) -/// example = extrude(10, exampleSketch) +/// |> close() +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "arcTo", @@ -1802,9 +1815,9 @@ pub async fn tangential_arc(exec_state: &mut ExecState, args: Args) -> Result close(%) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "tangentialArc", @@ -1931,10 +1944,10 @@ pub async fn tangential_arc_to_relative(exec_state: &mut ExecState, args: Args) /// length = 10, /// }, %) /// |> tangentialArcTo([15, 15], %) -/// |> line([10, -15], %) -/// |> close(%) +/// |> line(to = [10, -15]) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "tangentialArcTo", @@ -1997,10 +2010,10 @@ async fn inner_tangential_arc_to( /// length = 10, /// }, %) /// |> tangentialArcToRelative([0, -10], %) -/// |> line([-10, 0], %) -/// |> close(%) +/// |> line(to = [-10, 0]) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "tangentialArcToRelative", @@ -2134,16 +2147,16 @@ pub async fn bezier_curve(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([0, 0], %) -/// |> line([0, 10], %) +/// |> line(to = [0, 10]) /// |> bezierCurve({ /// to = [10, 10], /// control1 = [5, 0], /// control2 = [5, 10] /// }, %) -/// |> lineTo([10, 0], %) -/// |> close(%) +/// |> line(end = [10, 0]) +/// |> close() /// -/// example = extrude(10, exampleSketch) +/// example = extrude(exampleSketch, length = 10) /// ``` #[stdlib { name = "bezierCurve", @@ -2214,31 +2227,31 @@ pub async fn hole(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([0, 0], %) -/// |> line([0, 5], %) -/// |> line([5, 0], %) -/// |> line([0, -5], %) -/// |> close(%) +/// |> line(to = [0, 5]) +/// |> line(to = [5, 0]) +/// |> line(to = [0, -5]) +/// |> close() /// |> hole(circle({ center = [1, 1], radius = .25 }, %), %) /// |> hole(circle({ center = [1, 4], radius = .25 }, %), %) /// -/// example = extrude(1, exampleSketch) +/// example = extrude(exampleSketch, length = 1) /// ``` /// /// ```no_run /// fn squareHoleSketch() { /// squareSketch = startSketchOn('-XZ') /// |> startProfileAt([-1, -1], %) -/// |> line([2, 0], %) -/// |> line([0, 2], %) -/// |> line([-2, 0], %) -/// |> close(%) +/// |> line(to = [2, 0]) +/// |> line(to = [0, 2]) +/// |> line(to = [-2, 0]) +/// |> close() /// return squareSketch /// } /// /// exampleSketch = startSketchOn('-XZ') /// |> circle({ center = [0, 0], radius = 3 }, %) /// |> hole(squareHoleSketch(), %) -/// example = extrude(1, exampleSketch) +/// example = extrude(exampleSketch, length = 1) /// ``` #[stdlib { name = "hole", diff --git a/src/wasm-lib/kcl/tests/outputs/serial_test_example_line0.png b/src/wasm-lib/kcl/tests/outputs/serial_test_example_line0.png index 7fa0afd450..0973eb2646 100644 Binary files a/src/wasm-lib/kcl/tests/outputs/serial_test_example_line0.png and b/src/wasm-lib/kcl/tests/outputs/serial_test_example_line0.png differ diff --git a/src/wasm-lib/kcl/tests/outputs/serial_test_example_profile_start0.png b/src/wasm-lib/kcl/tests/outputs/serial_test_example_profile_start0.png index 03afd80296..8b8231b501 100644 Binary files a/src/wasm-lib/kcl/tests/outputs/serial_test_example_profile_start0.png and b/src/wasm-lib/kcl/tests/outputs/serial_test_example_profile_start0.png differ