Skip to content

Commit f77ecda

Browse files
committed
Updated documentation for Prettier
1 parent 2de7887 commit f77ecda

File tree

1 file changed

+32
-6
lines changed

1 file changed

+32
-6
lines changed

README.md

Lines changed: 32 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,68 @@
11
# ml5-neuralnetwork-test-build
2+
23
This is a test repo to see what it would take to build only the NeuralNetwork feature of the ml5 library.
34

45
## Setup
6+
57
This build uses node version 18.15.0 and npm version.
68
Install nvm and run the following commands:
9+
710
```
811
nvm install 18.15
912
nvm use 18
1013
```
1114

12-
1315
To build the library, run the following commands:
16+
1417
```
1518
npm install
1619
npm run build
1720
```
18-
This will create the build in the dist folder.
1921

22+
This will create the build in the dist folder.
2023

2124
Open `examples/NeuralNetwork/index.html` in the browser to see the build running an example from the ml5 website.
2225

2326
## Code Formatting
24-
To keep the coding style consistent, we will be using the prettier formatter.
2527

28+
To keep the coding style consistent, we will be using the Prettier formatter.
29+
30+
### Visual Studio Code
31+
32+
If you are using Visual Studio Code, you can install the Prettier extension by going to the **Extensions** tab and search for "Prettier". Click on **Prettier - Code formatter** and click **Install**.
33+
34+
Go to **File > Preferences > Settings**, search for "default formatter" and make sure **Prettier - Code formatter** is selected for **Editor: Default Formatter**.
35+
36+
To automatically format a document when saving it, search for "format on save" in the settings and make sure **Editor: Format On Save** is checked. Otherwise, you can use the VS Code keyboard shortcut to format an opened document, which is <kbd>shift</kbd> + <kbd>alt</kbd> + <kbd>f</kbd> for Windows or <kbd>shift</kbd> + <kbd>option</kbd> + <kbd>f</kbd> for Mac.
37+
38+
### Command Line
2639

40+
You can also format a document via the command line. To format all JavaScript documents in the repo, use:
41+
42+
```
43+
npm run format
44+
```
45+
46+
To format a specific document, use
47+
48+
```
49+
npx prettier --write path/to/file
50+
```
51+
52+
For more options with the command line, refer to the [Prettier Documentation](https://prettier.io/docs/en/cli.html)
2753

2854
## Process
29-
This section explains how this repository was creates and is for reference purposes only. The steps outlines in this section do not need to be followed by contributors.
55+
56+
_This section explains how this repository was creates and is for reference purposes only. The steps outlines in this section do not need to be followed by contributors._
3057

3158
I am building the library using Webpack, which was installed with:
59+
3260
```
3361
npm install --save-dev webpack webpack cli
3462
```
3563

3664
I also created package.json using `npm init` and set up a basic config file for a library build named `webpack.config.js`. I configured package.json so I could run webpack with `npm run build`.
3765

38-
3966
From the original ml5 library's `src` folder, I copied over all source files from the `NeuralNetwork` directory and necessary dependency files from `utils` directory. I also copied over `index.js` from the `src` folder and deleted everything unrelated to NeuralNetwork. I then installed `@tensorflow/[email protected]`, `@tensorflow/[email protected]`, and `[email protected]` with npm.
4067

41-
4268
At this point, the library can be built without error. I was only getting an error about exceeding recommended size limit. For the build, I am using the latest version of node, npm, and tfjs. I have not tested all the features of NeuralNetwork, but it appears to be working just fine.

0 commit comments

Comments
 (0)