generate kcl examples in docs from macro (#1710)

* rearrange

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

* examples

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

* fix tests

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

* recast

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

* updates

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

* add more tests

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

* fixups

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

* add more samples

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

* more docs

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

* more

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

* more samples

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

* more

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

* fixups

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

* fixups

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

* fixes

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

* make serial

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

* fix hang

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

* fix import

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

* updates

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

* fixes

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

* atan

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

* atan

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

* updates

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

* fixes

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

* fixes

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

* make all tests pass

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

* fix docs

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

* fixes

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

* must have code balock

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

* updates

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

* new docs

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

* fix

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

* fix docs

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

* new docs

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

---------

Signed-off-by: Jess Frazelle <github@jessfraz.com>
This commit is contained in:
Jess Frazelle
2024-03-13 12:56:46 -07:00
committed by GitHub
parent 6bab45a56a
commit a60bdd4cc3
36 changed files with 3584 additions and 538 deletions

View File

@ -48,6 +48,30 @@ pub async fn line_to(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw a line to a point.
///
/// ```no_run
/// fn rectShape = (pos, w, l) => {
/// const rr = startSketchOn('YZ')
/// |> startProfileAt([pos[0] - (w / 2), pos[1] - (l / 2)], %)
/// |> lineTo({
/// to: [pos[0] + w / 2, pos[1] - (l / 2)],
/// tag: "edge1"
/// }, %)
/// |> lineTo({
/// to: [pos[0] + w / 2, pos[1] + l / 2],
/// tag: "edge2"
/// }, %)
/// |> lineTo({
/// to: [pos[0] - (w / 2), pos[1] + l / 2],
/// tag: "edge3"
/// }, %)
/// |> close(%, "edge4")
/// return rr
/// }
///
/// // Create the mounting plate extrusion, holes, and fillets
/// const part = rectShape([0, 0], 20, 20)
/// ```
#[stdlib {
name = "lineTo",
}]
@ -127,6 +151,18 @@ pub async fn x_line_to(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw a line to a point on the x-axis.
///
/// ```no_run
/// startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> xLineTo({
/// to: 10,
/// tag: "edge1"
/// }, %)
/// |> line([10, 10], %)
/// |> close(%, "edge2")
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "xLineTo",
}]
@ -156,6 +192,19 @@ pub async fn y_line_to(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw a line to a point on the y-axis.
///
/// ```no_run
/// startSketchOn('XZ')
/// |> startProfileAt([0, 0], %)
/// |> yLineTo({
/// to: 10,
/// tag: "edge1"
/// }, %)
/// |> line([10, 10], %)
/// |> close(%, "edge2")
/// |> extrude(10, %)
/// |> fillet({radius: 2, tags: ["edge2"]}, %)
/// ```
#[stdlib {
name = "yLineTo",
}]
@ -200,6 +249,15 @@ pub async fn line(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw a line.
///
/// ```no_run
/// startSketchOn('-XY')
/// |> startProfileAt([0, 0], %)
/// |> line([10, 10], %)
/// |> line({to: [20, 10], tag: "edge1"}, %)
/// |> close(%, "edge2")
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "line",
}]
@ -278,6 +336,15 @@ pub async fn x_line(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw a line on the x-axis.
///
/// ```no_run
/// startSketchOn('YZ')
/// |> startProfileAt([0, 0], %)
/// |> xLine(10, %)
/// |> line([10, 10], %)
/// |> close(%, "edge1")
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "xLine",
}]
@ -304,6 +371,15 @@ pub async fn y_line(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw a line on the y-axis.
///
/// ```no_run
/// startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> yLine(10, %)
/// |> line([10, 10], %)
/// |> close(%, "edge1")
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "yLine",
}]
@ -358,6 +434,20 @@ pub async fn angled_line(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw an angled line.
///
/// ```no_run
/// startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> angledLine({
/// angle: 45,
/// length: 10,
/// tag: "edge1"
/// }, %)
/// |> line([10, 10], %)
/// |> line([0, 10], %)
/// |> close(%, "edge2")
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "angledLine",
}]
@ -429,6 +519,20 @@ pub async fn angled_line_of_x_length(args: Args) -> Result<MemoryItem, KclError>
}
/// Draw an angled line of a given x length.
///
/// ```no_run
/// startSketchOn('XZ')
/// |> startProfileAt([0, 0], %)
/// |> angledLineOfXLength({
/// angle: 45,
/// length: 10,
/// tag: "edge1"
/// }, %)
/// |> line([10, 10], %)
/// |> line([0, 10], %)
/// |> close(%, "edge2")
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "angledLineOfXLength",
}]
@ -486,6 +590,21 @@ pub async fn angled_line_to_x(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw an angled line to a given x coordinate.
///
/// ```no_run
/// startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> angledLineToX({
/// angle: 45,
/// to: 10,
/// tag: "edge1"
/// }, %)
/// |> line([10, 10], %)
/// |> line([0, 10], %)
/// |> close(%, "edge2")
/// |> extrude(10, %)
/// |> fillet({radius: 2, tags: ["edge1"]}, %)
/// ```
#[stdlib {
name = "angledLineToX",
}]
@ -518,6 +637,21 @@ pub async fn angled_line_of_y_length(args: Args) -> Result<MemoryItem, KclError>
}
/// Draw an angled line of a given y length.
///
/// ```no_run
/// startSketchOn('YZ')
/// |> startProfileAt([0, 0], %)
/// |> angledLineOfYLength({
/// angle: 45,
/// length: 10,
/// tag: "edge1"
/// }, %)
/// |> line([10, 10], %)
/// |> line([0, 10], %)
/// |> close(%, "edge2")
/// |> extrude(10, %)
/// |> fillet({radius: 2, tags: ["edge1"]}, %)
/// ```
#[stdlib {
name = "angledLineOfYLength",
}]
@ -547,6 +681,20 @@ pub async fn angled_line_to_y(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw an angled line to a given y coordinate.
///
/// ```no_run
/// startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> angledLineToY({
/// angle: 45,
/// to: 10,
/// tag: "edge1"
/// }, %)
/// |> line([10, 10], %)
/// |> line([0, 10], %)
/// |> close(%, "edge2")
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "angledLineToY",
}]
@ -593,6 +741,22 @@ pub async fn angled_line_that_intersects(args: Args) -> Result<MemoryItem, KclEr
}
/// Draw an angled line that intersects with a given line.
///
/// ```no_run
/// const part001 = startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> lineTo({to:[2, 2], tag: "yo"}, %)
/// |> lineTo([3, 1], %)
/// |> angledLineThatIntersects({
/// angle: 180,
/// intersectTag: 'yo',
/// offset: 12,
/// tag: "yo2"
/// }, %)
/// |> line([4, 0], %)
/// |> close(%, "yo3")
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "angledLineThatIntersects",
}]
@ -641,6 +805,11 @@ pub async fn start_sketch_at(args: Args) -> Result<MemoryItem, KclError> {
}
/// Start a sketch at a given point on the 'XY' plane.
///
/// ```no_run
/// startSketchAt([0, 0])
/// |> line([10, 10], %)
/// ```
#[stdlib {
name = "startSketchAt",
}]
@ -785,6 +954,37 @@ pub async fn start_sketch_on(args: Args) -> Result<MemoryItem, KclError> {
}
/// Start a sketch on a specific plane or face.
///
/// ```no_run
/// startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> line([10, 10], %)
/// |> line({to: [20, 10], tag: "edge1"}, %)
/// |> close(%, "edge2")
/// ```
///
/// ```no_run
/// fn cube = (pos, scale) => {
/// const sg = startSketchOn('XY')
/// |> startProfileAt(pos, %)
/// |> line([0, scale], %)
/// |> line([scale, 0], %)
/// |> line([0, -scale], %)
/// |> close(%)
/// |> extrude(scale, %)
///
/// return sg
/// }
///
/// const box = cube([0,0], 20)
///
/// const part001 = startSketchOn(box, "start")
/// |> startProfileAt([0, 0], %)
/// |> line([10, 10], %)
/// |> line({to: [20, 10], tag: "edge1"}, %)
/// |> close(%)
/// |> extrude(20, %)
/// ```
#[stdlib {
name = "startSketchOn",
}]
@ -1011,6 +1211,12 @@ pub async fn start_profile_at(args: Args) -> Result<MemoryItem, KclError> {
}
/// Start a profile at a given point.
///
/// ```no_run
/// startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> line([10, 10], %)
/// ```
#[stdlib {
name = "startProfileAt",
}]
@ -1081,6 +1287,22 @@ pub async fn close(args: Args) -> Result<MemoryItem, KclError> {
}
/// Close the current sketch.
///
/// ```no_run
/// startSketchOn('XZ')
/// |> startProfileAt([0, 0], %)
/// |> line([10, 10], %)
/// |> line([10, 0], %)
/// |> close(%)
/// ```
///
/// ```no_run
/// startSketchOn('YZ')
/// |> startProfileAt([0, 0], %)
/// |> line([10, 10], %)
/// |> line([10, 0], %)
/// |> close(%, "edge1")
/// ```
#[stdlib {
name = "close",
}]
@ -1165,6 +1387,18 @@ pub async fn arc(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw an arc.
///
/// ```no_run
/// startSketchOn('-YZ')
/// |> startProfileAt([0, 0], %)
/// |> arc({
/// angle_start: 0,
/// angle_end: 360,
/// radius: 10,
/// tag: "edge1"
/// }, %)
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "arc",
}]
@ -1259,6 +1493,19 @@ pub async fn tangential_arc(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw an arc.
///
/// ```no_run
/// startSketchOn('-YZ')
/// |> startProfileAt([0, 0], %)
/// |> line({to: [10, 10], tag: "edge0"}, %)
/// |> tangentialArc({
/// radius: 10,
/// offset: 90,
/// tag: "edge1"
/// }, %)
/// |> close(%)
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "tangentialArc",
}]
@ -1373,6 +1620,14 @@ pub async fn tangential_arc_to(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw an arc.
///
/// ```no_run
/// startSketchOn('-YZ')
/// |> startProfileAt([0, 0], %)
/// |> line({to: [10, 10], tag: "edge0"}, %)
/// |> tangentialArcTo([10, 0], %)
/// |> close(%)
/// ```
#[stdlib {
name = "tangentialArcTo",
}]
@ -1445,6 +1700,19 @@ pub async fn bezier_curve(args: Args) -> Result<MemoryItem, KclError> {
}
/// Draw a bezier curve.
///
/// ```no_run
/// startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> bezierCurve({
/// to: [10, 10],
/// control1: [5, 0],
/// control2: [5, 10],
/// tag: "edge1"
/// }, %)
/// |> close(%)
/// |> extrude(10, %)
/// ```
#[stdlib {
name = "bezierCurve",
}]
@ -1514,6 +1782,18 @@ pub async fn hole(args: Args) -> Result<MemoryItem, KclError> {
}
/// Use a sketch to cut a hole in another sketch.
///
/// ```no_run
/// const square = startSketchOn('XY')
/// |> startProfileAt([0, 0], %)
/// |> line([0, 10], %)
/// |> line([10, 0], %)
/// |> line([0, -10], %)
/// |> close(%)
/// |> hole(circle([2, 2], .5, startSketchOn('XY')), %)
/// |> hole(circle([2, 8], .5, startSketchOn('XY')), %)
/// |> extrude(2, %)
/// ```
#[stdlib {
name = "hole",
}]