Skip to content

Commit dcd1b8d

Browse files
authored
docs(all): V3 documentation changes
1 parent 10fc153 commit dcd1b8d

146 files changed

Lines changed: 694 additions & 405 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

jsdoc.json

Lines changed: 17 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"include": [
44
"packages/array-utils/src",
55

6+
"packages/modeling/src",
67
"packages/modeling/src/colors",
78
"packages/modeling/src/curves",
89
"packages/modeling/src/curves/bezier",
@@ -35,15 +36,22 @@
3536
"packages/modeling/src/text",
3637
"packages/modeling/src/utils",
3738

39+
"packages/io/io/src",
3840
"packages/io/io-utils",
39-
"packages/io/amf-deserializer/src",
40-
"packages/io/amf-serializer",
41+
"packages/io/3mf-deserializer/src",
42+
"packages/io/3mf-serializer/src",
43+
"packages/io/dxf-deserializer/src",
44+
"packages/io/dxf-serializer/src",
45+
"packages/io/json-deserializer/src",
46+
"packages/io/json-serializer/src",
47+
"packages/io/obj-deserializer/src",
48+
"packages/io/obj-serializer/src",
49+
"packages/io/stl-deserializer/src",
50+
"packages/io/stl-serializer/src",
4151
"packages/io/svg-deserializer/src",
42-
"packages/io/svg-serializer",
52+
"packages/io/svg-serializer/src",
4353
"packages/io/x3d-deserializer/src",
44-
"packages/io/x3d-serializer/src",
45-
"packages/io/3mf-deserializer/src",
46-
"packages/io/3mf-serializer/src"
54+
"packages/io/x3d-serializer/src"
4755
],
4856
"includePattern": ".+\\.js(doc|x)?$",
4957
"excludePattern": ".+test.js$"
@@ -54,7 +62,7 @@
5462
"tutorials": "./jsdoc/tutorials",
5563
"readme": "./jsdoc/assets/README.md"
5664
},
57-
"plugins": ["plugins/markdown"],
65+
"plugins": ["jsdoc/jsdocFix","plugins/markdown"],
5866
"templates": {
5967
"default": {
6068
"staticFiles": {
@@ -86,8 +94,8 @@
8694
"url": ""
8795
},
8896
"meta": {
89-
"title": "JSCAD API Documentation",
90-
"description": "JSCAD API Documentation",
97+
"title": "JSCAD V3 API Documentation",
98+
"description": "JSCAD V3 API Documentation",
9199
"keyword": "JSCAD OpenJSCAD"
92100
},
93101
"search": [true],

jsdoc/assets/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ There are different 'flavors' of JSCAD that you can use based on your needs
2323

2424
## Documentation
2525

26-
* [JSCAD User Guide](https://openjscad.xyz/guide.html)
27-
* [API Reference](https://openjscad.xyz/docs/)
26+
* [JSCAD User Guide](https://openjscad.xyz/v3/guide.html)
27+
* [API Reference](https://openjscad.xyz/v3/docs/)
2828
* [Open Issues](https://openjscad.xyz/issues.html)
2929

3030
## Community

jsdoc/assets/static/jscad-docs.css

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ body {
55

66
nav {
77
background: none;
8+
padding-bottom: 10px;
89
}
910

1011
section {

jsdoc/jsdocFix.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
const newDocletFix = (docHandle) => {
2+
if (docHandle.doclet.params) {
3+
docHandle.doclet.kind = "function"
4+
}
5+
}
6+
7+
exports.handlers = {
8+
newDoclet: newDocletFix
9+
}

jsdoc/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"name": "package to fix jsdoc"
3+
}

jsdoc/tutorials/01_gettingStarted.md

Lines changed: 6 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -23,34 +23,17 @@ it with the "Load a JSCAD Project" file dialog.
2323
The simplest file that will render a cube in JSCAD looks like this:
2424
```javascript
2525
// the import statement allows your code to use JSCAD functions.
26-
import { primitives } from '@jscad/modeling'
26+
import { cube } from '@jscad/modeling'
2727

2828
// the export statement defines the entry point of the design.
2929
export const main = () => {
30-
return primitives.cube()
30+
return cube()
3131
}
3232
```
33-
JSCAD functions must be imported, but there are several different syntaxes for using the functions:
34-
```javascript
35-
// import one or more functional areas from JSCAD:
36-
import { primitives, booleans } from '@jscad/modeling'
37-
38-
// use functions directly
39-
let aCube = primitives.cube()
40-
41-
// or
42-
43-
// use the functions by name
44-
const { cube, sphere } = primitives
45-
46-
let aCube = cube()
47-
let aSphere = sphere()
48-
```
4933
## Adding Methods
5034
Clean, readable code is one of the most important aspects of a useful design. In that respect, it can often be useful to break your code into simple function that do part of the work for your design:
5135
```javascript
52-
import { primitives } from '@jscad/modeling'
53-
const { cylinder } = primitives
36+
import { cylinder } from '@jscad/modeling'
5437

5538
const hex = (radius, height) => {
5639
return cylinder({radius, height, segments: 6})
@@ -63,8 +46,7 @@ export const main = () => {
6346
## Re-usable Designs
6447
A valuable practise when creating models is to store all but the most trivial values as parameters in the code, rather than using the numerical values directly. This can be done by storing them in constants in your file...
6548
```javascript
66-
import { primitives } from '@jscad/modeling'
67-
const { cylinder } = primitives
49+
import { cylinder } from '@jscad/modeling'
6850

6951
const options = {
7052
height: 5.1,
@@ -78,10 +60,10 @@ export const main = () => {
7860

7961
... or, even better, to include runtime parameters in your design. This is done using the getParameterDefinitions function:
8062
```javascript
81-
import { primitives } from '@jscad/modeling'
82-
const { cylinder } = primitives
63+
import { cylinder } from '@jscad/modeling'
8364

8465
// Declare a function named "getParameterDefinitions". It will return an array of parameter definitions.
66+
// You must also export the getParameterDefinitions function.
8567
export const getParameterDefinitions = () => {
8668
return [
8769
{ name: 'height', type: 'number', initial: 2.0, min: 1.0, max: 10.0, step: 0.1, caption: 'Hex Height:' },
@@ -93,7 +75,6 @@ export const getParameterDefinitions = () => {
9375
export const main = (params) => {
9476
return cylinder({radius: params.radius, height: params.height, segments: 6})
9577
}
96-
// You must also export the getParameterDefinitions function.
9778
```
9879
<img src="img/parameters.png" alt="JSCAD Parameters Example">
9980

jsdoc/tutorials/02_modelingBasics.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,7 @@ Another valuable way of building shapes is to start with 2D shapes. These can b
3838
specifying points, starting with basic primitive 2D shapes, or importing SVG files. The 2D
3939
shapes can then be extruded to produce a wide variety of different geometries.
4040
```javascript
41-
import { primitives, extrusions } from '@jscad/modeling'
42-
const { polygon } = primitives
43-
const { extrudeLinear } = extrusions
41+
import { polygon, extrudeLinear } from '@jscad/modeling'
4442

4543
export const main = () => {
4644
const poly = polygon({ points: [[-1, -1], [3, -1], [3.5, 2], [2, 1], [1, 2], [0, 1], [-1, 2]] })

jsdoc/tutorials/03_usingParameters.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ your designs, so that they can easily adapt to different situations.
33

44
## ParametricBox.js
55
```javascript
6-
import { primitives, booleans } from '@jscad/modeling'
7-
const { cuboid, roundedCuboid } = primitives
8-
const { subtract } = booleans
6+
import { cuboid, roundedCuboid, subtract } from '@jscad/modeling'
97

108
export const getParameterDefinitions = () => {
119
return [

jsdoc/tutorials/04_multifileProjects.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,13 @@ contain your design. Your project can also contain:
2121
```
2222
## hexcap/index.js
2323
```javascript
24-
import { primtives } from '@jscad/modeling'
25-
const { cylinder } = primitives
24+
import { cylinder } from '@jscad/modeling'
2625

2726
import { hexWidthToRadius } from './lib/utils.js'
2827

2928
export const main = () => {
30-
let hexRadius = utils.hexWidthToRadius(12)
31-
return cylinder({radius: hexRadius, height: 4, segments: 6})
29+
let radius = hexWidthToRadius(12)
30+
return cylinder({radius, height: 4, segments: 6})
3231
}
3332
```
3433
## hexcap/lib/utils.js

jsdoc/tutorials/05_importingFiles.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
11
Importing files in JSCAD is a simple case of loading them using the same import statement used to load javascript modules. The files you load need to be part of a multifile project, so that JSCAD can access them:
22

33
```javascript
4+
// import all functions and global constants
45
import * as jscad from '@jscad/modeling'
56

6-
const { translate, scale, rotateZ } = jscad.transforms
7-
const { union } = jscad.booleans
7+
// import specific functions and global constants by name
8+
const { translate, scale, rotateZ, union, TAU } = '@jscad/modeling'
89

910
// Load the STL files using require
1011
const sculpture = require('./3d_sculpture-VernonBussler.stl')

0 commit comments

Comments
 (0)