1
0
Fork 0

fix(markdown): Correct and normalize utils docs

This commit is contained in:
Benjamin Fan 2024-02-21 20:26:36 -08:00
parent 1c38b4518b
commit 8075a4bd14
6 changed files with 19 additions and 16 deletions

View file

@ -7,7 +7,7 @@ The `utils.deg2read()` function returns the degrees you pass to it as radians.
## Signature ## Signature
```js ```js
float deg2rad(float degrees) float utils.deg2rad(float degrees)
``` ```
## Notes ## Notes

View file

@ -1,8 +1,8 @@
--- ---
title: generateStackTransform title: utils.generateStackTransform()
--- ---
This method will generate the SVG transform to implement a given layout configuration on [a stack](/reference/api/stack). The `utils.generateStackTransform()` function will generate the SVG transform to implement a given layout configuration on [a stack](/reference/api/stack).
## Signature ## Signature
@ -28,7 +28,7 @@ In other words, it rotates the stack.
The fourth and fifth parameters flip the part along the X or Y axis respectively. The fourth and fifth parameters flip the part along the X or Y axis respectively.
<Note compact> <Note compact>
This is a low-level method to facilitate intervening in the pattern layout late in the draft process. This is a low-level function to facilitate intervening in the pattern layout late in the draft process.
It is unlikely you will want to use this. It is unlikely you will want to use this.
</Note> </Note>

View file

@ -1,8 +1,8 @@
--- ---
title: getTransformedBounds title: utils.getTransformedBounds()
--- ---
This methods re-calculates the bounding box of an object (a stack or a part) after applying the passed-in transform(s). The `utils.getTransformedBounds()` function re-calculates the bounding box of an object (a stack or a part) after applying the passed-in transform(s).
The object passed in should have its `topLeft` and `bottomRight` properties set. The object passed in should have its `topLeft` and `bottomRight` properties set.
It will return on object that with (only) the updated `topLeft` and `bottomRight` properties set. It will return on object that with (only) the updated `topLeft` and `bottomRight` properties set.
@ -10,13 +10,13 @@ It will return on object that with (only) the updated `topLeft` and `bottomRight
## Signature ## Signature
```js ```js
Object getTransformedBounds( Object utils.getTransformedBounds(
Object stack, Object stack,
Array transforms Array transforms
) )
``` ```
<Note compact> <Note compact>
This is a low-level method to facilitate intervening in the pattern layout late in the draft process. This is a low-level function to facilitate intervening in the pattern layout late in the draft process.
It is unlikely you will want to use this. It is unlikely you will want to use this.
</Note> </Note>

View file

@ -1,14 +1,14 @@
--- ---
title: mergeI18n title: utils.mergeI18n()
--- ---
The `mergeI18n` method merges translation files from different designs. The `utils.mergeI18n()` function merges translation files from different designs.
When your design re-uses parts from other designs, it should provide When your design re-uses parts from other designs, it should provide
translation for those parts and any strings or options they use. Rather than translation for those parts and any strings or options they use. Rather than
re-creating this content in your own design, you can pull it out of of the re-creating this content in your own design, you can pull it out of of the
design you are using the part from by importing the `i18n` named export, and design you are using the part from by importing the `i18n` named export, and
then use this method to merge it with your own translations. then use this function to merge it with your own translations.
## Signature ## Signature
@ -21,7 +21,7 @@ Object mergeI18n({
## Use ## Use
In its simplest form, this method will receive an Array of translation data In its simplest form, this function will receive an Array of translation data
(typically the `i18n` named export of a design) and merge them: (typically the `i18n` named export of a design) and merge them:
```js ```js
@ -75,7 +75,7 @@ const i18n = mergeI18n(
) )
``` ```
The method will check each key under the `s`, `p`, and `o` top-level keys in the translation files. The function will check each key under the `s`, `p`, and `o` top-level keys in the translation files.
For each it will: For each it will:
- Check whether there is a `drop` array configured. If there is, it will remove the entry if its key is included in the `drop` Array. - Check whether there is a `drop` array configured. If there is, it will remove the entry if its key is included in the `drop` Array.

View file

@ -8,7 +8,10 @@ options from the pattern configuration.
## Signature ## Signature
```js ```js
object mergeOptions(object settings, object optionsConfig) Object utils.mergeOptions(
Object settings,
Object optionsConfig
)
``` ```
## Notes ## Notes
@ -20,7 +23,7 @@ and if it's not get the default value from the pattern config. Furthermore,
where the default is stored and whether or not it should be further transformed where the default is stored and whether or not it should be further transformed
depends on the option type. depends on the option type.
This method exists to facilitate this. You pass it the user-provided settings, This function exists to facilitate this. You pass it the user-provided settings,
and the pattern config options key, and it will return an object where all and the pattern config options key, and it will return an object where all
options are populated with the user-provided values, or their defaults if the options are populated with the user-provided values, or their defaults if the
user did not provide any input. user did not provide any input.

View file

@ -7,6 +7,6 @@ The `utils.rad2dag()` function returns the radians you pass to it as degrees.
## Signature ## Signature
```js ```js
float rad2deg(float radians) float utils.rad2deg(float radians)
``` ```