2024-03-13 12:56:46 -07:00
|
|
|
#[cfg(test)]
|
|
|
|
mod test_examples_line_to {
|
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
|
|
|
async fn serial_test_example_line_to0() {
|
|
|
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
|
|
|
let http_client = reqwest::Client::builder()
|
|
|
|
.user_agent(user_agent)
|
|
|
|
.timeout(std::time::Duration::from_secs(600))
|
|
|
|
.connect_timeout(std::time::Duration::from_secs(60));
|
|
|
|
let ws_client = reqwest::Client::builder()
|
|
|
|
.user_agent(user_agent)
|
|
|
|
.timeout(std::time::Duration::from_secs(600))
|
|
|
|
.connect_timeout(std::time::Duration::from_secs(60))
|
|
|
|
.connection_verbose(true)
|
|
|
|
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
|
|
.http1_only();
|
|
|
|
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
2024-03-23 15:45:55 -07:00
|
|
|
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
|
|
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
|
|
client.set_base_url(addr);
|
|
|
|
}
|
|
|
|
|
2024-03-13 12:56:46 -07:00
|
|
|
let ws = client
|
|
|
|
.modeling()
|
|
|
|
.commands_ws(None, None, None, None, None, Some(false))
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nlineTo");
|
|
|
|
let parser = crate::parser::Parser::new(tokens);
|
|
|
|
let program = parser.ast().unwrap();
|
|
|
|
let mut mem: crate::executor::ProgramMemory = Default::default();
|
2024-03-26 19:32:31 -07:00
|
|
|
let ctx = crate::executor::ExecutorContext::new(ws, kittycad::types::UnitLength::Mm)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2024-03-13 12:56:46 -07:00
|
|
|
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
|
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
|
|
|
async fn serial_test_example_line_to1() {
|
|
|
|
let user_agent = concat!(env!("CARGO_PKG_NAME"), ".rs/", env!("CARGO_PKG_VERSION"),);
|
|
|
|
let http_client = reqwest::Client::builder()
|
|
|
|
.user_agent(user_agent)
|
|
|
|
.timeout(std::time::Duration::from_secs(600))
|
|
|
|
.connect_timeout(std::time::Duration::from_secs(60));
|
|
|
|
let ws_client = reqwest::Client::builder()
|
|
|
|
.user_agent(user_agent)
|
|
|
|
.timeout(std::time::Duration::from_secs(600))
|
|
|
|
.connect_timeout(std::time::Duration::from_secs(60))
|
|
|
|
.connection_verbose(true)
|
|
|
|
.tcp_keepalive(std::time::Duration::from_secs(600))
|
|
|
|
.http1_only();
|
|
|
|
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
|
2024-03-23 15:45:55 -07:00
|
|
|
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
|
|
|
|
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
|
|
|
|
client.set_base_url(addr);
|
|
|
|
}
|
|
|
|
|
2024-03-13 12:56:46 -07:00
|
|
|
let ws = client
|
|
|
|
.modeling()
|
|
|
|
.commands_ws(None, None, None, None, None, Some(false))
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nlineTo");
|
|
|
|
let parser = crate::parser::Parser::new(tokens);
|
|
|
|
let program = parser.ast().unwrap();
|
|
|
|
let mut mem: crate::executor::ProgramMemory = Default::default();
|
2024-03-26 19:32:31 -07:00
|
|
|
let ctx = crate::executor::ExecutorContext::new(ws, kittycad::types::UnitLength::Mm)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
2024-03-13 12:56:46 -07:00
|
|
|
crate::executor::execute(program, &mut mem, crate::executor::BodyType::Root, &ctx)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-25 13:41:04 -07:00
|
|
|
#[allow(non_camel_case_types, missing_docs)]
|
2024-03-13 12:56:46 -07:00
|
|
|
#[doc = "Std lib function: lineTo\nThis is some function.\nIt does shit."]
|
2023-09-05 16:02:27 -07:00
|
|
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, schemars :: JsonSchema, ts_rs :: TS)]
|
|
|
|
#[ts(export)]
|
2023-08-25 13:41:04 -07:00
|
|
|
pub(crate) struct LineTo {}
|
|
|
|
|
|
|
|
#[allow(non_upper_case_globals, missing_docs)]
|
2024-03-13 12:56:46 -07:00
|
|
|
#[doc = "Std lib function: lineTo\nThis is some function.\nIt does shit."]
|
2023-08-25 13:41:04 -07:00
|
|
|
pub(crate) const LineTo: LineTo = LineTo {};
|
2023-09-20 18:27:08 -07:00
|
|
|
fn boxed_line_to(
|
|
|
|
args: crate::std::Args,
|
|
|
|
) -> std::pin::Pin<
|
|
|
|
Box<
|
|
|
|
dyn std::future::Future<
|
|
|
|
Output = anyhow::Result<crate::executor::MemoryItem, crate::errors::KclError>,
|
|
|
|
>,
|
|
|
|
>,
|
|
|
|
> {
|
|
|
|
Box::pin(line_to(args))
|
|
|
|
}
|
|
|
|
|
2023-08-25 13:41:04 -07:00
|
|
|
impl crate::docs::StdLibFn for LineTo {
|
|
|
|
fn name(&self) -> String {
|
|
|
|
"lineTo".to_string()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn summary(&self) -> String {
|
2024-03-13 12:56:46 -07:00
|
|
|
"This is some function.".to_string()
|
2023-08-25 13:41:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn description(&self) -> String {
|
2024-03-13 12:56:46 -07:00
|
|
|
"It does shit.".to_string()
|
2023-08-25 13:41:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn tags(&self) -> Vec<String> {
|
|
|
|
vec![]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn args(&self) -> Vec<crate::docs::StdLibFnArg> {
|
|
|
|
let mut settings = schemars::gen::SchemaSettings::openapi3();
|
|
|
|
settings.inline_subschemas = true;
|
|
|
|
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
|
|
|
vec![
|
|
|
|
crate::docs::StdLibFnArg {
|
|
|
|
name: "data".to_string(),
|
|
|
|
type_: "LineToData".to_string(),
|
|
|
|
schema: LineToData::json_schema(&mut generator),
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
crate::docs::StdLibFnArg {
|
|
|
|
name: "sketch_group".to_string(),
|
|
|
|
type_: "SketchGroup".to_string(),
|
|
|
|
schema: SketchGroup::json_schema(&mut generator),
|
|
|
|
required: true,
|
|
|
|
},
|
|
|
|
]
|
|
|
|
}
|
|
|
|
|
2023-09-05 16:02:27 -07:00
|
|
|
fn return_value(&self) -> Option<crate::docs::StdLibFnArg> {
|
2023-08-25 13:41:04 -07:00
|
|
|
let mut settings = schemars::gen::SchemaSettings::openapi3();
|
|
|
|
settings.inline_subschemas = true;
|
|
|
|
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
2023-09-05 16:02:27 -07:00
|
|
|
Some(crate::docs::StdLibFnArg {
|
2023-08-25 13:41:04 -07:00
|
|
|
name: "".to_string(),
|
|
|
|
type_: "SketchGroup".to_string(),
|
2024-03-12 12:54:45 -07:00
|
|
|
schema: <SketchGroup>::json_schema(&mut generator),
|
2023-08-25 13:41:04 -07:00
|
|
|
required: true,
|
2023-09-05 16:02:27 -07:00
|
|
|
})
|
2023-08-25 13:41:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
fn unpublished(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
|
|
|
fn deprecated(&self) -> bool {
|
|
|
|
false
|
|
|
|
}
|
|
|
|
|
2024-03-13 12:56:46 -07:00
|
|
|
fn examples(&self) -> Vec<String> {
|
|
|
|
let code_blocks = vec![
|
|
|
|
"This is another code block.\nyes sirrr.\nlineTo",
|
|
|
|
"This is code.\nIt does other shit.\nlineTo",
|
|
|
|
];
|
|
|
|
code_blocks
|
|
|
|
.iter()
|
|
|
|
.map(|cb| {
|
|
|
|
let tokens = crate::token::lexer(cb);
|
|
|
|
let parser = crate::parser::Parser::new(tokens);
|
|
|
|
let program = parser.ast().unwrap();
|
|
|
|
let mut options: crate::ast::types::FormatOptions = Default::default();
|
|
|
|
options.insert_final_newline = false;
|
|
|
|
program.recast(&options, 0)
|
|
|
|
})
|
|
|
|
.collect::<Vec<String>>()
|
|
|
|
}
|
|
|
|
|
2023-08-25 13:41:04 -07:00
|
|
|
fn std_lib_fn(&self) -> crate::std::StdFn {
|
2023-09-20 18:27:08 -07:00
|
|
|
boxed_line_to
|
2023-08-25 13:41:04 -07:00
|
|
|
}
|
2023-09-05 16:02:27 -07:00
|
|
|
|
|
|
|
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
|
|
|
Box::new(self.clone())
|
|
|
|
}
|
2023-08-25 13:41:04 -07:00
|
|
|
}
|
|
|
|
|
2024-03-13 12:56:46 -07:00
|
|
|
#[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" lineTo"]
|
|
|
|
#[doc = r""]
|
|
|
|
#[doc = r" ```"]
|
|
|
|
#[doc = r" This is another code block."]
|
|
|
|
#[doc = r" yes sirrr."]
|
|
|
|
#[doc = r" lineTo"]
|
|
|
|
#[doc = r" ```"]
|
2023-08-25 13:41:04 -07:00
|
|
|
fn inner_line_to(
|
|
|
|
data: LineToData,
|
|
|
|
sketch_group: SketchGroup,
|
|
|
|
args: &Args,
|
|
|
|
) -> Result<SketchGroup, KclError> {
|
|
|
|
Ok(())
|
|
|
|
}
|