1
0
Fork 0

fix(markdown): Restructure part reference. See #2981

This commit is contained in:
Joost De Cock 2022-10-18 21:00:50 +02:00
parent b4eb7e7b00
commit ac7b5befce
10 changed files with 105 additions and 110 deletions

View file

@ -32,15 +32,16 @@ access the following properties:
| `sa` | Access to `settings.sa` |
| `scale` | Access to `settings.scale` |
|| **_Access to utilities_** |
| `getId` | See [the getId documentation](/refence/api/part/draft/getid) |
| `hide` | See [the hide documentation](/refence/api/part/draft/hide) |
| `log` | See [the logging documentation](referenec/api/store/logs) |
| `getId` | See [the getId documentation](/reference/api/part/getid) |
| `hide` | See [the hide documentation](/reference/api/part/hide) |
| `log` | See [the logging documentation](reference/api/store/logs) |
| `macro` | See [the macros documentation](/reference/macros/) |
| `setHidden` | See [the setHidden documentation](/refence/api/part/draft/sethidden) |
| `setHidden` | See [the setHidden documentation](/reference/api/part/sethidden) |
| `store` | See [the store documentation](/reference/api/store) |
| `unhide` | See [the unhide documentation](/refence/api/part/draft/unhide) |
| `units` | See [the units documentation](/refence/api/part/draft/units) |
| `unhide` | See [the unhide documentation](/reference/api/part/unhide) |
| `units` | A version of [`utils.units()`](/reference/api/utils/units) that is preconfigured with the user's chosenunits |
| `utils` | See [the utils documentation](/reference/api/utils) |
|| **_Return value_** |
| `part` | Your draft method **must** return this |

View file

@ -1,31 +0,0 @@
---
title: getId()
---
Calling `getId()` in a part's draft method will return an integer the can be used as an
for ID Points/Paths/Snippets. This method will ensure the ID is unique by
keeping an internal incremental counter of the IDs that have been used.
It is typically used when programatically adding points, paths, or snippets.
## getId() signature
```js
int|string getId(prefix='')
```
This methiod takes an optional parameter that will be used as a prefix for the ID.
## getId() example
```js
cont part = {
name: 'examples.getid',
draft: ({ Point, points, getId, part }) => {
for (let i=0;i<10;i++) {
points[getId()] = new Point(i*10, i*10)
}
return part
}
}
```

View file

@ -1,24 +0,0 @@
---
title: hide()
---
Calling `hide()` in a part's draft method will mark the part as hidden.
<Tip>This method returns the `part` object, so it's chainable</Tip>
<Related>
The [unhide](/reference/api/part/draft/unhide) and
[setHidden](/reference/api/part/draft/sethidden) methods also control a
part's visibility
</Related>
## hide() example
```js
cont part = {
name: 'examples.hide',
draft: ({ hide, part }) => part.hide()
}
```

View file

@ -1,28 +0,0 @@
---
title: setHidden()
---
Calling `setHidden()` in a part's draft method will mark the part either hidden
or not, depending on whether you:
- Pass a *truthy* value: part will be hidden
- Pass a *falsy* value: part will be unhidden/revealed
<Tip>This method returns the `part` object, so it's chainable</Tip>
<Related>
The [hide](/reference/api/part/draft/hide) and
[unhide](/reference/api/part/draft/unhide) also control a
part's visibility
</Related>
## setHidden() example
```js
cont part = {
name: 'examples.hide',
draft: ({ setHidden, part }) => part.setHidden(true)
}
```

View file

@ -1,24 +0,0 @@
---
title: unhide()
---
Calling `unhide()` in a part's draft method will mark the part as not hidden.
<Tip>This method returns the `part` object, so it's chainable</Tip>
<Related>
The [hide](/reference/api/part/draft/hide) and
[setHidden](/reference/api/part/draft/sethidden) methods also control a
part's visibility
</Related>
## unhide() example
```js
cont part = {
name: 'examples.hide',
draft: ({ unhide, part }) => part.unhide()
}
```

View file

@ -1,22 +0,0 @@
---
title: units()
---
Calling `units()` in a part's draft method will format a float you pass it --
which should represent a value in mm -- into the units requested by the user.
The returned value is to be used in presentation only, as it will be
a string that includes the user's units.
## units() example
```js
cont part = {
name: 'examples.units',
draft: ({ log, measurements, part }) => {
log.info(`Pattern drafted for a ${units(measurements.chest)} chest`)
return part
}
}
```