Add batch support to current KCL implementation (#1871)

* wip

* wip

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* more batch shit

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* fixes

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* push up mods

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* go back to batch id

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* add unlocks back

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* remove logging

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* port to wasm

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* use a trait

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* updates

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* snapshojts

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* artifact map fix

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* cleanup

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* remove the blur

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* hacks on hacks

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* artifact map clean up

* tweak

* fix so extrudes work

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* start of id to source range infra

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* basic map to ids and source ranges

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* make typescript happy

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* flush at end of exxecute

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* small thing for flush

Signed-off-by: Jess Frazelle <github@jessfraz.com>

* A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu)

* trigger ci

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
Co-authored-by: 49lf <ircsurfer33@gmail.com>
Co-authored-by: Kurt Hutten Irev-Dev <k.hutten@protonmail.ch>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
Jess Frazelle
2024-03-23 15:45:55 -07:00
committed by GitHub
parent 846fc99bbc
commit 0983dcca22
53 changed files with 866 additions and 836 deletions

View File

@ -1,7 +1,7 @@
[package]
name = "derive-docs"
description = "A tool for generating documentation from Rust derive macros"
version = "0.1.11"
version = "0.1.12"
edition = "2021"
license = "MIT"
repository = "https://github.com/KittyCAD/modeling-app"
@ -23,6 +23,7 @@ serde_tokenstream = "0.2"
syn = { version = "2.0.53", features = ["full"] }
[dev-dependencies]
anyhow = "1.0.81"
expectorate = "1.1.0"
openapitor = { git = "https://github.com/KittyCAD/kittycad.rs", branch = "main" }
pretty_assertions = "1.4.0"
rustfmt-wrapper = "0.2.1"

View File

@ -764,7 +764,11 @@ fn generate_code_block_test(fn_name: &str, code_block: &str, index: usize) -> pr
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
// Create the client.
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
let mut client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
// Set a local engine address if it's set.
if let Ok(addr) = std::env::var("LOCAL_ENGINE_ADDR") {
client.set_base_url(addr);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -1,7 +1,27 @@
use anyhow::Result;
use quote::quote;
use crate::{do_stdlib, parse_array_type};
fn clean_text(s: &str) -> String {
// Add newlines after end-braces at <= two levels of indentation.
if cfg!(not(windows)) {
let regex = regex::Regex::new(r"(})(\n\s{0,8}[^} ])").unwrap();
regex.replace_all(s, "$1\n$2").to_string()
} else {
let regex = regex::Regex::new(r"(})(\r\n\s{0,8}[^} ])").unwrap();
regex.replace_all(s, "$1\r\n$2").to_string()
}
}
/// Format a TokenStream as a string and run `rustfmt` on the result.
fn get_text_fmt(output: &proc_macro2::TokenStream) -> Result<String> {
// Format the file with rustfmt.
let content = rustfmt_wrapper::rustfmt(output).unwrap();
Ok(clean_text(&content))
}
#[test]
fn test_get_inner_array_type() {
for (expected, input) in [
@ -47,7 +67,7 @@ fn test_stdlib_line_to() {
let _expected = quote! {};
assert!(errors.is_empty());
expectorate::assert_contents("tests/lineTo.gen", &openapitor::types::get_text_fmt(&item).unwrap());
expectorate::assert_contents("tests/lineTo.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -88,7 +108,7 @@ fn test_stdlib_min() {
let _expected = quote! {};
assert!(errors.is_empty());
expectorate::assert_contents("tests/min.gen", &openapitor::types::get_text_fmt(&item).unwrap());
expectorate::assert_contents("tests/min.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -115,7 +135,7 @@ fn test_stdlib_show() {
let _expected = quote! {};
assert!(errors.is_empty());
expectorate::assert_contents("tests/show.gen", &openapitor::types::get_text_fmt(&item).unwrap());
expectorate::assert_contents("tests/show.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -143,7 +163,7 @@ fn test_stdlib_box() {
let _expected = quote! {};
assert!(errors.is_empty());
expectorate::assert_contents("tests/box.gen", &openapitor::types::get_text_fmt(&item).unwrap());
expectorate::assert_contents("tests/box.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -170,7 +190,7 @@ fn test_stdlib_option() {
.unwrap();
assert!(errors.is_empty());
expectorate::assert_contents("tests/option.gen", &openapitor::types::get_text_fmt(&item).unwrap());
expectorate::assert_contents("tests/option.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -203,7 +223,7 @@ fn test_stdlib_array() {
.unwrap();
assert!(errors.is_empty());
expectorate::assert_contents("tests/array.gen", &openapitor::types::get_text_fmt(&item).unwrap());
expectorate::assert_contents("tests/array.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -230,10 +250,7 @@ fn test_stdlib_option_input_format() {
.unwrap();
assert!(errors.is_empty());
expectorate::assert_contents(
"tests/option_input_format.gen",
&openapitor::types::get_text_fmt(&item).unwrap(),
);
expectorate::assert_contents("tests/option_input_format.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -260,10 +277,7 @@ fn test_stdlib_return_vec_sketch_group() {
.unwrap();
assert!(errors.is_empty());
expectorate::assert_contents(
"tests/return_vec_sketch_group.gen",
&openapitor::types::get_text_fmt(&item).unwrap(),
);
expectorate::assert_contents("tests/return_vec_sketch_group.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -290,10 +304,7 @@ fn test_stdlib_return_vec_box_sketch_group() {
.unwrap();
assert!(errors.is_empty());
expectorate::assert_contents(
"tests/return_vec_box_sketch_group.gen",
&openapitor::types::get_text_fmt(&item).unwrap(),
);
expectorate::assert_contents("tests/return_vec_box_sketch_group.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -326,10 +337,7 @@ fn test_stdlib_doc_comment_with_code() {
.unwrap();
assert!(errors.is_empty());
expectorate::assert_contents(
"tests/doc_comment_with_code.gen",
&openapitor::types::get_text_fmt(&item).unwrap(),
);
expectorate::assert_contents("tests/doc_comment_with_code.gen", &get_text_fmt(&item).unwrap());
}
#[test]
@ -364,7 +372,7 @@ fn test_stdlib_doc_comment_with_code_on_ignored_function() {
assert!(errors.is_empty());
expectorate::assert_contents(
"tests/doc_comment_with_code_on_ignored_function.gen",
&openapitor::types::get_text_fmt(&item).unwrap(),
&get_text_fmt(&item).unwrap(),
);
}

View File

@ -15,7 +15,11 @@ mod test_examples_show {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))
@ -55,7 +59,11 @@ mod test_examples_show {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -15,7 +15,11 @@ mod test_examples_show {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -15,7 +15,11 @@ mod test_examples_my_func {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))
@ -55,7 +59,11 @@ mod test_examples_my_func {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -16,7 +16,11 @@ mod test_examples_import {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))
@ -57,7 +61,11 @@ mod test_examples_import {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -15,7 +15,11 @@ mod test_examples_line_to {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))
@ -55,7 +59,11 @@ mod test_examples_line_to {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -15,7 +15,11 @@ mod test_examples_min {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))
@ -55,7 +59,11 @@ mod test_examples_min {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -15,7 +15,11 @@ mod test_examples_show {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -16,7 +16,11 @@ mod test_examples_import {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -16,7 +16,11 @@ mod test_examples_import {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -16,7 +16,11 @@ mod test_examples_import {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))

View File

@ -15,7 +15,11 @@ mod test_examples_show {
.tcp_keepalive(std::time::Duration::from_secs(600))
.http1_only();
let token = std::env::var("KITTYCAD_API_TOKEN").expect("KITTYCAD_API_TOKEN not set");
let client = kittycad::Client::new_from_reqwest(token, http_client, ws_client);
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);
}
let ws = client
.modeling()
.commands_ws(None, None, None, None, None, Some(false))