Move the wasm lib, and cleanup rust directory and all references (#5585)
* git mv src/wasm-lib rust Signed-off-by: Jess Frazelle <github@jessfraz.com> * mv wasm-lib to workspace Signed-off-by: Jess Frazelle <github@jessfraz.com> * mv kcl-lib Signed-off-by: Jess Frazelle <github@jessfraz.com> * mv derive docs Signed-off-by: Jess Frazelle <github@jessfraz.com> * resolve file paths Signed-off-by: Jess Frazelle <github@jessfraz.com> * clippy Signed-off-by: Jess Frazelle <github@jessfraz.com> * move more shit Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix more paths Signed-off-by: Jess Frazelle <github@jessfraz.com> * make yarn build:wasm work Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix scripts Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixups Signed-off-by: Jess Frazelle <github@jessfraz.com> * better references Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix cargo ci Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix reference Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix more ci Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix tests Signed-off-by: Jess Frazelle <github@jessfraz.com> * cargo sort Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix script Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix Signed-off-by: Jess Frazelle <github@jessfraz.com> * fmt Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix a dep Signed-off-by: Jess Frazelle <github@jessfraz.com> * sort Signed-off-by: Jess Frazelle <github@jessfraz.com> * remove unused deps Signed-off-by: Jess Frazelle <github@jessfraz.com> * Revert "remove unused deps" This reverts commit fbabdb062e275fd5cbc1476f8480a1afee15d972. * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * deps; Signed-off-by: Jess Frazelle <github@jessfraz.com> * fixes Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
		
							
								
								
									
										181
									
								
								rust/kcl-derive-docs/tests/box.gen
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										181
									
								
								rust/kcl-derive-docs/tests/box.gen
									
									
									
									
									
										Normal file
									
								
							@ -0,0 +1,181 @@
 | 
			
		||||
#[cfg(test)]
 | 
			
		||||
mod test_examples_show {
 | 
			
		||||
    #[tokio::test(flavor = "multi_thread")]
 | 
			
		||||
    async fn test_mock_example_show0() -> miette::Result<()> {
 | 
			
		||||
        let program =
 | 
			
		||||
            crate::Program::parse_no_errs("This is code.\nIt does other shit.\nshow").unwrap();
 | 
			
		||||
        let ctx = crate::ExecutorContext {
 | 
			
		||||
            engine: std::sync::Arc::new(Box::new(
 | 
			
		||||
                crate::engine::conn_mock::EngineConnection::new()
 | 
			
		||||
                    .await
 | 
			
		||||
                    .unwrap(),
 | 
			
		||||
            )),
 | 
			
		||||
            fs: std::sync::Arc::new(crate::fs::FileManager::new()),
 | 
			
		||||
            stdlib: std::sync::Arc::new(crate::std::StdLib::new()),
 | 
			
		||||
            settings: Default::default(),
 | 
			
		||||
            context_type: crate::execution::ContextType::Mock,
 | 
			
		||||
        };
 | 
			
		||||
        if let Err(e) = ctx
 | 
			
		||||
            .run(
 | 
			
		||||
                &program,
 | 
			
		||||
                &mut crate::execution::ExecState::new(&ctx.settings),
 | 
			
		||||
            )
 | 
			
		||||
            .await
 | 
			
		||||
        {
 | 
			
		||||
            return Err(miette::Report::new(crate::errors::Report {
 | 
			
		||||
                error: e,
 | 
			
		||||
                filename: format!("{}{}", "show", 0usize),
 | 
			
		||||
                kcl_source: "This is code.\nIt does other shit.\nshow".to_string(),
 | 
			
		||||
            }));
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    #[tokio::test(flavor = "multi_thread", worker_threads = 5)]
 | 
			
		||||
    async fn kcl_test_example_show0() -> miette::Result<()> {
 | 
			
		||||
        let code = "This is code.\nIt does other shit.\nshow";
 | 
			
		||||
        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.error,
 | 
			
		||||
                    filename: format!("{}{}", "show", 0usize),
 | 
			
		||||
                    kcl_source: "This is code.\nIt does other shit.\nshow".to_string(),
 | 
			
		||||
                }));
 | 
			
		||||
            }
 | 
			
		||||
            Err(other_err) => panic!("{}", other_err),
 | 
			
		||||
            Ok(img) => img,
 | 
			
		||||
        };
 | 
			
		||||
        twenty_twenty::assert_image(
 | 
			
		||||
            &format!("tests/outputs/{}.png", "serial_test_example_show0"),
 | 
			
		||||
            &result,
 | 
			
		||||
            0.99,
 | 
			
		||||
        );
 | 
			
		||||
        Ok(())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[allow(non_camel_case_types, missing_docs)]
 | 
			
		||||
#[doc = "Std lib function: show\nThis is some function.\nIt does shit."]
 | 
			
		||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, schemars :: JsonSchema, ts_rs :: TS)]
 | 
			
		||||
#[ts(export)]
 | 
			
		||||
pub(crate) struct Show {}
 | 
			
		||||
 | 
			
		||||
#[allow(non_upper_case_globals, missing_docs)]
 | 
			
		||||
#[doc = "Std lib function: show\nThis is some function.\nIt does shit."]
 | 
			
		||||
pub(crate) const Show: Show = Show {};
 | 
			
		||||
fn boxed_show(
 | 
			
		||||
    exec_state: &mut crate::execution::ExecState,
 | 
			
		||||
    args: crate::std::Args,
 | 
			
		||||
) -> std::pin::Pin<
 | 
			
		||||
    Box<
 | 
			
		||||
        dyn std::future::Future<
 | 
			
		||||
                Output = anyhow::Result<crate::execution::KclValue, crate::errors::KclError>,
 | 
			
		||||
            > + Send
 | 
			
		||||
            + '_,
 | 
			
		||||
    >,
 | 
			
		||||
> {
 | 
			
		||||
    Box::pin(show(exec_state, args))
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
impl crate::docs::StdLibFn for Show {
 | 
			
		||||
    fn name(&self) -> String {
 | 
			
		||||
        "show".to_string()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn summary(&self) -> String {
 | 
			
		||||
        "This is some function.".to_string()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn description(&self) -> String {
 | 
			
		||||
        "It does shit.".to_string()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn tags(&self) -> Vec<String> {
 | 
			
		||||
        vec![]
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn keyword_arguments(&self) -> bool {
 | 
			
		||||
        false
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn args(&self, inline_subschemas: bool) -> Vec<crate::docs::StdLibFnArg> {
 | 
			
		||||
        let mut settings = schemars::gen::SchemaSettings::openapi3();
 | 
			
		||||
        settings.inline_subschemas = inline_subschemas;
 | 
			
		||||
        let mut generator = schemars::gen::SchemaGenerator::new(settings);
 | 
			
		||||
        vec![crate::docs::StdLibFnArg {
 | 
			
		||||
            name: "args".to_string(),
 | 
			
		||||
            type_: "number".to_string(),
 | 
			
		||||
            schema: crate::docs::cleanup_number_tuples_root(generator.root_schema_for::<f64>()),
 | 
			
		||||
            required: true,
 | 
			
		||||
            label_required: true,
 | 
			
		||||
            description: String::new().to_string(),
 | 
			
		||||
            include_in_snippet: true,
 | 
			
		||||
        }]
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn return_value(&self, inline_subschemas: bool) -> Option<crate::docs::StdLibFnArg> {
 | 
			
		||||
        let mut settings = schemars::gen::SchemaSettings::openapi3();
 | 
			
		||||
        settings.inline_subschemas = inline_subschemas;
 | 
			
		||||
        let mut generator = schemars::gen::SchemaGenerator::new(settings);
 | 
			
		||||
        let schema = crate::docs::cleanup_number_tuples_root(generator.root_schema_for::<f64>());
 | 
			
		||||
        Some(crate::docs::StdLibFnArg {
 | 
			
		||||
            name: "".to_string(),
 | 
			
		||||
            type_: "number".to_string(),
 | 
			
		||||
            schema,
 | 
			
		||||
            required: true,
 | 
			
		||||
            label_required: true,
 | 
			
		||||
            description: String::new(),
 | 
			
		||||
            include_in_snippet: true,
 | 
			
		||||
        })
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn unpublished(&self) -> bool {
 | 
			
		||||
        false
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn deprecated(&self) -> bool {
 | 
			
		||||
        false
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn feature_tree_operation(&self) -> bool {
 | 
			
		||||
        false
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn examples(&self) -> Vec<String> {
 | 
			
		||||
        let code_blocks = vec!["This is code.\nIt does other shit.\nshow"];
 | 
			
		||||
        code_blocks
 | 
			
		||||
            .iter()
 | 
			
		||||
            .map(|cb| {
 | 
			
		||||
                let program = crate::Program::parse_no_errs(cb).unwrap();
 | 
			
		||||
                let mut options: crate::parsing::ast::types::FormatOptions = Default::default();
 | 
			
		||||
                options.insert_final_newline = false;
 | 
			
		||||
                program.ast.recast(&options, 0)
 | 
			
		||||
            })
 | 
			
		||||
            .collect::<Vec<String>>()
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn std_lib_fn(&self) -> crate::std::StdFn {
 | 
			
		||||
        boxed_show
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
 | 
			
		||||
        Box::new(self.clone())
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#[doc = r" This is some function."]
 | 
			
		||||
#[doc = r" It does shit."]
 | 
			
		||||
#[doc = r""]
 | 
			
		||||
#[doc = r"     This is code."]
 | 
			
		||||
#[doc = r"     It does other shit."]
 | 
			
		||||
#[doc = r"     show"]
 | 
			
		||||
fn inner_show(#[doc = r" The args to do shit to."] args: Box<f64>) -> Box<f64> {
 | 
			
		||||
    args
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user