Misc docs polishing (#6712)

* Fake modules for Rust std lib functions

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Include the missing @ in Rust std lib fns

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Move revolve and mirror2d to better modules

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Use docs from KCL mods for type summaries

Signed-off-by: Nick Cameron <nrc@ncameron.org>

* Use type docs to describe types from KCL std lib

Signed-off-by: Nick Cameron <nrc@ncameron.org>

---------

Signed-off-by: Nick Cameron <nrc@ncameron.org>
This commit is contained in:
Nick Cameron
2025-05-06 16:09:59 +12:00
committed by GitHub
parent 1e056cfd8a
commit 1841e63021
116 changed files with 1178 additions and 1095 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -34,7 +34,7 @@ helix(
### Returns
[`Helix`](/docs/kcl-std/types/std-types-Helix)
[`Helix`](/docs/kcl-std/types/std-types-Helix) - A helix.
### Examples

View File

@ -16,11 +16,11 @@ abs(@input: number): number
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | | Yes |
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | A number | Yes |
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -16,11 +16,11 @@ ceil(@input: number): number
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | | Yes |
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | A number | Yes |
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -16,11 +16,11 @@ floor(@input: number): number
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | | Yes |
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | A number | Yes |
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -16,11 +16,11 @@ ln(@input: number): number
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | | Yes |
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | A number | Yes |
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -26,7 +26,7 @@ log(
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -16,11 +16,11 @@ log10(@input: number): number
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | | Yes |
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | A number | Yes |
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -16,11 +16,11 @@ log2(@input: number): number
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | | Yes |
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | A number | Yes |
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -20,7 +20,7 @@ max(@input: [number; 1+]): number
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -20,7 +20,7 @@ min(@input: [number; 1+]): number
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -25,7 +25,7 @@ polar(
### Returns
[`Point2d`](/docs/kcl-std/types/std-types-Point2d)
[`Point2d`](/docs/kcl-std/types/std-types-Point2d) - A point in two dimensional space.
### Examples

View File

@ -24,7 +24,7 @@ pow(
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -25,7 +25,7 @@ rem(
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -16,11 +16,11 @@ round(@input: number): number
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | | Yes |
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | A number | Yes |
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -16,11 +16,11 @@ sqrt(@input: number): number
| Name | Type | Description | Required |
|----------|------|-------------|----------|
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | | Yes |
| `input` | [`number`](/docs/kcl-std/types/std-types-number) | A number | Yes |
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -25,7 +25,7 @@ offsetPlane(
### Returns
[`Plane`](/docs/kcl-std/types/std-types-Plane)
[`Plane`](/docs/kcl-std/types/std-types-Plane) - A plane.
### Examples

File diff suppressed because one or more lines are too long

View File

@ -29,7 +29,7 @@ circle(
### Returns
[`Sketch`](/docs/kcl-std/types/std-types-Sketch)
[`Sketch`](/docs/kcl-std/types/std-types-Sketch) - A sketch is a collection of paths.
### Examples

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -30,7 +30,7 @@ chamfer(
### Returns
[`Solid`](/docs/kcl-std/types/std-types-Solid)
[`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extrude surfaces.
### Examples

View File

@ -32,7 +32,7 @@ fillet(
### Returns
[`Solid`](/docs/kcl-std/types/std-types-Solid)
[`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extrude surfaces.
### Examples

View File

@ -25,7 +25,7 @@ hollow(
### Returns
[`Solid`](/docs/kcl-std/types/std-types-Solid)
[`Solid`](/docs/kcl-std/types/std-types-Solid) - A solid is a collection of extrude surfaces.
### Examples

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,68 +9,18 @@ layout: manual
### Functions
* [**std**](/docs/kcl-std/modules/std)
* [`angledLine`](/docs/kcl-std/angledLine)
* [`angledLineThatIntersects`](/docs/kcl-std/angledLineThatIntersects)
* [`appearance`](/docs/kcl-std/appearance)
* [`arc`](/docs/kcl-std/arc)
* [`assert`](/docs/kcl-std/assert)
* [`assertIs`](/docs/kcl-std/assertIs)
* [`bezierCurve`](/docs/kcl-std/bezierCurve)
* [`circleThreePoint`](/docs/kcl-std/circleThreePoint)
* [`clone`](/docs/kcl-std/clone)
* [`close`](/docs/kcl-std/close)
* [`extrude`](/docs/kcl-std/extrude)
* [`getCommonEdge`](/docs/kcl-std/getCommonEdge)
* [`getNextAdjacentEdge`](/docs/kcl-std/getNextAdjacentEdge)
* [`getOppositeEdge`](/docs/kcl-std/getOppositeEdge)
* [`getPreviousAdjacentEdge`](/docs/kcl-std/getPreviousAdjacentEdge)
* [`helix`](/docs/kcl-std/functions/std-helix)
* [`intersect`](/docs/kcl-std/intersect)
* [`involuteCircular`](/docs/kcl-std/involuteCircular)
* [`lastSegX`](/docs/kcl-std/lastSegX)
* [`lastSegY`](/docs/kcl-std/lastSegY)
* [`legAngX`](/docs/kcl-std/legAngX)
* [`legAngY`](/docs/kcl-std/legAngY)
* [`legLen`](/docs/kcl-std/legLen)
* [`line`](/docs/kcl-std/line)
* [`loft`](/docs/kcl-std/loft)
* [`map`](/docs/kcl-std/map)
* [`offsetPlane`](/docs/kcl-std/functions/std-offsetPlane)
* [`patternCircular2d`](/docs/kcl-std/patternCircular2d)
* [`patternCircular3d`](/docs/kcl-std/patternCircular3d)
* [`patternLinear2d`](/docs/kcl-std/patternLinear2d)
* [`patternLinear3d`](/docs/kcl-std/patternLinear3d)
* [`patternTransform`](/docs/kcl-std/patternTransform)
* [`patternTransform2d`](/docs/kcl-std/patternTransform2d)
* [`polygon`](/docs/kcl-std/polygon)
* [**std::array**](/docs/kcl-std/modules/std-array)
* [`map`](/docs/kcl-std/map)
* [`pop`](/docs/kcl-std/pop)
* [`profileStart`](/docs/kcl-std/profileStart)
* [`profileStartX`](/docs/kcl-std/profileStartX)
* [`profileStartY`](/docs/kcl-std/profileStartY)
* [`push`](/docs/kcl-std/push)
* [`reduce`](/docs/kcl-std/reduce)
* [`revolve`](/docs/kcl-std/functions/std-revolve)
* [`rotate`](/docs/kcl-std/rotate)
* [`scale`](/docs/kcl-std/scale)
* [`segAng`](/docs/kcl-std/segAng)
* [`segEnd`](/docs/kcl-std/segEnd)
* [`segEndX`](/docs/kcl-std/segEndX)
* [`segEndY`](/docs/kcl-std/segEndY)
* [`segLen`](/docs/kcl-std/segLen)
* [`segStart`](/docs/kcl-std/segStart)
* [`segStartX`](/docs/kcl-std/segStartX)
* [`segStartY`](/docs/kcl-std/segStartY)
* [`startProfile`](/docs/kcl-std/startProfile)
* [`startSketchOn`](/docs/kcl-std/startSketchOn)
* [`subtract`](/docs/kcl-std/subtract)
* [`subtract2d`](/docs/kcl-std/subtract2d)
* [`sweep`](/docs/kcl-std/sweep)
* [`tangentToEnd`](/docs/kcl-std/tangentToEnd)
* [`tangentialArc`](/docs/kcl-std/tangentialArc)
* [`translate`](/docs/kcl-std/translate)
* [`union`](/docs/kcl-std/union)
* [`xLine`](/docs/kcl-std/xLine)
* [`yLine`](/docs/kcl-std/yLine)
* [**std::math**](/docs/kcl-std/modules/std-math)
* [`abs`](/docs/kcl-std/functions/std-math-abs)
* [`acos`](/docs/kcl-std/functions/std-math-acos)
@ -80,6 +30,9 @@ layout: manual
* [`ceil`](/docs/kcl-std/functions/std-math-ceil)
* [`cos`](/docs/kcl-std/functions/std-math-cos)
* [`floor`](/docs/kcl-std/functions/std-math-floor)
* [`legAngX`](/docs/kcl-std/legAngX)
* [`legAngY`](/docs/kcl-std/legAngY)
* [`legLen`](/docs/kcl-std/legLen)
* [`ln`](/docs/kcl-std/functions/std-math-ln)
* [`log`](/docs/kcl-std/functions/std-math-log)
* [`log10`](/docs/kcl-std/functions/std-math-log10)
@ -94,13 +47,62 @@ layout: manual
* [`sqrt`](/docs/kcl-std/functions/std-math-sqrt)
* [`tan`](/docs/kcl-std/functions/std-math-tan)
* [**std::sketch**](/docs/kcl-std/modules/std-sketch)
* [`angledLine`](/docs/kcl-std/angledLine)
* [`angledLineThatIntersects`](/docs/kcl-std/angledLineThatIntersects)
* [`arc`](/docs/kcl-std/arc)
* [`bezierCurve`](/docs/kcl-std/bezierCurve)
* [`circle`](/docs/kcl-std/functions/std-sketch-circle)
* [`mirror2d`](/docs/kcl-std/functions/std-sketch-mirror2d)
* [`circleThreePoint`](/docs/kcl-std/circleThreePoint)
* [`close`](/docs/kcl-std/close)
* [`extrude`](/docs/kcl-std/extrude)
* [`getCommonEdge`](/docs/kcl-std/getCommonEdge)
* [`getNextAdjacentEdge`](/docs/kcl-std/getNextAdjacentEdge)
* [`getOppositeEdge`](/docs/kcl-std/getOppositeEdge)
* [`getPreviousAdjacentEdge`](/docs/kcl-std/getPreviousAdjacentEdge)
* [`involuteCircular`](/docs/kcl-std/involuteCircular)
* [`lastSegX`](/docs/kcl-std/lastSegX)
* [`lastSegY`](/docs/kcl-std/lastSegY)
* [`line`](/docs/kcl-std/line)
* [`loft`](/docs/kcl-std/loft)
* [`patternCircular2d`](/docs/kcl-std/patternCircular2d)
* [`patternTransform2d`](/docs/kcl-std/patternTransform2d)
* [`polygon`](/docs/kcl-std/polygon)
* [`profileStart`](/docs/kcl-std/profileStart)
* [`profileStartX`](/docs/kcl-std/profileStartX)
* [`profileStartY`](/docs/kcl-std/profileStartY)
* [`revolve`](/docs/kcl-std/functions/std-sketch-revolve)
* [`segAng`](/docs/kcl-std/segAng)
* [`segEnd`](/docs/kcl-std/segEnd)
* [`segEndX`](/docs/kcl-std/segEndX)
* [`segEndY`](/docs/kcl-std/segEndY)
* [`segLen`](/docs/kcl-std/segLen)
* [`segStart`](/docs/kcl-std/segStart)
* [`segStartX`](/docs/kcl-std/segStartX)
* [`segStartY`](/docs/kcl-std/segStartY)
* [`startProfile`](/docs/kcl-std/startProfile)
* [`startSketchOn`](/docs/kcl-std/startSketchOn)
* [`subtract2d`](/docs/kcl-std/subtract2d)
* [`sweep`](/docs/kcl-std/sweep)
* [`tangentToEnd`](/docs/kcl-std/tangentToEnd)
* [`tangentialArc`](/docs/kcl-std/tangentialArc)
* [`xLine`](/docs/kcl-std/xLine)
* [`yLine`](/docs/kcl-std/yLine)
* [**std::solid**](/docs/kcl-std/modules/std-solid)
* [`chamfer`](/docs/kcl-std/functions/std-solid-chamfer)
* [`fillet`](/docs/kcl-std/functions/std-solid-fillet)
* [`hollow`](/docs/kcl-std/functions/std-solid-hollow)
* [`intersect`](/docs/kcl-std/intersect)
* [`patternCircular3d`](/docs/kcl-std/patternCircular3d)
* [`patternLinear3d`](/docs/kcl-std/patternLinear3d)
* [`patternTransform`](/docs/kcl-std/patternTransform)
* [`shell`](/docs/kcl-std/functions/std-solid-shell)
* [`subtract`](/docs/kcl-std/subtract)
* [`union`](/docs/kcl-std/union)
* [**std::transform**](/docs/kcl-std/modules/std-transform)
* [`mirror2d`](/docs/kcl-std/functions/std-transform-mirror2d)
* [`rotate`](/docs/kcl-std/rotate)
* [`scale`](/docs/kcl-std/scale)
* [`translate`](/docs/kcl-std/translate)
* [**std::units**](/docs/kcl-std/modules/std-units)
* [`units::toCentimeters`](/docs/kcl-std/functions/std-units-toCentimeters)
* [`units::toDegrees`](/docs/kcl-std/functions/std-units-toDegrees)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,5 +1,5 @@
---
title: "legAngX"
title: "std::math::legAngX"
excerpt: "Compute the angle of the given leg for x."
layout: manual
---
@ -24,7 +24,7 @@ legAngX(
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -1,5 +1,5 @@
---
title: "legAngY"
title: "std::math::legAngY"
excerpt: "Compute the angle of the given leg for y."
layout: manual
---
@ -24,7 +24,7 @@ legAngY(
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

View File

@ -1,5 +1,5 @@
---
title: "legLen"
title: "std::math::legLen"
excerpt: "Compute the length of the given leg."
layout: manual
---
@ -24,7 +24,7 @@ legLen(
### Returns
[`number`](/docs/kcl-std/types/std-types-number)
[`number`](/docs/kcl-std/types/std-types-number) - A number
### Examples

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -0,0 +1,12 @@
---
title: "std::array"
excerpt: ""
layout: manual
---

View File

@ -12,5 +12,5 @@ layout: manual
## Functions and constants
* [`circle`](/docs/kcl-std/functions/std-sketch-circle)
* [`mirror2d`](/docs/kcl-std/functions/std-sketch-mirror2d)
* [`revolve`](/docs/kcl-std/functions/std-sketch-revolve)

View File

@ -0,0 +1,15 @@
---
title: "std::transform"
excerpt: ""
layout: manual
---
## Functions and constants
* [`mirror2d`](/docs/kcl-std/functions/std-transform-mirror2d)

View File

@ -10,9 +10,11 @@ Contains frequently used constants, functions for interacting with the KittyCAD
## Modules
* [`array`](/docs/kcl-std/modules/std-array)
* [`math`](/docs/kcl-std/modules/std-math)
* [`sketch`](/docs/kcl-std/modules/std-sketch)
* [`solid`](/docs/kcl-std/modules/std-solid)
* [`transform`](/docs/kcl-std/modules/std-transform)
* [`turns::turns`](/docs/kcl-std/modules/std-turns)
* [`types`](/docs/kcl-std/modules/std-types)
* [`units::units`](/docs/kcl-std/modules/std-units)
@ -29,5 +31,4 @@ Contains frequently used constants, functions for interacting with the KittyCAD
* [`Z`](/docs/kcl-std/consts/std-Z)
* [`helix`](/docs/kcl-std/functions/std-helix)
* [`offsetPlane`](/docs/kcl-std/functions/std-offsetPlane)
* [`revolve`](/docs/kcl-std/functions/std-revolve)

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -9,13 +9,11 @@ use serde_json::json;
use tokio::task::JoinSet;
use super::kcl_doc::{ConstData, DocData, ExampleProperties, FnData, ModData, TyData};
use crate::{docs::StdLibFn, std::StdLib, ExecutorContext};
// These types are declared in (KCL) std.
const DECLARED_TYPES: [&str; 15] = [
"any", "number", "string", "tag", "bool", "Sketch", "Solid", "Plane", "Helix", "Face", "Edge", "Point2d",
"Point3d", "Axis2d", "Axis3d",
];
use crate::{
docs::{StdLibFn, DECLARED_TYPES},
std::StdLib,
ExecutorContext,
};
// Types with special handling.
const SPECIAL_TYPES: [&str; 5] = ["TagDeclarator", "TagIdentifier", "Start", "End", "ImportedGeometry"];
@ -126,9 +124,12 @@ fn generate_index(combined: &IndexMap<String, Box<dyn StdLibFn>>, kcl_lib: &ModD
continue;
}
let tags = internal_fn.tags();
let module = tags.first().map(|s| format!("std::{s}")).unwrap_or("std".to_owned());
functions
.get_mut("std")
.unwrap()
.entry(module.to_owned())
.or_default()
.push((internal_fn.name(), internal_fn.name()));
}
@ -319,7 +320,12 @@ fn generate_mod_from_kcl(m: &ModData, file_name: String) -> Result<()> {
Ok(())
}
fn generate_function_from_kcl(function: &FnData, file_name: String, example_name: String) -> Result<()> {
fn generate_function_from_kcl(
function: &FnData,
file_name: String,
example_name: String,
kcl_std: &ModData,
) -> Result<()> {
if function.properties.doc_hidden {
return Ok(());
}
@ -344,14 +350,14 @@ fn generate_function_from_kcl(function: &FnData, file_name: String, example_name
json!({
"name": arg.name,
"type_": arg.ty,
"description": arg.docs.as_deref().unwrap_or(""),
"description": arg.docs.clone().or_else(|| arg.ty.as_ref().and_then(|t| super::docs_for_type(t, kcl_std))).unwrap_or_default(),
"required": arg.kind.required(),
})
}).collect::<Vec<_>>(),
"return_value": function.return_type.as_ref().map(|t| {
json!({
"type_": t,
"description": "",
"description": super::docs_for_type(t, kcl_std).unwrap_or_default(),
})
}),
});
@ -392,7 +398,7 @@ fn generate_const_from_kcl(cnst: &ConstData, file_name: String, example_name: St
Ok(())
}
fn generate_function(internal_fn: Box<dyn StdLibFn>) -> Result<()> {
fn generate_function(internal_fn: Box<dyn StdLibFn>, kcl_std: &ModData) -> Result<()> {
let hbs = init_handlebars()?;
if internal_fn.unpublished() {
@ -428,8 +434,11 @@ fn generate_function(internal_fn: Box<dyn StdLibFn>) -> Result<()> {
})
.collect();
let tags = internal_fn.tags();
let qual = tags.first().map(|s| &**s).unwrap_or("");
let data = json!({
"name": fn_name,
"name": format!("std::{qual}{}{fn_name}", if qual.is_empty() { "" } else {"::"}),
"summary": internal_fn.summary(),
"description": internal_fn.description(),
"deprecated": internal_fn.deprecated(),
@ -439,14 +448,14 @@ fn generate_function(internal_fn: Box<dyn StdLibFn>) -> Result<()> {
json!({
"name": arg.name,
"type_": rename_type(&arg.type_),
"description": arg.description(),
"description": arg.description(Some(kcl_std)),
"required": arg.required,
})
}).collect::<Vec<_>>(),
"return_value": internal_fn.return_value(false).map(|ret| {
json!({
"type_": rename_type(&ret.type_),
"description": ret.description(),
"description": ret.description(Some(kcl_std)),
})
}),
});
@ -651,12 +660,12 @@ fn test_generate_stdlib_markdown_docs() {
for key in combined.keys().sorted() {
let internal_fn = combined.get(key).unwrap();
generate_function(internal_fn.clone()).unwrap();
generate_function(internal_fn.clone(), &kcl_std).unwrap();
}
for d in kcl_std.all_docs() {
match d {
DocData::Fn(f) => generate_function_from_kcl(f, d.file_name(), d.example_name()).unwrap(),
DocData::Fn(f) => generate_function_from_kcl(f, d.file_name(), d.example_name(), &kcl_std).unwrap(),
DocData::Const(c) => generate_const_from_kcl(c, d.file_name(), d.example_name()).unwrap(),
DocData::Ty(t) => generate_type_from_kcl(t, d.file_name(), d.example_name()).unwrap(),
DocData::Mod(m) => generate_mod_from_kcl(m, d.file_name()).unwrap(),

View File

@ -307,6 +307,15 @@ impl DocData {
_ => unreachable!(),
}
}
pub(super) fn summary(&self) -> Option<&String> {
match self {
DocData::Fn(f) => f.summary.as_ref(),
DocData::Const(c) => c.summary.as_ref(),
DocData::Ty(t) => t.summary.as_ref(),
DocData::Mod(m) => m.summary.as_ref(),
}
}
}
#[derive(Debug, Clone)]
@ -459,7 +468,6 @@ impl ModData {
}
}
#[cfg(test)]
pub fn find_by_name(&self, name: &str) -> Option<&DocData> {
if let Some(result) = self.children.values().find(|dd| dd.name() == name) {
return Some(result);

View File

@ -10,6 +10,7 @@ use std::{
};
use anyhow::Result;
use kcl_doc::ModData;
use schemars::JsonSchema;
use serde::{Deserialize, Serialize};
use tower_lsp::lsp_types::{
@ -22,6 +23,12 @@ use crate::{
std::Primitive,
};
// These types are declared in (KCL) std.
const DECLARED_TYPES: [&str; 15] = [
"any", "number", "string", "tag", "bool", "Sketch", "Solid", "Plane", "Helix", "Face", "Edge", "Point2d",
"Point3d", "Axis2d", "Axis3d",
];
lazy_static::lazy_static! {
static ref NUMERIC_TYPE_SCHEMA: schemars::schema::SchemaObject = {
let mut settings = schemars::gen::SchemaSettings::openapi3();
@ -94,6 +101,9 @@ pub struct StdLibFnArg {
impl fmt::Display for StdLibFnArg {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
if !self.label_required {
f.write_char('@')?;
}
f.write_str(&self.name)?;
if !self.required {
f.write_char('?')?;
@ -154,11 +164,18 @@ impl StdLibFnArg {
.map(|maybe| maybe.map(|(index, snippet)| (index, format!("{label}{snippet}"))))
}
pub fn description(&self) -> Option<String> {
pub fn description(&self, kcl_std: Option<&ModData>) -> Option<String> {
// Check if we explicitly gave this stdlib arg a description.
if !self.description.is_empty() {
return Some(self.description.clone());
}
if let Some(kcl_std) = kcl_std {
if let Some(t) = docs_for_type(&self.type_, kcl_std) {
return Some(t);
}
}
// If not, then try to get something meaningful from the schema.
get_description_string_from_schema(&self.schema.clone())
}
@ -370,7 +387,7 @@ impl From<StdLibFnArg> for ParameterInformation {
fn from(arg: StdLibFnArg) -> Self {
ParameterInformation {
label: ParameterLabel::Simple(arg.name.to_string()),
documentation: arg.description().map(|description| {
documentation: arg.description(None).map(|description| {
Documentation::MarkupContent(MarkupContent {
kind: MarkupKind::Markdown,
value: description,
@ -380,6 +397,16 @@ impl From<StdLibFnArg> for ParameterInformation {
}
}
fn docs_for_type(ty: &str, kcl_std: &ModData) -> Option<String> {
if DECLARED_TYPES.contains(&ty) {
if let Some(data) = kcl_std.find_by_name(ty) {
return data.summary().cloned();
}
}
None
}
/// This trait defines functions called upon stdlib functions to generate
/// documentation for them.
pub trait StdLibFn: std::fmt::Debug + Send + Sync {
@ -1128,7 +1155,7 @@ mod tests {
assert_eq!(
sh.signatures[0].label,
r#"extrude(
sketches: [Sketch],
@sketches: [Sketch],
length: number,
symmetric?: bool,
bidirectionalLength?: number,

View File

@ -1116,7 +1116,7 @@ async fn test_kcl_lsp_signature_help() {
assert_eq!(
signature_help.signatures[0].label,
r#"startSketchOn(
planeOrSolid: SketchData,
@planeOrSolid: SketchData,
face?: FaceTag,
): SketchSurface"#
);
@ -1205,7 +1205,7 @@ a1 = startSketchOn(offsetPlane(XY, offset = 10))
assert_eq!(
signature_help.signatures[0].label,
r#"extrude(
sketches: [Sketch],
@sketches: [Sketch],
length: number,
symmetric?: bool,
bidirectionalLength?: number,
@ -1303,7 +1303,7 @@ a1 = startSketchOn(offsetPlane(XY, offset = 10))
assert_eq!(
signature_help.signatures[0].label,
r#"extrude(
sketches: [Sketch],
@sketches: [Sketch],
length: number,
symmetric?: bool,
bidirectionalLength?: number,
@ -1396,7 +1396,7 @@ a1 = startSketchOn(offsetPlane(XY, offset = 10))
assert_eq!(
signature_help.signatures[0].label,
r#"extrude(
sketches: [Sketch],
@sketches: [Sketch],
length: number,
symmetric?: bool,
bidirectionalLength?: number,
@ -1494,7 +1494,7 @@ a1 = startSketchOn(offsetPlane(XY, offset = 10))
assert_eq!(
signature_help.signatures[0].label,
r#"extrude(
sketches: [Sketch],
@sketches: [Sketch],
length: number,
symmetric?: bool,
bidirectionalLength?: number,

View File

@ -95,6 +95,8 @@ pub(crate) fn read_std(mod_name: &str) -> Option<&'static str> {
"types" => Some(include_str!("../std/types.kcl")),
"solid" => Some(include_str!("../std/solid.kcl")),
"units" => Some(include_str!("../std/units.kcl")),
"array" => Some(include_str!("../std/array.kcl")),
"transform" => Some(include_str!("../std/transform.kcl")),
_ => None,
}
}

View File

@ -236,13 +236,13 @@ pub(crate) fn std_fn(path: &str, fn_name: &str) -> (crate::std::StdFn, StdFnProp
|e, a| Box::pin(crate::std::helix::helix(e, a)),
StdFnProps::default("std::helix").include_in_feature_tree(),
),
("sketch", "mirror2d") => (
("transform", "mirror2d") => (
|e, a| Box::pin(crate::std::mirror::mirror_2d(e, a)),
StdFnProps::default("std::sketch::mirror2d"),
StdFnProps::default("std::transform::mirror2d"),
),
("prelude", "revolve") => (
("sketch", "revolve") => (
|e, a| Box::pin(crate::std::revolve::revolve(e, a)),
StdFnProps::default("std::revolve").include_in_feature_tree(),
StdFnProps::default("std::sketch::revolve").include_in_feature_tree(),
),
("prelude", "offsetPlane") => (
|e, a| Box::pin(crate::std::planes::offset_plane(e, a)),

View File

@ -0,0 +1,2 @@
@no_std
@settings(defaultLengthUnit = mm, kclVersion = 1.0)

View File

@ -10,9 +10,11 @@
export import * from "std::types"
export import "std::units"
export import * from "std::array"
export import * from "std::math"
export import * from "std::sketch"
export import * from "std::solid"
export import * from "std::transform"
export import "std::turns"
export XY = {
@ -149,245 +151,6 @@ export fn helix(
cylinder?: Solid,
): Helix {}
/// Rotate a sketch around some provided axis, creating a solid from its extent.
///
/// This, like extrude, is able to create a 3-dimensional solid from a
/// 2-dimensional sketch. However, unlike extrude, this creates a solid
/// by using the extent of the sketch as its revolved around an axis rather
/// than using the extent of the sketch linearly translated through a third
/// dimension.
///
/// Revolve occurs around a local sketch axis rather than a global axis.
///
/// You can provide more than one sketch to revolve, and they will all be
/// revolved around the same axis.
///
/// ```
/// part001 = startSketchOn(XY)
/// |> startProfile(at = [4, 12])
/// |> line(end = [2, 0])
/// |> line(end = [0, -6])
/// |> line(end = [4, -6])
/// |> line(end = [0, -6])
/// |> line(end = [-3.75, -4.5])
/// |> line(end = [0, -5.5])
/// |> line(end = [-2, 0])
/// |> close()
/// |> revolve(axis = Y) // default angle is 360
/// ```
///
/// ```
/// // A donut shape.
/// sketch001 = startSketchOn(XY)
/// |> circle( center = [15, 0], radius = 5 )
/// |> revolve(
/// angle = 360,
/// axis = Y,
/// )
/// ```
///
/// ```
/// part001 = startSketchOn(XY)
/// |> startProfile(at = [4, 12])
/// |> line(end = [2, 0])
/// |> line(end = [0, -6])
/// |> line(end = [4, -6])
/// |> line(end = [0, -6])
/// |> line(end = [-3.75, -4.5])
/// |> line(end = [0, -5.5])
/// |> line(end = [-2, 0])
/// |> close()
/// |> revolve(axis = Y, angle = 180)
/// ```
///
/// ```
/// part001 = startSketchOn(XY)
/// |> startProfile(at = [4, 12])
/// |> line(end = [2, 0])
/// |> line(end = [0, -6])
/// |> line(end = [4, -6])
/// |> line(end = [0, -6])
/// |> line(end = [-3.75, -4.5])
/// |> line(end = [0, -5.5])
/// |> line(end = [-2, 0])
/// |> close()
/// |> revolve(axis = Y, angle = 180)
///
/// part002 = startSketchOn(part001, face = END)
/// |> startProfile(at = [4.5, -5])
/// |> line(end = [0, 5])
/// |> line(end = [5, 0])
/// |> line(end = [0, -5])
/// |> close()
/// |> extrude(length = 5)
/// ```
///
/// ```
/// box = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20])
/// |> line(end = [20, 0])
/// |> line(end = [0, -20])
/// |> close()
/// |> extrude(length = 20)
///
/// sketch001 = startSketchOn(box, face = END)
/// |> circle( center = [10,10], radius = 4 )
/// |> revolve(
/// angle = -90,
/// axis = Y
/// )
/// ```
///
/// ```
/// box = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20])
/// |> line(end = [20, 0])
/// |> line(end = [0, -20], tag = $revolveAxis)
/// |> close()
/// |> extrude(length = 20)
///
/// sketch001 = startSketchOn(box, face = END)
/// |> circle( center = [10,10], radius = 4 )
/// |> revolve(
/// angle = 90,
/// axis = getOppositeEdge(revolveAxis)
/// )
/// ```
///
/// ```
/// box = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20])
/// |> line(end = [20, 0])
/// |> line(end = [0, -20], tag = $revolveAxis)
/// |> close()
/// |> extrude(length = 20)
///
/// sketch001 = startSketchOn(box, face = END)
/// |> circle( center = [10,10], radius = 4 )
/// |> revolve(
/// angle = 90,
/// axis = getOppositeEdge(revolveAxis),
/// tolerance = 0.0001
/// )
/// ```
///
/// ```
/// sketch001 = startSketchOn(XY)
/// |> startProfile(at = [10, 0])
/// |> line(end = [5, -5])
/// |> line(end = [5, 5])
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close()
///
/// part001 = revolve(
/// sketch001,
/// axis = {
/// direction = [0.0, 1.0],
/// origin = [0.0, 0.0]
/// }
/// )
/// ```
///
/// ```
/// // Revolve two sketches around the same axis.
///
/// sketch001 = startSketchOn(XY)
/// profile001 = startProfile(sketch001, at = [4, 8])
/// |> xLine(length = 3)
/// |> yLine(length = -3)
/// |> xLine(length = -3)
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close()
///
/// profile002 = startProfile(sketch001, at = [-5, 8])
/// |> xLine(length = 3)
/// |> yLine(length = -3)
/// |> xLine(length = -3)
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close()
///
/// revolve(
/// [profile001, profile002],
/// axis = X,
/// )
/// ```
///
/// ```
/// // Revolve around a path that has not been extruded.
///
/// profile001 = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20], tag = $revolveAxis)
/// |> line(end = [20, 0])
/// |> line(end = [0, -20])
/// |> close(%)
///
/// sketch001 = startSketchOn(XY)
/// |> circle(center = [-10, 10], radius = 4)
/// |> revolve(angle = 90, axis = revolveAxis)
/// ```
///
/// ```
/// // Revolve around a path that has not been extruded or closed.
///
/// profile001 = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20], tag = $revolveAxis)
/// |> line(end = [20, 0])
///
/// sketch001 = startSketchOn(XY)
/// |> circle(center = [-10, 10], radius = 4)
/// |> revolve(angle = 90, axis = revolveAxis)
/// ```
///
/// ```
/// // Symmetrically revolve around a path.
///
/// profile001 = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20], tag = $revolveAxis)
/// |> line(end = [20, 0])
///
/// sketch001 = startSketchOn(XY)
/// |> circle(center = [-10, 10], radius = 4)
/// |> revolve(angle = 90, axis = revolveAxis, symmetric = true)
/// ```
///
/// ```
/// // Bidirectional revolve around a path.
///
/// profile001 = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20], tag = $revolveAxis)
/// |> line(end = [20, 0])
///
/// sketch001 = startSketchOn(XY)
/// |> circle(center = [-10, 10], radius = 4)
/// |> revolve(angle = 90, axis = revolveAxis, bidirectionalAngle = 50)
/// ```
@(impl = std_rust)
export fn revolve(
/// The sketch or set of sketches that should be revolved
@sketches: [Sketch; 1+],
/// Axis of revolution.
axis: Axis2d | Edge,
/// Angle to revolve (in degrees). Default is 360.
angle?: number(Angle),
/// Tolerance for the revolve operation.
tolerance?: number(Length),
/// If true, the extrusion will happen symmetrically around the sketch. Otherwise, the extrusion will happen on only one side of the sketch.
symmetric?: bool,
/// If specified, will also revolve in the opposite direction to 'angle' to the specified angle. If 'symmetric' is true, this value is ignored.
bidirectionalAngle?: number(Angle),
/// A named tag for the face at the start of the revolve, i.e. the original sketch.
tagStart?: tag,
/// A named tag for the face at the end of the revolve.
tagEnd?: tag,
): Solid {}
/// Offset a plane by a distance along its normal.
///
/// For example, if you offset the `XZ` plane by 10, the new plane will be parallel to the `XZ`

View File

@ -34,92 +34,241 @@ export fn circle(
tag?: tag,
): Sketch {}
/// Mirror a sketch.
/// Rotate a sketch around some provided axis, creating a solid from its extent.
///
/// Only works on unclosed sketches for now.
/// This, like extrude, is able to create a 3-dimensional solid from a
/// 2-dimensional sketch. However, unlike extrude, this creates a solid
/// by using the extent of the sketch as its revolved around an axis rather
/// than using the extent of the sketch linearly translated through a third
/// dimension.
///
/// Mirror occurs around a local sketch axis rather than a global axis.
/// Revolve occurs around a local sketch axis rather than a global axis.
///
/// You can provide more than one sketch to revolve, and they will all be
/// revolved around the same axis.
///
/// ```
/// // Mirror an un-closed sketch across the Y axis.
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 10])
/// |> line(end = [15, 0])
/// |> line(end = [-7, -3])
/// |> line(end = [9, -1])
/// |> line(end = [-8, -5])
/// |> line(end = [9, -3])
/// |> line(end = [-8, -3])
/// |> line(end = [9, -1])
/// |> line(end = [-19, -0])
/// |> mirror2d(axis = Y)
///
/// example = extrude(sketch001, length = 10)
/// part001 = startSketchOn(XY)
/// |> startProfile(at = [4, 12])
/// |> line(end = [2, 0])
/// |> line(end = [0, -6])
/// |> line(end = [4, -6])
/// |> line(end = [0, -6])
/// |> line(end = [-3.75, -4.5])
/// |> line(end = [0, -5.5])
/// |> line(end = [-2, 0])
/// |> close()
/// |> revolve(axis = Y) // default angle is 360
/// ```
///
/// ```
/// // Mirror a un-closed sketch across the Y axis.
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 8.5])
/// |> line(end = [20, -8.5])
/// |> line(end = [-20, -8.5])
/// |> mirror2d(axis = Y)
///
/// example = extrude(sketch001, length = 10)
/// // A donut shape.
/// sketch001 = startSketchOn(XY)
/// |> circle( center = [15, 0], radius = 5 )
/// |> revolve(
/// angle = 360,
/// axis = Y,
/// )
/// ```
///
/// ```
/// // Mirror a un-closed sketch across an edge.
/// helper001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 10], tag = $edge001)
///
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 8.5])
/// |> line(end = [20, -8.5])
/// |> line(end = [-20, -8.5])
/// |> mirror2d(axis = edge001)
///
/// // example = extrude(sketch001, length = 10)
/// part001 = startSketchOn(XY)
/// |> startProfile(at = [4, 12])
/// |> line(end = [2, 0])
/// |> line(end = [0, -6])
/// |> line(end = [4, -6])
/// |> line(end = [0, -6])
/// |> line(end = [-3.75, -4.5])
/// |> line(end = [0, -5.5])
/// |> line(end = [-2, 0])
/// |> close()
/// |> revolve(axis = Y, angle = 180)
/// ```
///
/// ```
/// // Mirror an un-closed sketch across a custom axis.
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 8.5])
/// |> line(end = [20, -8.5])
/// |> line(end = [-20, -8.5])
/// |> mirror2d(
/// axis = {
/// direction = [0.0, 1.0],
/// origin = [0.0, 0.0]
/// })
/// part001 = startSketchOn(XY)
/// |> startProfile(at = [4, 12])
/// |> line(end = [2, 0])
/// |> line(end = [0, -6])
/// |> line(end = [4, -6])
/// |> line(end = [0, -6])
/// |> line(end = [-3.75, -4.5])
/// |> line(end = [0, -5.5])
/// |> line(end = [-2, 0])
/// |> close()
/// |> revolve(axis = Y, angle = 180)
///
/// example = extrude(sketch001, length = 10)
/// part002 = startSketchOn(part001, face = END)
/// |> startProfile(at = [4.5, -5])
/// |> line(end = [0, 5])
/// |> line(end = [5, 0])
/// |> line(end = [0, -5])
/// |> close()
/// |> extrude(length = 5)
/// ```
///
/// ```
/// // Sketch on the face of a mirrored sketch, that has been extruded.
/// sketch0011 = startSketchOn(XY)
/// |> startProfile(at = [6.77, 0])
/// |> yLine(length = 1.27)
/// |> tangentialArc(endAbsolute = [5.96, 2.37])
/// |> tangentialArc(endAbsolute = [-6.2, 2.44])
/// |> tangentialArc(endAbsolute = [-6.6, 1.82])
/// |> yLine(length = -1.82)
/// |> mirror2d( axis = X )
/// |> extrude(length = 10)
/// box = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20])
/// |> line(end = [20, 0])
/// |> line(end = [0, -20])
/// |> close()
/// |> extrude(length = 20)
///
/// sketch002 = startSketchOn(sketch0011, face = END)
/// |> circle( center = [-0.01, 1.58], radius = 1.2 )
/// |> extrude(length = 1.2)
/// sketch001 = startSketchOn(box, face = END)
/// |> circle( center = [10,10], radius = 4 )
/// |> revolve(
/// angle = -90,
/// axis = Y
/// )
/// ```
///
/// shell([sketch002], faces = ['end'], thickness = .1 )
/// ```
/// box = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20])
/// |> line(end = [20, 0])
/// |> line(end = [0, -20], tag = $revolveAxis)
/// |> close()
/// |> extrude(length = 20)
///
/// sketch001 = startSketchOn(box, face = END)
/// |> circle( center = [10,10], radius = 4 )
/// |> revolve(
/// angle = 90,
/// axis = getOppositeEdge(revolveAxis)
/// )
/// ```
///
/// ```
/// box = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20])
/// |> line(end = [20, 0])
/// |> line(end = [0, -20], tag = $revolveAxis)
/// |> close()
/// |> extrude(length = 20)
///
/// sketch001 = startSketchOn(box, face = END)
/// |> circle( center = [10,10], radius = 4 )
/// |> revolve(
/// angle = 90,
/// axis = getOppositeEdge(revolveAxis),
/// tolerance = 0.0001
/// )
/// ```
///
/// ```
/// sketch001 = startSketchOn(XY)
/// |> startProfile(at = [10, 0])
/// |> line(end = [5, -5])
/// |> line(end = [5, 5])
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close()
///
/// part001 = revolve(
/// sketch001,
/// axis = {
/// direction = [0.0, 1.0],
/// origin = [0.0, 0.0]
/// }
/// )
/// ```
///
/// ```
/// // Revolve two sketches around the same axis.
///
/// sketch001 = startSketchOn(XY)
/// profile001 = startProfile(sketch001, at = [4, 8])
/// |> xLine(length = 3)
/// |> yLine(length = -3)
/// |> xLine(length = -3)
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close()
///
/// profile002 = startProfile(sketch001, at = [-5, 8])
/// |> xLine(length = 3)
/// |> yLine(length = -3)
/// |> xLine(length = -3)
/// |> line(endAbsolute = [profileStartX(%), profileStartY(%)])
/// |> close()
///
/// revolve(
/// [profile001, profile002],
/// axis = X,
/// )
/// ```
///
/// ```
/// // Revolve around a path that has not been extruded.
///
/// profile001 = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20], tag = $revolveAxis)
/// |> line(end = [20, 0])
/// |> line(end = [0, -20])
/// |> close(%)
///
/// sketch001 = startSketchOn(XY)
/// |> circle(center = [-10, 10], radius = 4)
/// |> revolve(angle = 90, axis = revolveAxis)
/// ```
///
/// ```
/// // Revolve around a path that has not been extruded or closed.
///
/// profile001 = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20], tag = $revolveAxis)
/// |> line(end = [20, 0])
///
/// sketch001 = startSketchOn(XY)
/// |> circle(center = [-10, 10], radius = 4)
/// |> revolve(angle = 90, axis = revolveAxis)
/// ```
///
/// ```
/// // Symmetrically revolve around a path.
///
/// profile001 = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20], tag = $revolveAxis)
/// |> line(end = [20, 0])
///
/// sketch001 = startSketchOn(XY)
/// |> circle(center = [-10, 10], radius = 4)
/// |> revolve(angle = 90, axis = revolveAxis, symmetric = true)
/// ```
///
/// ```
/// // Bidirectional revolve around a path.
///
/// profile001 = startSketchOn(XY)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 20], tag = $revolveAxis)
/// |> line(end = [20, 0])
///
/// sketch001 = startSketchOn(XY)
/// |> circle(center = [-10, 10], radius = 4)
/// |> revolve(angle = 90, axis = revolveAxis, bidirectionalAngle = 50)
/// ```
@(impl = std_rust)
export fn mirror2d(
/// The sketch or sketches to be reflected.
export fn revolve(
/// The sketch or set of sketches that should be revolved
@sketches: [Sketch; 1+],
/// The axis to reflect around.
/// Axis of revolution.
axis: Axis2d | Edge,
): Sketch {}
/// Angle to revolve (in degrees). Default is 360.
angle?: number(Angle),
/// Tolerance for the revolve operation.
tolerance?: number(Length),
/// If true, the extrusion will happen symmetrically around the sketch. Otherwise, the extrusion will happen on only one side of the sketch.
symmetric?: bool,
/// If specified, will also revolve in the opposite direction to 'angle' to the specified angle. If 'symmetric' is true, this value is ignored.
bidirectionalAngle?: number(Angle),
/// A named tag for the face at the start of the revolve, i.e. the original sketch.
tagStart?: tag,
/// A named tag for the face at the end of the revolve.
tagEnd?: tag,
): Solid {}

View File

@ -0,0 +1,93 @@
@no_std
@settings(defaultLengthUnit = mm, kclVersion = 1.0)
/// Mirror a sketch.
///
/// Only works on unclosed sketches for now.
///
/// Mirror occurs around a local sketch axis rather than a global axis.
///
/// ```
/// // Mirror an un-closed sketch across the Y axis.
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 10])
/// |> line(end = [15, 0])
/// |> line(end = [-7, -3])
/// |> line(end = [9, -1])
/// |> line(end = [-8, -5])
/// |> line(end = [9, -3])
/// |> line(end = [-8, -3])
/// |> line(end = [9, -1])
/// |> line(end = [-19, -0])
/// |> mirror2d(axis = Y)
///
/// example = extrude(sketch001, length = 10)
/// ```
///
/// ```
/// // Mirror a un-closed sketch across the Y axis.
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 8.5])
/// |> line(end = [20, -8.5])
/// |> line(end = [-20, -8.5])
/// |> mirror2d(axis = Y)
///
/// example = extrude(sketch001, length = 10)
/// ```
///
/// ```
/// // Mirror a un-closed sketch across an edge.
/// helper001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 0])
/// |> line(end = [0, 10], tag = $edge001)
///
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 8.5])
/// |> line(end = [20, -8.5])
/// |> line(end = [-20, -8.5])
/// |> mirror2d(axis = edge001)
///
/// // example = extrude(sketch001, length = 10)
/// ```
///
/// ```
/// // Mirror an un-closed sketch across a custom axis.
/// sketch001 = startSketchOn(XZ)
/// |> startProfile(at = [0, 8.5])
/// |> line(end = [20, -8.5])
/// |> line(end = [-20, -8.5])
/// |> mirror2d(
/// axis = {
/// direction = [0.0, 1.0],
/// origin = [0.0, 0.0]
/// })
///
/// example = extrude(sketch001, length = 10)
/// ```
///
/// ```
/// // Sketch on the face of a mirrored sketch, that has been extruded.
/// sketch0011 = startSketchOn(XY)
/// |> startProfile(at = [6.77, 0])
/// |> yLine(length = 1.27)
/// |> tangentialArc(endAbsolute = [5.96, 2.37])
/// |> tangentialArc(endAbsolute = [-6.2, 2.44])
/// |> tangentialArc(endAbsolute = [-6.6, 1.82])
/// |> yLine(length = -1.82)
/// |> mirror2d( axis = X )
/// |> extrude(length = 10)
///
/// sketch002 = startSketchOn(sketch0011, face = END)
/// |> circle( center = [-0.01, 1.58], radius = 1.2 )
/// |> extrude(length = 1.2)
///
/// shell([sketch002], faces = ['end'], thickness = .1 )
/// ```
@(impl = std_rust)
export fn mirror2d(
/// The sketch or sketches to be reflected.
@sketches: [Sketch; 1+],
/// The axis to reflect around.
axis: Axis2d | Edge,
): Sketch {}

View File

Before

Width:  |  Height:  |  Size: 150 KiB

After

Width:  |  Height:  |  Size: 150 KiB

Some files were not shown because too many files have changed in this diff Show More