change TyF64 to f64 according to JsonSchema and cleanup docs code (#6081)
* cleanup gen_std Signed-off-by: Jess Frazelle <github@jessfraz.com> * cleanup docs Signed-off-by: Jess Frazelle <github@jessfraz.com> * updates Signed-off-by: Jess Frazelle <github@jessfraz.com> * fix table Signed-off-by: Jess Frazelle <github@jessfraz.com> --------- Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
@ -17,7 +17,7 @@ circle(@sketch_or_surface: Sketch | Plane | Face, center: Point2d, radius: numbe
|
||||
|
||||
| Name | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `sketch_or_surface` | [`Sketch`](/docs/kcl/types/Sketch) `|` [`Plane`](/docs/kcl/types/Face) `|` [`Plane`](/docs/kcl/types/Face) | Sketch to extend, or plane or surface to sketch on. | Yes |
|
||||
| `sketch_or_surface` | [`Sketch`](/docs/kcl/types/Sketch) OR [`Plane`](/docs/kcl/types/Plane) OR [`Face`](/docs/kcl/types/Face) | Sketch to extend, or plane or surface to sketch on. | Yes |
|
||||
| `center` | [`Point2d`](/docs/kcl/types/Point2d) | The center of the circle. | Yes |
|
||||
| `radius` | [`number`](/docs/kcl/types/number) | The radius of the circle. | Yes |
|
||||
| [`tag`](/docs/kcl/types/tag) | [`tag`](/docs/kcl/types/tag) | Create a new tag which refers to this circle. | No |
|
||||
|
@ -207302,372 +207302,8 @@
|
||||
},
|
||||
"definitions": {
|
||||
"TyF64": {
|
||||
"type": "object",
|
||||
"required": [
|
||||
"n",
|
||||
"ty"
|
||||
],
|
||||
"properties": {
|
||||
"n": {
|
||||
"type": "number",
|
||||
"format": "double"
|
||||
},
|
||||
"ty": {
|
||||
"$ref": "#/components/schemas/NumericType"
|
||||
}
|
||||
}
|
||||
},
|
||||
"NumericType": {
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Count"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A unit of length.",
|
||||
"type": "object",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Mm"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Cm"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"M"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Inches"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Feet"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Yards"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Length"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"description": "A unit of angle.",
|
||||
"type": "object",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Degrees"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Radians"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Angle"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Known"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"angle",
|
||||
"len",
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Default"
|
||||
]
|
||||
},
|
||||
"len": {
|
||||
"$ref": "#/components/schemas/UnitLen"
|
||||
},
|
||||
"angle": {
|
||||
"$ref": "#/components/schemas/UnitAngle"
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Unknown"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Any"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"UnitLen": {
|
||||
"description": "A unit of length.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Mm"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Cm"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"M"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Inches"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Feet"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Yards"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"UnitAngle": {
|
||||
"description": "A unit of angle.",
|
||||
"oneOf": [
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Degrees"
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": [
|
||||
"type"
|
||||
],
|
||||
"properties": {
|
||||
"type": {
|
||||
"type": "string",
|
||||
"enum": [
|
||||
"Radians"
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -28,7 +28,7 @@ An extrude plane.
|
||||
| `faceId` |[`string`](/docs/kcl/types/string)| The face id for the extrude plane. | No |
|
||||
| [`tag`](/docs/kcl/types/tag) |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag. | No |
|
||||
| `id` |[`string`](/docs/kcl/types/string)| The id of the geometry. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
| `sourceRange` |`[integer, integer, integer]`| The source range. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -48,7 +48,7 @@ An extruded arc.
|
||||
| `faceId` |[`string`](/docs/kcl/types/string)| The face id for the extrude plane. | No |
|
||||
| [`tag`](/docs/kcl/types/tag) |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag. | No |
|
||||
| `id` |[`string`](/docs/kcl/types/string)| The id of the geometry. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
| `sourceRange` |`[integer, integer, integer]`| The source range. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -68,7 +68,7 @@ Geometry metadata.
|
||||
| `faceId` |[`string`](/docs/kcl/types/string)| The id for the chamfer surface. | No |
|
||||
| [`tag`](/docs/kcl/types/tag) |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag. | No |
|
||||
| `id` |[`string`](/docs/kcl/types/string)| The id of the geometry. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
| `sourceRange` |`[integer, integer, integer]`| The source range. | No |
|
||||
|
||||
|
||||
----
|
||||
@ -88,7 +88,7 @@ Geometry metadata.
|
||||
| `faceId` |[`string`](/docs/kcl/types/string)| The id for the fillet surface. | No |
|
||||
| [`tag`](/docs/kcl/types/tag) |[`TagDeclarator`](/docs/kcl/types#tag-declaration)| The tag. | No |
|
||||
| `id` |[`string`](/docs/kcl/types/string)| The id of the geometry. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
| `sourceRange` |`[integer, integer, integer]`| The source range. | No |
|
||||
|
||||
|
||||
----
|
||||
|
@ -17,6 +17,6 @@ Geometry metadata.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `id` |[`string`](/docs/kcl/types/string)| The id of the geometry. | No |
|
||||
| `sourceRange` |[`SourceRange`](/docs/kcl/types/SourceRange)| The source range. | No |
|
||||
| `sourceRange` |`[integer, integer, integer]`| The source range. | No |
|
||||
|
||||
|
||||
|
@ -17,7 +17,7 @@ A helix.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `value` |[`string`](/docs/kcl/types/string)| The id of the helix. | No |
|
||||
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The artifact ID. | No |
|
||||
| `artifactId` |[`string`](/docs/kcl/types/string)| The artifact ID. | No |
|
||||
| `revolutions` |[`number`](/docs/kcl/types/number)| Number of revolutions. | No |
|
||||
| `angleStart` |[`number`](/docs/kcl/types/number)| Start angle (in degrees). | No |
|
||||
| `ccw` |`boolean`| Is the helix rotation counter clockwise? | No |
|
||||
|
@ -285,7 +285,7 @@ Data for an imported geometry.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `Module`| | No |
|
||||
| `value` |[`ModuleId`](/docs/kcl/types/ModuleId)| Identifier of a source file. Uses a u32 to keep the size small. | No |
|
||||
| `value` |`integer`| Identifier of a source file. Uses a u32 to keep the size small. | No |
|
||||
|
||||
|
||||
----
|
||||
|
@ -17,6 +17,6 @@ Data for polar coordinates.
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `angle` |[`number`](/docs/kcl/types/number)| The angle of the line (in degrees). | No |
|
||||
| `length` |[`TyF64`](/docs/kcl/types/TyF64)| The length of the line. | No |
|
||||
| `length` |[`number`](/docs/kcl/types/number)| The length of the line. | No |
|
||||
|
||||
|
||||
|
@ -25,7 +25,7 @@ A sketch type.
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `plane`| | No |
|
||||
| `id` |[`string`](/docs/kcl/types/string)| The id of the plane. | No |
|
||||
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The artifact ID. | No |
|
||||
| `artifactId` |[`string`](/docs/kcl/types/string)| The artifact ID. | No |
|
||||
| `value` |[`PlaneType`](/docs/kcl/types/PlaneType)| Type for a plane. | No |
|
||||
| `origin` |[`Point3d`](/docs/kcl/types/Point3d)| Origin of the plane. | No |
|
||||
| `xAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the plane's X axis be? | No |
|
||||
@ -49,7 +49,7 @@ A face.
|
||||
|----------|------|-------------|----------|
|
||||
| `type` |enum: `face`| | No |
|
||||
| `id` |[`string`](/docs/kcl/types/string)| The id of the face. | No |
|
||||
| `artifactId` |[`ArtifactId`](/docs/kcl/types/ArtifactId)| The artifact ID. | No |
|
||||
| `artifactId` |[`string`](/docs/kcl/types/string)| The artifact ID. | No |
|
||||
| `value` |[`string`](/docs/kcl/types/string)| The tag of the face. | No |
|
||||
| `xAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the face's X axis be? | No |
|
||||
| `yAxis` |[`Point3d`](/docs/kcl/types/Point3d)| What should the face's Y axis be? | No |
|
||||
|
@ -1,15 +0,0 @@
|
||||
---
|
||||
title: "SourceRange"
|
||||
excerpt: ""
|
||||
layout: manual
|
||||
---
|
||||
|
||||
|
||||
**Type:** `integer` (`uint`)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -5,17 +5,11 @@ layout: manual
|
||||
---
|
||||
|
||||
|
||||
**Type:** `object`
|
||||
**Type:** [`number`](/docs/kcl/types/number) (`double`)
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
## Properties
|
||||
|
||||
| Property | Type | Description | Required |
|
||||
|----------|------|-------------|----------|
|
||||
| `n` |[`number`](/docs/kcl/types/number)| | No |
|
||||
| `ty` |[`NumericType`](/docs/kcl/types/NumericType)| | No |
|
||||
|
||||
|
||||
|
@ -329,7 +329,7 @@ fn do_stdlib_inner(
|
||||
let camel_case_arg_name = to_camel_case(&arg_name);
|
||||
if ty_string != "ExecState" && ty_string != "Args" {
|
||||
let schema = quote! {
|
||||
#docs_crate::cleanup_number_tuples_root(generator.root_schema_for::<#ty_ident>())
|
||||
generator.root_schema_for::<#ty_ident>()
|
||||
};
|
||||
arg_types.push(quote! {
|
||||
#docs_crate::StdLibFnArg {
|
||||
@ -394,7 +394,7 @@ fn do_stdlib_inner(
|
||||
let return_type = if !ret_ty_string.is_empty() || ret_ty_string != "()" {
|
||||
let ret_ty_string = rust_type_to_openapi_type(&ret_ty_string);
|
||||
quote! {
|
||||
let schema = #docs_crate::cleanup_number_tuples_root(generator.root_schema_for::<#return_type_inner>());
|
||||
let schema = generator.root_schema_for::<#return_type_inner>();
|
||||
Some(#docs_crate::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: #ret_ty_string.to_string(),
|
||||
|
@ -102,7 +102,7 @@ impl crate::docs::StdLibFn for SomeFn {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "data".to_string(),
|
||||
type_: "Foo".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(generator.root_schema_for::<Foo>()),
|
||||
schema: generator.root_schema_for::<Foo>(),
|
||||
required: true,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -114,7 +114,7 @@ impl crate::docs::StdLibFn for SomeFn {
|
||||
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::<i32>());
|
||||
let schema = generator.root_schema_for::<i32>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "i32".to_string(),
|
||||
|
@ -102,7 +102,7 @@ impl crate::docs::StdLibFn for SomeFn {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "data".to_string(),
|
||||
type_: "string".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(generator.root_schema_for::<str>()),
|
||||
schema: generator.root_schema_for::<str>(),
|
||||
required: true,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -114,7 +114,7 @@ impl crate::docs::StdLibFn for SomeFn {
|
||||
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::<i32>());
|
||||
let schema = generator.root_schema_for::<i32>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "i32".to_string(),
|
||||
|
@ -103,9 +103,7 @@ impl crate::docs::StdLibFn for Show {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "args".to_string(),
|
||||
type_: "[number]".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<[f64; 2usize]>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<[f64; 2usize]>(),
|
||||
required: true,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -117,7 +115,7 @@ impl crate::docs::StdLibFn for Show {
|
||||
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>());
|
||||
let schema = generator.root_schema_for::<f64>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "number".to_string(),
|
||||
|
@ -103,7 +103,7 @@ impl crate::docs::StdLibFn for Show {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "args".to_string(),
|
||||
type_: "number".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(generator.root_schema_for::<f64>()),
|
||||
schema: generator.root_schema_for::<f64>(),
|
||||
required: true,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -115,7 +115,7 @@ impl crate::docs::StdLibFn for Show {
|
||||
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>());
|
||||
let schema = generator.root_schema_for::<f64>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "number".to_string(),
|
||||
|
@ -104,9 +104,7 @@ impl crate::docs::StdLibFn for MyFunc {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "args".to_string(),
|
||||
type_: "kittycad::types::InputFormat".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<Option<kittycad::types::InputFormat>>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<Option<kittycad::types::InputFormat>>(),
|
||||
required: false,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -118,8 +116,7 @@ impl crate::docs::StdLibFn for MyFunc {
|
||||
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::<Vec<Sketch>>());
|
||||
let schema = generator.root_schema_for::<Vec<Sketch>>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "[Sketch]".to_string(),
|
||||
|
@ -105,9 +105,7 @@ impl crate::docs::StdLibFn for LineTo {
|
||||
crate::docs::StdLibFnArg {
|
||||
name: "data".to_string(),
|
||||
type_: "LineToData".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<LineToData>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<LineToData>(),
|
||||
required: true,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -116,9 +114,7 @@ impl crate::docs::StdLibFn for LineTo {
|
||||
crate::docs::StdLibFnArg {
|
||||
name: "sketch".to_string(),
|
||||
type_: "Sketch".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<Sketch>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<Sketch>(),
|
||||
required: true,
|
||||
label_required: true,
|
||||
description: "the sketch you're adding the line to".to_string(),
|
||||
@ -131,7 +127,7 @@ impl crate::docs::StdLibFn for LineTo {
|
||||
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::<Sketch>());
|
||||
let schema = generator.root_schema_for::<Sketch>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "Sketch".to_string(),
|
||||
|
@ -103,9 +103,7 @@ impl crate::docs::StdLibFn for Min {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "args".to_string(),
|
||||
type_: "[number]".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<Vec<f64>>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<Vec<f64>>(),
|
||||
required: true,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -117,7 +115,7 @@ impl crate::docs::StdLibFn for Min {
|
||||
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>());
|
||||
let schema = generator.root_schema_for::<f64>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "number".to_string(),
|
||||
|
@ -103,9 +103,7 @@ impl crate::docs::StdLibFn for Show {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "args".to_string(),
|
||||
type_: "number".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<Option<f64>>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<Option<f64>>(),
|
||||
required: false,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -117,7 +115,7 @@ impl crate::docs::StdLibFn for Show {
|
||||
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>());
|
||||
let schema = generator.root_schema_for::<f64>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "number".to_string(),
|
||||
|
@ -103,9 +103,7 @@ impl crate::docs::StdLibFn for Import {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "args".to_string(),
|
||||
type_: "kittycad::types::InputFormat".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<Option<kittycad::types::InputFormat>>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<Option<kittycad::types::InputFormat>>(),
|
||||
required: false,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -117,7 +115,7 @@ impl crate::docs::StdLibFn for Import {
|
||||
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>());
|
||||
let schema = generator.root_schema_for::<f64>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "number".to_string(),
|
||||
|
@ -103,9 +103,7 @@ impl crate::docs::StdLibFn for Import {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "args".to_string(),
|
||||
type_: "kittycad::types::InputFormat".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<Option<kittycad::types::InputFormat>>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<Option<kittycad::types::InputFormat>>(),
|
||||
required: false,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -117,8 +115,7 @@ impl crate::docs::StdLibFn for Import {
|
||||
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::<Vec<Sketch>>());
|
||||
let schema = generator.root_schema_for::<Vec<Sketch>>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "[Sketch]".to_string(),
|
||||
|
@ -103,9 +103,7 @@ impl crate::docs::StdLibFn for Import {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "args".to_string(),
|
||||
type_: "kittycad::types::InputFormat".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<Option<kittycad::types::InputFormat>>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<Option<kittycad::types::InputFormat>>(),
|
||||
required: false,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -117,8 +115,7 @@ impl crate::docs::StdLibFn for Import {
|
||||
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::<Vec<Sketch>>());
|
||||
let schema = generator.root_schema_for::<Vec<Sketch>>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "[Sketch]".to_string(),
|
||||
|
@ -103,9 +103,7 @@ impl crate::docs::StdLibFn for Show {
|
||||
vec![crate::docs::StdLibFnArg {
|
||||
name: "args".to_string(),
|
||||
type_: "[number]".to_string(),
|
||||
schema: crate::docs::cleanup_number_tuples_root(
|
||||
generator.root_schema_for::<Vec<f64>>(),
|
||||
),
|
||||
schema: generator.root_schema_for::<Vec<f64>>(),
|
||||
required: true,
|
||||
label_required: true,
|
||||
description: String::new().to_string(),
|
||||
@ -117,7 +115,7 @@ impl crate::docs::StdLibFn for Show {
|
||||
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::<()>());
|
||||
let schema = generator.root_schema_for::<()>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "()".to_string(),
|
||||
|
@ -106,7 +106,7 @@ impl crate::docs::StdLibFn for SomeFunction {
|
||||
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::<i32>());
|
||||
let schema = generator.root_schema_for::<i32>();
|
||||
Some(crate::docs::StdLibFnArg {
|
||||
name: "".to_string(),
|
||||
type_: "i32".to_string(),
|
||||
|
@ -10,6 +10,7 @@ use convert_case::Casing;
|
||||
use handlebars::Renderable;
|
||||
use indexmap::IndexMap;
|
||||
use itertools::Itertools;
|
||||
use schemars::schema::SingleOrVec;
|
||||
use serde_json::json;
|
||||
use tokio::task::JoinSet;
|
||||
|
||||
@ -673,6 +674,7 @@ fn cleanup_type_links<'a>(output: &str, types: impl Iterator<Item = &'a String>)
|
||||
// TODO: This is a hack for the handlebars template being too complex.
|
||||
cleaned_output = cleaned_output.replace("`[, `number`, `number`]`", "`[number, number]`");
|
||||
cleaned_output = cleaned_output.replace("`[, `number`, `number`, `number`]`", "`[number, number, number]`");
|
||||
cleaned_output = cleaned_output.replace("`[, `integer`, `integer`, `integer`]`", "`[integer, integer, integer]`");
|
||||
|
||||
// Fix the links to the types.
|
||||
for type_name in types.map(|s| &**s).chain(DECLARED_TYPES) {
|
||||
@ -691,7 +693,7 @@ fn cleanup_type_links<'a>(output: &str, types: impl Iterator<Item = &'a String>)
|
||||
// TODO handle union types generically rather than special casing them.
|
||||
cleaned_output = cleaned_output.replace(
|
||||
"`Sketch | Plane | Face`",
|
||||
"[`Sketch`](/docs/kcl/types/Sketch) `|` [`Plane`](/docs/kcl/types/Face) `|` [`Plane`](/docs/kcl/types/Face)",
|
||||
"[`Sketch`](/docs/kcl/types/Sketch) OR [`Plane`](/docs/kcl/types/Plane) OR [`Face`](/docs/kcl/types/Face)",
|
||||
);
|
||||
|
||||
cleanup_static_links(&cleaned_output)
|
||||
@ -720,6 +722,11 @@ fn add_to_types(
|
||||
));
|
||||
};
|
||||
|
||||
if name == "SourceRange" {
|
||||
types.insert(name.to_string(), schema.clone());
|
||||
return Ok(());
|
||||
}
|
||||
|
||||
// If we have an array we want to generate the type markdown files for each item in the
|
||||
// array.
|
||||
if let Some(array) = &o.array {
|
||||
@ -727,7 +734,7 @@ fn add_to_types(
|
||||
if let Some(items) = &array.items {
|
||||
match items {
|
||||
schemars::schema::SingleOrVec::Single(item) => {
|
||||
if is_primitive(item)?.is_some() && name != "SourceRange" {
|
||||
if is_primitive(item)?.is_some() {
|
||||
return Ok(());
|
||||
}
|
||||
return add_to_types(name.trim_start_matches('[').trim_end_matches(']'), item, types);
|
||||
@ -816,9 +823,8 @@ fn generate_type(
|
||||
}
|
||||
|
||||
let cleaned_schema = recurse_and_create_references(name, schema, types)?;
|
||||
let new_schema = super::cleanup_number_tuples(&cleaned_schema);
|
||||
|
||||
let schemars::schema::Schema::Object(o) = new_schema else {
|
||||
let schemars::schema::Schema::Object(o) = cleaned_schema else {
|
||||
return Err(anyhow::anyhow!(
|
||||
"Failed to get object schema, should have not been a primitive"
|
||||
));
|
||||
@ -950,6 +956,13 @@ fn recurse_and_create_references(
|
||||
"Failed to get object schema, should have not been a primitive"
|
||||
));
|
||||
};
|
||||
|
||||
// If this is a primitive just use the primitive.
|
||||
if to.subschemas.is_none() && to.object.is_none() && to.reference.is_none() {
|
||||
return Ok(t.clone());
|
||||
}
|
||||
|
||||
// Otherwise append the metadata to our reference.
|
||||
if let Some(metadata) = obj.metadata.as_mut() {
|
||||
if metadata.description.is_none() {
|
||||
metadata.description = to.metadata.as_ref().and_then(|m| m.description.clone());
|
||||
@ -1052,6 +1065,13 @@ fn recurse_and_create_references(
|
||||
*item = new_item;
|
||||
}
|
||||
}
|
||||
|
||||
if subschema.one_of.is_none() && subschema.all_of.is_none() && subschema.any_of.is_none() && obj.array.is_none()
|
||||
{
|
||||
if let Some(SingleOrVec::Single(_)) = &o.instance_type {
|
||||
return Ok(schema.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let obj = cleanup_type_description(&obj)
|
||||
|
@ -660,69 +660,6 @@ pub fn get_description_string_from_schema(schema: &schemars::schema::RootSchema)
|
||||
None
|
||||
}
|
||||
|
||||
pub fn cleanup_number_tuples_root(mut schema: schemars::schema::RootSchema) -> schemars::schema::RootSchema {
|
||||
cleanup_number_tuples_object(&mut schema.schema);
|
||||
schema
|
||||
}
|
||||
|
||||
fn cleanup_number_tuples_object(o: &mut schemars::schema::SchemaObject) {
|
||||
if let Some(object) = &mut o.object {
|
||||
for (_, value) in object.properties.iter_mut() {
|
||||
*value = cleanup_number_tuples(value);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(array) = &mut o.array {
|
||||
if let Some(items) = &mut array.items {
|
||||
match items {
|
||||
schemars::schema::SingleOrVec::Single(_) => {
|
||||
// Do nothing since its only a single item.
|
||||
}
|
||||
schemars::schema::SingleOrVec::Vec(items) => {
|
||||
if items.len() == 2 {
|
||||
// Get the second item and see if its a NumericType.
|
||||
|
||||
if let Some(schemars::schema::Schema::Object(obj)) = items.get(1) {
|
||||
if let Some(reference) = &obj.reference {
|
||||
if reference == "#/components/schemas/NumericType" {
|
||||
// Get the first item.
|
||||
if let Some(schemars::schema::Schema::Object(obj2)) = items.first() {
|
||||
let mut obj2 = obj2.clone();
|
||||
obj2.metadata = o.metadata.clone();
|
||||
// Replace the array with the first item.
|
||||
*o = obj2;
|
||||
}
|
||||
}
|
||||
} else if NUMERIC_TYPE_SCHEMA.object == obj.object {
|
||||
if let Some(schemars::schema::Schema::Object(obj2)) = items.first() {
|
||||
let mut obj2 = obj2.clone();
|
||||
obj2.metadata = o.metadata.clone();
|
||||
// Replace the array with the first item.
|
||||
*o = obj2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Some numbers will be tuples of 2 where the second type is always "NumericType". We want to
|
||||
/// replace these with the first item in the array and not have an array as it messes
|
||||
/// with the docs generation which assumes if there is a tuple that you give 2 values not one
|
||||
/// in the form of an array.
|
||||
fn cleanup_number_tuples(schema: &schemars::schema::Schema) -> schemars::schema::Schema {
|
||||
let mut schema = schema.clone();
|
||||
|
||||
if let schemars::schema::Schema::Object(o) = &mut schema {
|
||||
cleanup_number_tuples_object(o);
|
||||
}
|
||||
|
||||
schema
|
||||
}
|
||||
|
||||
pub fn is_primitive(schema: &schemars::schema::Schema) -> Result<Option<Primitive>> {
|
||||
match schema {
|
||||
schemars::schema::Schema::Object(o) => {
|
||||
|
@ -72,7 +72,7 @@ impl KwArgs {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS, JsonSchema)]
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, ts_rs::TS)]
|
||||
#[ts(export)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct TyF64 {
|
||||
@ -98,6 +98,16 @@ impl TyF64 {
|
||||
}
|
||||
}
|
||||
|
||||
impl JsonSchema for TyF64 {
|
||||
fn schema_name() -> String {
|
||||
"TyF64".to_string()
|
||||
}
|
||||
|
||||
fn json_schema(gen: &mut schemars::gen::SchemaGenerator) -> schemars::schema::Schema {
|
||||
gen.subschema_for::<f64>()
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct Args {
|
||||
/// Positional args.
|
||||
|
Reference in New Issue
Block a user