Skip to content

Commit 9189ffb

Browse files
committed
cleaned up contributing guide
1 parent e6474e9 commit 9189ffb

File tree

1 file changed

+14
-33
lines changed

1 file changed

+14
-33
lines changed

CONTRIBUTING_GUIDE.md

+14-33
Original file line numberDiff line numberDiff line change
@@ -19,23 +19,21 @@ npm run test:clean
1919

2020
The following repo has 4 main directories:
2121

22-
- `scikitjs-browser`: Contains build/test commands for the browser version of scikitjs
23-
- `scikitjs-node`: Contains build/test commands for the node version of scikitjs
22+
- `src`: Contains the majority of the code for implementing scikit-learn Estimators, and helper functions
2423
- `docs`: Contains a docusaurus site which builds the `scikitjs.org` site. Has blogs/tutorials/apis documentation
25-
- `shared`: Contains all the code that is shared between browser and node versions of this library.
2624

27-
For anyone creating Estimators or writing scikit-learn functions, you'll likely be spending your time in the `shared/lib` directory. It contains a directory-like structure that matches the scikit-learn directory structure. So there is a `cluster` directory, and a `model_selection` directory, etc.
25+
For anyone creating Estimators or writing scikit-learn functions, you'll likely be spending your time in the `src` directory. It contains a directory-like structure that matches the scikit-learn directory structure. So there is a `cluster` directory, and a `model_selection` directory, etc.
2826

29-
The following files are available in the `shared/lib` directory:
27+
The following files are available in the `src` directory:
3028

3129
- `index`: Entry file which exports all features.
3230
- `utils`: A collection of reusable utility functions.
3331
- `types`: A file for declaring Typescript types.
3432

3533
Some important scripts in the package.json file are:
3634

37-
- `test:clean` : Build both browser and node versions, and runs all tests against them
38-
- `build` : Builds both the browser and node versions of this library
35+
- `test:clean` : Runs tests against node.js version of src code
36+
- `build` : Builds all bundles (esm, cjs, script src)
3937
- `build:docs`: Builds a local version of the site `scikitjs.org`
4038

4139
## Code Style
@@ -96,9 +94,9 @@ Type names are typically nouns or noun phrases. For example, Request, ImmutableL
9694

9795
#### Method names
9896

99-
Method names are written in lowerCamelCase e.g `addNum`. Names for private methods must start with a dollar sign e.g `$startAddition`, and should be declared as private.
97+
Method names are written in lowerCamelCase e.g `addNum`.
10098

101-
Method names are typically verbs or verb phrases. For example, `sendMessage` or `$stopProcess`. Getter and setter methods for properties are never required, but if they are used they should be named `getFoo` (or optionally `isFoo` or `hasFoo` for booleans), or `setFoo(value)` for setters.
99+
Method names are typically verbs or verb phrases. For example, `sendMessage` or `stopProcess`. Getter and setter methods for properties are never required, but if they are used they should be named `getFoo` (or optionally `isFoo` or `hasFoo` for booleans), or `setFoo(value)` for setters.
102100

103101
#### Constant names
104102

@@ -134,9 +132,9 @@ JSDOCs attached to the class or functions are automatically converted into the A
134132

135133
## **Writing tests**
136134

137-
We strongly encourage contributors to write tests for their code. Like many packages, [danfojs](https://danfo.jsdata.org/) uses [mocha](https://mochajs.org/).
135+
We strongly encourage contributors to write tests for their code. Like many packages, [scikitjs](https://scikitjs.org) uses [jest](https://jestjs.io/).
138136

139-
All tests should go into the file suffixed by `.test.ts` and place in the corresponding module. The test files contain some current examples of tests (e.g. `kmeans.test.ts`), and we suggest looking to these for inspiration.
137+
All tests should go into the file suffixed by `.test.ts` and be placed next to the corresponding src code. The test files contain some current examples of tests (e.g. `kmeans.test.ts`), and we suggest looking to these for inspiration.
140138

141139
Below is the general framework to write a test for each module.
142140

@@ -147,7 +145,7 @@ import { addSeries } from './addSeries' //compiled build
147145
describe('Name of the class|module', function () {
148146
it('name of the methods| expected result', function () {
149147
//write your test code here
150-
//use assert.{property} to test your code
148+
//use expect(thing).toEqual to test your code
151149
})
152150
})
153151
```
@@ -163,9 +161,8 @@ describe("Name of the class|module", function(){
163161
describe("method name 1", function(){
164162

165163
it("expected result",function(){
166-
167164
//write your test code here
168-
//use assert.{proprty} to test your code
165+
//use expect(thing).toEqual to test your code
169166
})
170167
})
171168

@@ -174,7 +171,7 @@ describe("Name of the class|module", function(){
174171
it("expected result",function(){
175172

176173
//write your test code here
177-
//use assert.{proprty} to test your code
174+
//use expect(thing).toEqual to test your code
178175
})
179176
})
180177
.......
@@ -183,22 +180,6 @@ describe("Name of the class|module", function(){
183180

184181
### **Running the test case**
185182

186-
To run the test for the module/file you created/edited,
187-
188-
**1\)** Change `describe` to `describe.only` at the top of the test file
189-
190-
**2\)** If you are in the shared directory, you can run the test case against the node library by typing
191-
192-
```bash
193-
npm run test:node
194-
```
195-
196-
You can also test your code against the browser version by running
197-
198-
```bash
199-
npm run test:browser
200-
```
201-
202-
Note that running tests against the browser is usually a bit slower because we build the browser bundle. I usually test against node for quick iterations, and then at the end test against the browser.
183+
To run the test for the module/file you created/edited, just run jest over that single file
203184

204-
Learn more about mocha [here](https://mochajs.org/)
185+
**1\)** Simply run `npx jest ./path/to/file.test.ts`

0 commit comments

Comments
 (0)