Files
modeling-app/src/wasm-lib/derive-docs/tests/args_with_refs.gen

145 lines
4.2 KiB
Plaintext
Raw Normal View History

#[cfg(test)]
mod test_examples_someFn {
#[tokio::test(flavor = "multi_thread")]
async fn test_mock_example_someFn0() {
let program = crate::Program::parse("someFn()").unwrap();
let ctx = crate::executor::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(),
Initial kcl to core codegen (C++) util (#2999) * wip on this * wip on kcl-to-core tool * Update conn_mock_core.rs * stopping point * wip * use enum for is_mock for added versatility * get at least circular patterns working to finish POC * fmt * fmt part 2 * Update Cargo.lock * quick fix for tests * quick fix * more fixes * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * get more cases of this working * Update src/wasm-lib/kcl-to-core/src/conn_mock_core.rs Co-authored-by: Jonathan Tran <jonnytran@gmail.com> * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu) * kcl core gen plane code by default * fmt * fix build? * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Fix clippy errors * Remove unneeded clippy allow * post merge build fix attempt * Add missing indexmap dependency * Fix to use IndexMap instead of HashMap * Migrate to kittycad-modeling-cmds * fix build * fmt * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest)" This reverts commit 991cdde15eca2fd476e57502d8b6e37d5ef00872. * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit a4ae03c740ecbb5335acce2f5cf841106778cce0. * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit 9a082e7c9f8900ea54fa180c351d088a16721795. * Regenerate derive_docs * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Revert "A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest)" This reverts commit a8bdb3562774a4f064aefb7860804d2dd075b146. * Fix e2e test failing by masking state indicator * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest) * Confirm snapshot change * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest) * Confirm snapshot change * Fix build from last merge with main --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Jonathan Tran <jonnytran@gmail.com> Co-authored-by: Kurt Hutten <k.hutten@protonmail.ch> Co-authored-by: Frank Noirot <frank@zoo.dev>
2024-10-01 12:45:01 -07:00
context_type: crate::executor::ContextType::Mock,
};
ctx.run(&program, &mut crate::ExecState::default())
.await
.unwrap();
}
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
async fn kcl_test_example_someFn0() {
let code = "someFn()";
let result =
crate::test_server::execute_and_snapshot(code, crate::settings::types::UnitLength::Mm)
.await
.unwrap();
twenty_twenty::assert_image(
&format!("tests/outputs/{}.png", "serial_test_example_someFn0"),
&result,
0.99,
);
}
}
#[allow(non_camel_case_types, missing_docs)]
#[doc = "Std lib function: someFn\nDocs"]
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, schemars :: JsonSchema, ts_rs :: TS)]
#[ts(export)]
pub(crate) struct SomeFn {}
#[allow(non_upper_case_globals, missing_docs)]
#[doc = "Std lib function: someFn\nDocs"]
pub(crate) const SomeFn: SomeFn = SomeFn {};
fn boxed_someFn(
exec_state: &mut crate::executor::ExecState,
args: crate::std::Args,
) -> std::pin::Pin<
Box<
dyn std::future::Future<
Output = anyhow::Result<crate::executor::KclValue, crate::errors::KclError>,
> + Send
+ '_,
>,
> {
Box::pin(someFn(exec_state, args))
}
impl crate::docs::StdLibFn for SomeFn {
fn name(&self) -> String {
"someFn".to_string()
}
fn summary(&self) -> String {
"Docs".to_string()
}
fn description(&self) -> String {
"".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: "data".to_string(),
type_: "string".to_string(),
schema: generator.root_schema_for::<str>(),
required: true,
label_required: 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 = generator.root_schema_for::<i32>();
Some(crate::docs::StdLibFnArg {
name: "".to_string(),
type_: "i32".to_string(),
schema,
required: true,
label_required: true,
})
}
fn unpublished(&self) -> bool {
false
}
fn deprecated(&self) -> bool {
false
}
fn examples(&self) -> Vec<String> {
let code_blocks = vec!["someFn()"];
code_blocks
.iter()
.map(|cb| {
let program = crate::Program::parse(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_someFn
}
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
Box::new(self.clone())
}
}
#[doc = r" Docs"]
#[doc = r" ```"]
#[doc = r" someFn()"]
#[doc = r" ```"]
fn someFn(data: &'a str) -> i32 {
3
}