2024-03-13 12:56:46 -07:00
|
|
|
#[cfg(test)]
|
|
|
|
mod test_examples_show {
|
2024-05-15 10:17:29 -07:00
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
async fn test_mock_example_show0() {
|
|
|
|
let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nshow").unwrap();
|
|
|
|
let parser = crate::parser::Parser::new(tokens);
|
|
|
|
let program = parser.ast().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(),
|
|
|
|
is_mock: true,
|
|
|
|
};
|
2024-06-26 14:51:47 -07:00
|
|
|
ctx.run(&program, None).await.unwrap();
|
2024-05-15 10:17:29 -07:00
|
|
|
}
|
|
|
|
|
2024-03-13 12:56:46 -07:00
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
|
|
|
async fn serial_test_example_show0() {
|
|
|
|
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-04-15 17:18:32 -07:00
|
|
|
let tokens = crate::token::lexer("This is another code block.\nyes sirrr.\nshow").unwrap();
|
2024-03-13 12:56:46 -07:00
|
|
|
let parser = crate::parser::Parser::new(tokens);
|
|
|
|
let program = parser.ast().unwrap();
|
2024-04-25 02:31:18 -07:00
|
|
|
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
2024-03-26 19:32:31 -07:00
|
|
|
.await
|
|
|
|
.unwrap();
|
2024-06-26 14:51:47 -07:00
|
|
|
ctx.run(&program, None).await.unwrap();
|
2024-03-26 21:28:50 -07:00
|
|
|
ctx.engine
|
|
|
|
.send_modeling_cmd(
|
|
|
|
uuid::Uuid::new_v4(),
|
|
|
|
crate::executor::SourceRange::default(),
|
2024-04-22 17:14:10 -07:00
|
|
|
kittycad::types::ModelingCmd::ZoomToFit {
|
2024-04-22 20:46:54 -07:00
|
|
|
object_ids: Default::default(),
|
2024-04-22 17:14:10 -07:00
|
|
|
padding: 0.1,
|
2024-03-26 21:28:50 -07:00
|
|
|
},
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let resp = ctx
|
|
|
|
.engine
|
|
|
|
.send_modeling_cmd(
|
|
|
|
uuid::Uuid::new_v4(),
|
|
|
|
crate::executor::SourceRange::default(),
|
|
|
|
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
|
|
format: kittycad::types::ImageFormat::Png,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let output_file =
|
|
|
|
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
|
|
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
|
|
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
|
|
} = &resp
|
|
|
|
{
|
|
|
|
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
|
|
} else {
|
|
|
|
panic!("Unexpected response from engine: {:?}", resp);
|
|
|
|
}
|
|
|
|
|
|
|
|
let actual = image::io::Reader::open(output_file)
|
|
|
|
.unwrap()
|
|
|
|
.decode()
|
|
|
|
.unwrap();
|
|
|
|
twenty_twenty::assert_image(
|
|
|
|
&format!("tests/outputs/{}.png", "serial_test_example_show0"),
|
|
|
|
&actual,
|
|
|
|
1.0,
|
|
|
|
);
|
2024-03-13 12:56:46 -07:00
|
|
|
}
|
|
|
|
|
2024-05-15 10:17:29 -07:00
|
|
|
#[tokio::test(flavor = "multi_thread")]
|
|
|
|
async fn test_mock_example_show1() {
|
|
|
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
|
|
|
let parser = crate::parser::Parser::new(tokens);
|
|
|
|
let program = parser.ast().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(),
|
|
|
|
is_mock: true,
|
|
|
|
};
|
2024-06-26 14:51:47 -07:00
|
|
|
ctx.run(&program, None).await.unwrap();
|
2024-05-15 10:17:29 -07:00
|
|
|
}
|
|
|
|
|
2024-03-13 12:56:46 -07:00
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 5)]
|
|
|
|
async fn serial_test_example_show1() {
|
|
|
|
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-04-15 17:18:32 -07:00
|
|
|
let tokens = crate::token::lexer("This is code.\nIt does other shit.\nshow").unwrap();
|
2024-03-13 12:56:46 -07:00
|
|
|
let parser = crate::parser::Parser::new(tokens);
|
|
|
|
let program = parser.ast().unwrap();
|
2024-04-25 02:31:18 -07:00
|
|
|
let ctx = crate::executor::ExecutorContext::new(&client, Default::default())
|
2024-03-26 19:32:31 -07:00
|
|
|
.await
|
|
|
|
.unwrap();
|
2024-06-26 14:51:47 -07:00
|
|
|
ctx.run(&program, None).await.unwrap();
|
2024-03-26 21:28:50 -07:00
|
|
|
ctx.engine
|
|
|
|
.send_modeling_cmd(
|
|
|
|
uuid::Uuid::new_v4(),
|
|
|
|
crate::executor::SourceRange::default(),
|
2024-04-22 17:14:10 -07:00
|
|
|
kittycad::types::ModelingCmd::ZoomToFit {
|
2024-04-22 20:46:54 -07:00
|
|
|
object_ids: Default::default(),
|
2024-04-22 17:14:10 -07:00
|
|
|
padding: 0.1,
|
2024-03-26 21:28:50 -07:00
|
|
|
},
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let resp = ctx
|
|
|
|
.engine
|
|
|
|
.send_modeling_cmd(
|
|
|
|
uuid::Uuid::new_v4(),
|
|
|
|
crate::executor::SourceRange::default(),
|
|
|
|
kittycad::types::ModelingCmd::TakeSnapshot {
|
|
|
|
format: kittycad::types::ImageFormat::Png,
|
|
|
|
},
|
|
|
|
)
|
|
|
|
.await
|
|
|
|
.unwrap();
|
|
|
|
let output_file =
|
|
|
|
std::env::temp_dir().join(format!("kcl_output_{}.png", uuid::Uuid::new_v4()));
|
|
|
|
if let kittycad::types::OkWebSocketResponseData::Modeling {
|
|
|
|
modeling_response: kittycad::types::OkModelingCmdResponse::TakeSnapshot { data },
|
|
|
|
} = &resp
|
|
|
|
{
|
|
|
|
std::fs::write(&output_file, &data.contents.0).unwrap();
|
|
|
|
} else {
|
|
|
|
panic!("Unexpected response from engine: {:?}", resp);
|
|
|
|
}
|
|
|
|
|
|
|
|
let actual = image::io::Reader::open(output_file)
|
|
|
|
.unwrap()
|
|
|
|
.decode()
|
|
|
|
.unwrap();
|
|
|
|
twenty_twenty::assert_image(
|
|
|
|
&format!("tests/outputs/{}.png", "serial_test_example_show1"),
|
|
|
|
&actual,
|
|
|
|
1.0,
|
|
|
|
);
|
2024-03-13 12:56:46 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
Remove just one enum (#1096)
# Problem
This is my proposal for fixing #1107 . I've only done it for one stdlib function, `tangentialArcTo` -- if y'all like it, I'll apply this idea to the rest of the stdlib.
Previously, if users want to put a tag on the arc, the function's parameters change type.
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is object
tangentialArcTo({to: [x, y], tag: "myTag"}, %)
```
# Solution
My proposal in #1006 is that KCL should have optional values. This means we can change the stdlib `tangentialArcTo` function to use them. In this PR, the calls are now like
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is array still, but we now pass a tag at the end.
tangentialArcTo([x, y], %, "myTag")
```
This adds an "option" type to KCL typesystem, but it's not really revealed to users (no KCL types are revealed to users right now, they write untyped code and only interact with types when they get type errors upon executing programs). Also adds a None type, which is the default case of the Optional enum.
2023-12-18 23:49:32 -06:00
|
|
|
#[allow(non_camel_case_types, missing_docs)]
|
2024-03-13 12:56:46 -07:00
|
|
|
#[doc = "Std lib function: show\nThis is some function.\nIt does shit."]
|
Remove just one enum (#1096)
# Problem
This is my proposal for fixing #1107 . I've only done it for one stdlib function, `tangentialArcTo` -- if y'all like it, I'll apply this idea to the rest of the stdlib.
Previously, if users want to put a tag on the arc, the function's parameters change type.
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is object
tangentialArcTo({to: [x, y], tag: "myTag"}, %)
```
# Solution
My proposal in #1006 is that KCL should have optional values. This means we can change the stdlib `tangentialArcTo` function to use them. In this PR, the calls are now like
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is array still, but we now pass a tag at the end.
tangentialArcTo([x, y], %, "myTag")
```
This adds an "option" type to KCL typesystem, but it's not really revealed to users (no KCL types are revealed to users right now, they write untyped code and only interact with types when they get type errors upon executing programs). Also adds a None type, which is the default case of the Optional enum.
2023-12-18 23:49:32 -06:00
|
|
|
#[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)]
|
2024-03-13 12:56:46 -07:00
|
|
|
#[doc = "Std lib function: show\nThis is some function.\nIt does shit."]
|
Remove just one enum (#1096)
# Problem
This is my proposal for fixing #1107 . I've only done it for one stdlib function, `tangentialArcTo` -- if y'all like it, I'll apply this idea to the rest of the stdlib.
Previously, if users want to put a tag on the arc, the function's parameters change type.
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is object
tangentialArcTo({to: [x, y], tag: "myTag"}, %)
```
# Solution
My proposal in #1006 is that KCL should have optional values. This means we can change the stdlib `tangentialArcTo` function to use them. In this PR, the calls are now like
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is array still, but we now pass a tag at the end.
tangentialArcTo([x, y], %, "myTag")
```
This adds an "option" type to KCL typesystem, but it's not really revealed to users (no KCL types are revealed to users right now, they write untyped code and only interact with types when they get type errors upon executing programs). Also adds a None type, which is the default case of the Optional enum.
2023-12-18 23:49:32 -06:00
|
|
|
pub(crate) const Show: Show = Show {};
|
|
|
|
fn boxed_show(
|
|
|
|
args: crate::std::Args,
|
|
|
|
) -> std::pin::Pin<
|
|
|
|
Box<
|
|
|
|
dyn std::future::Future<
|
2024-04-12 21:32:57 -07:00
|
|
|
Output = anyhow::Result<crate::executor::MemoryItem, crate::errors::KclError>,
|
|
|
|
> + Send,
|
Remove just one enum (#1096)
# Problem
This is my proposal for fixing #1107 . I've only done it for one stdlib function, `tangentialArcTo` -- if y'all like it, I'll apply this idea to the rest of the stdlib.
Previously, if users want to put a tag on the arc, the function's parameters change type.
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is object
tangentialArcTo({to: [x, y], tag: "myTag"}, %)
```
# Solution
My proposal in #1006 is that KCL should have optional values. This means we can change the stdlib `tangentialArcTo` function to use them. In this PR, the calls are now like
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is array still, but we now pass a tag at the end.
tangentialArcTo([x, y], %, "myTag")
```
This adds an "option" type to KCL typesystem, but it's not really revealed to users (no KCL types are revealed to users right now, they write untyped code and only interact with types when they get type errors upon executing programs). Also adds a None type, which is the default case of the Optional enum.
2023-12-18 23:49:32 -06:00
|
|
|
>,
|
|
|
|
> {
|
|
|
|
Box::pin(show(args))
|
|
|
|
}
|
|
|
|
|
|
|
|
impl crate::docs::StdLibFn for Show {
|
|
|
|
fn name(&self) -> String {
|
|
|
|
"show".to_string()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn summary(&self) -> String {
|
2024-03-13 12:56:46 -07:00
|
|
|
"This is some function.".to_string()
|
Remove just one enum (#1096)
# Problem
This is my proposal for fixing #1107 . I've only done it for one stdlib function, `tangentialArcTo` -- if y'all like it, I'll apply this idea to the rest of the stdlib.
Previously, if users want to put a tag on the arc, the function's parameters change type.
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is object
tangentialArcTo({to: [x, y], tag: "myTag"}, %)
```
# Solution
My proposal in #1006 is that KCL should have optional values. This means we can change the stdlib `tangentialArcTo` function to use them. In this PR, the calls are now like
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is array still, but we now pass a tag at the end.
tangentialArcTo([x, y], %, "myTag")
```
This adds an "option" type to KCL typesystem, but it's not really revealed to users (no KCL types are revealed to users right now, they write untyped code and only interact with types when they get type errors upon executing programs). Also adds a None type, which is the default case of the Optional enum.
2023-12-18 23:49:32 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
fn description(&self) -> String {
|
2024-03-13 12:56:46 -07:00
|
|
|
"It does shit.".to_string()
|
Remove just one enum (#1096)
# Problem
This is my proposal for fixing #1107 . I've only done it for one stdlib function, `tangentialArcTo` -- if y'all like it, I'll apply this idea to the rest of the stdlib.
Previously, if users want to put a tag on the arc, the function's parameters change type.
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is object
tangentialArcTo({to: [x, y], tag: "myTag"}, %)
```
# Solution
My proposal in #1006 is that KCL should have optional values. This means we can change the stdlib `tangentialArcTo` function to use them. In this PR, the calls are now like
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is array still, but we now pass a tag at the end.
tangentialArcTo([x, y], %, "myTag")
```
This adds an "option" type to KCL typesystem, but it's not really revealed to users (no KCL types are revealed to users right now, they write untyped code and only interact with types when they get type errors upon executing programs). Also adds a None type, which is the default case of the Optional enum.
2023-12-18 23:49:32 -06: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: "args".to_string(),
|
|
|
|
type_: "[number]".to_string(),
|
|
|
|
schema: <[f64; 2usize]>::json_schema(&mut generator),
|
|
|
|
required: true,
|
|
|
|
}]
|
|
|
|
}
|
|
|
|
|
|
|
|
fn return_value(&self) -> Option<crate::docs::StdLibFnArg> {
|
|
|
|
let mut settings = schemars::gen::SchemaSettings::openapi3();
|
|
|
|
settings.inline_subschemas = true;
|
|
|
|
let mut generator = schemars::gen::SchemaGenerator::new(settings);
|
|
|
|
Some(crate::docs::StdLibFnArg {
|
|
|
|
name: "".to_string(),
|
|
|
|
type_: "number".to_string(),
|
2024-03-12 12:54:45 -07:00
|
|
|
schema: <f64>::json_schema(&mut generator),
|
Remove just one enum (#1096)
# Problem
This is my proposal for fixing #1107 . I've only done it for one stdlib function, `tangentialArcTo` -- if y'all like it, I'll apply this idea to the rest of the stdlib.
Previously, if users want to put a tag on the arc, the function's parameters change type.
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is object
tangentialArcTo({to: [x, y], tag: "myTag"}, %)
```
# Solution
My proposal in #1006 is that KCL should have optional values. This means we can change the stdlib `tangentialArcTo` function to use them. In this PR, the calls are now like
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is array still, but we now pass a tag at the end.
tangentialArcTo([x, y], %, "myTag")
```
This adds an "option" type to KCL typesystem, but it's not really revealed to users (no KCL types are revealed to users right now, they write untyped code and only interact with types when they get type errors upon executing programs). Also adds a None type, which is the default case of the Optional enum.
2023-12-18 23:49:32 -06:00
|
|
|
required: true,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
|
|
|
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.\nshow",
|
|
|
|
"This is code.\nIt does other shit.\nshow",
|
|
|
|
];
|
|
|
|
code_blocks
|
|
|
|
.iter()
|
|
|
|
.map(|cb| {
|
2024-04-15 17:18:32 -07:00
|
|
|
let tokens = crate::token::lexer(cb).unwrap();
|
2024-03-13 12:56:46 -07:00
|
|
|
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>>()
|
|
|
|
}
|
|
|
|
|
Remove just one enum (#1096)
# Problem
This is my proposal for fixing #1107 . I've only done it for one stdlib function, `tangentialArcTo` -- if y'all like it, I'll apply this idea to the rest of the stdlib.
Previously, if users want to put a tag on the arc, the function's parameters change type.
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is object
tangentialArcTo({to: [x, y], tag: "myTag"}, %)
```
# Solution
My proposal in #1006 is that KCL should have optional values. This means we can change the stdlib `tangentialArcTo` function to use them. In this PR, the calls are now like
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is array still, but we now pass a tag at the end.
tangentialArcTo([x, y], %, "myTag")
```
This adds an "option" type to KCL typesystem, but it's not really revealed to users (no KCL types are revealed to users right now, they write untyped code and only interact with types when they get type errors upon executing programs). Also adds a None type, which is the default case of the Optional enum.
2023-12-18 23:49:32 -06:00
|
|
|
fn std_lib_fn(&self) -> crate::std::StdFn {
|
|
|
|
boxed_show
|
|
|
|
}
|
|
|
|
|
|
|
|
fn clone_box(&self) -> Box<dyn crate::docs::StdLibFn> {
|
|
|
|
Box::new(self.clone())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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" show"]
|
|
|
|
#[doc = r""]
|
|
|
|
#[doc = r" ```"]
|
|
|
|
#[doc = r" This is another code block."]
|
|
|
|
#[doc = r" yes sirrr."]
|
|
|
|
#[doc = r" show"]
|
|
|
|
#[doc = r" ```"]
|
2024-03-12 12:54:45 -07:00
|
|
|
fn inner_show(#[doc = r" The args to do shit to."] args: [f64; 2]) -> Result<Box<f64>> {
|
Remove just one enum (#1096)
# Problem
This is my proposal for fixing #1107 . I've only done it for one stdlib function, `tangentialArcTo` -- if y'all like it, I'll apply this idea to the rest of the stdlib.
Previously, if users want to put a tag on the arc, the function's parameters change type.
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is object
tangentialArcTo({to: [x, y], tag: "myTag"}, %)
```
# Solution
My proposal in #1006 is that KCL should have optional values. This means we can change the stdlib `tangentialArcTo` function to use them. In this PR, the calls are now like
```
// Tag missing: first param is array
tangentialArcTo([x, y], %)
// Tag present: first param is array still, but we now pass a tag at the end.
tangentialArcTo([x, y], %, "myTag")
```
This adds an "option" type to KCL typesystem, but it's not really revealed to users (no KCL types are revealed to users right now, they write untyped code and only interact with types when they get type errors upon executing programs). Also adds a None type, which is the default case of the Optional enum.
2023-12-18 23:49:32 -06:00
|
|
|
args
|
|
|
|
}
|