You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This folder contains various documents for developers of p5.js. This document contains the overview of how to contribute, build the library, test the code, and update the documentation.
1
+
This folder contains various documents intended for developers of p5.js.
2
2
3
-
# Getting started
3
+
# Ways To Contribute
4
4
5
-
Interested in contributing? Awesome! First, figure out what you'd like to do (a good place to start is the [issues list](https://github.com/processing/p5.js/issues)).
5
+
## Issues
6
6
7
-
***Fix a bug** :
7
+
Known bugs and intended new features are tracked using [GitHub issues](https://github.com/processing/p5.js/issues). If you'd like to contribute code but need suggestions about what to work on, start by looking at the existing issues. Issue [labels](https://github.com/processing/p5.js/blob/master/developer_docs/issue_labels.md) are used to sort issues into categories, such as those which are [suitable for beginners](https://github.com/processing/p5.js/labels/level%3Abeginner). If you start working on an existing issue, make sure to "assign" it to yourself so other contributors know it's being handled and can offer help. If you have discovered a bug or thought of a new feature but don't have code for it yet, you should consider submitting an issue.
8
8
9
-
If it's not on the issues list, add it. If it's already on this issues list, assign it to yourself or comment on the issue indicating you're working on it. Go ahead and fix it and submit a PR (see below for instructions for getting set up for development). We are also in the process of adding unit tests and more inline documentation, so if the function you are fixing doesn't have these, please consider adding these as well. [Submit the change to the master branch (see below).](https://github.com/processing/p5.js/blob/master/developer_docs/#master-branch-development)
10
-
Need help finding an issue to fix? Check out this [list of bite size issues](https://github.com/processing/p5.js/labels/level%3Abeginner) suitable for new contributors (or peruse other [issue labels](https://github.com/processing/p5.js/blob/master/developer_docs/issue_labels.md) for topics that catch your interest).
11
-
***Implement a new feature** :
9
+
## Accompaniments
12
10
13
-
If you have an original idea about a feature, open an issue describing your idea preferably in the format provided there, and let us know you're interested! Initiate a discussion, wait for the green signal, and then assign it to yourself! _Note: new features will require tests and inline documentation._
14
-
- Inline documentation:
15
-
- [Style guide for p5.js inline docs](https://github.com/processing/p5.js/blob/master/developer_docs/inline_documentation.md) -- by formatting your documentation correctly, it will automatically show up in the p5.js reference.
16
-
- Unit tests:
17
-
- See the [testing section](https://github.com/processing/p5.js/blob/master/developer_docs/#testing) for how to do this.
18
-
- This helps ensure that the code you write keeps working far into the future when further updates and changes are made.
19
-
- Benchmarks
20
-
- See [Benchmarking section](https://github.com/processing/p5.js/blob/master/developer_docs/benchmarking_p5.md)
21
-
- Helpful for finding and implementing performance optimizations
11
+
Aside from the code itself, you may also need to supply some combination of the following.
22
12
23
-
***Add unit tests or documentation for existing code** :
13
+
-[inline documentation](https://github.com/processing/p5.js/blob/master/developer_docs/inline_documentation.md) in the form of code comments, which explain the code both to other developers and to users. Many of these comments must conform to [JSDoc](https://usejsdoc.org) syntax and will be published on the p5.js website as part of the [online reference manual](https://p5js.org/reference/)
14
+
-[unit tests](https://github.com/processing/p5.js/blob/master/developer_docs/#testing), small pieces of code which are separate from the library and are used to verify its behavior
15
+
-[benchmarks](https://github.com/processing/p5.js/blob/master/developer_docs/benchmarking_p5.md) to test performance
24
16
25
-
Let us know which areas you're working on so we don't duplicate efforts! [Submit the change to the master branch.](https://github.com/processing/p5.js/blob/master/developer_docs/#master-branch-development)
26
-
- See the [guide for p5.js inline docs](https://github.com/processing/p5.js/blob/master/developer_docs/inline_documentation.md) -- by formatting your documentation correctly, it will automatically show up in the p5.js reference (coming soon).
27
-
- See the [testing section](https://github.com/processing/p5.js/blob/master/developer_docs/#testing) for how to add unit tests.
17
+
## Examples
28
18
29
-
***Add examples to the examples page** :
19
+
The p5.js site includes [integrated examples](http://p5js.org/examples/). You can [add more](https://github.com/processing/p5.js-website/wiki/Adding-examples), and there is an issue which lists some [desired examples](https://github.com/processing/p5.js/issues/1954).
30
20
31
-
Add to the examples on the [p5js.org examples page](http://p5js.org/examples/). See this [guide](https://github.com/processing/p5.js-website/wiki/Adding-examples) for details.
21
+
## Other Ideas
32
22
33
-
***Add inline examples to the ref** :
23
+
If you'd like to contribute in other ways which are not covered here, feel free to write to [[email protected]](mailto:[email protected]) and let us know what you're thinking! Aside from working on this codebase, we can always use help with things like documentation, tutorials, workshops, educational materials, branding, and design. Get in touch and we can talk about ways you might participate.
34
24
35
-
*[List of examples needed](https://github.com/processing/p5.js/issues/1954)
36
-
*[Guide for p5.js inline docs](https://github.com/processing/p5.js/blob/master/developer_docs/inline_documentation.md)
25
+
# Gotchas
37
26
38
-
***Contribute in some other way** :
27
+
The developer tooling included with the p5.js codebase is intentionally very strict about some things. This is a good thing! It makes everything consistent, and it will encourage you to be disciplined. This means you may try to change something only to have your commit rejected by the project, but don't get discouraged; even seasoned p5.js developers get caught by this stuff all the time. Typically the problem will be in one of two areas.
39
28
40
-
Write to [[email protected]](mailto:[email protected]) and let us know what you're thinking! It is our intention that there should be many ways to contribute to p5.js, from writing code, to creating examples, tutorials and documentation, to thinking about workshops and education, to working on branding and design, and anything else you can dream up. Get in touch and we can talk about ways you might participate.
29
+
## Code Syntax
41
30
42
-
# Setup
31
+
p5.js requires clean and stylistically consistent code syntax, which it enforces with [Prettier](https://prettier.io/) and [ESlint](https://eslint.org/). The rules are checked before you commit, but you can also install an [ESlint plugin](https://eslint.org/docs/user-guide/integrations#editors) for your code editor to highlight errors as soon as they appear. which will highlight problems immediately as you write your code.
43
32
44
-
1. Download and install [npm](https://npmjs.org/). The easiest way to do this is to just install [node](http://nodejs.org/).
45
-
2.[Fork and clone](https://help.github.com/articles/fork-a-repo) this library ([p5.js](https://github.com/processing/p5.js)).
33
+
To detect errors, run the following command in your terminal (do not type the `$` prompt):
34
+
35
+
```
36
+
$ npm run lint
37
+
```
38
+
39
+
Some syntax errors can be automatically fixed:
40
+
41
+
```
42
+
$ npm run lint:fix
43
+
```
44
+
45
+
Sticking with the established project style is usually preferable, but [occasionally](https://github.com/processing/p5.js/search?utf8=%E2%9C%93&q=prettier-ignore&type=) using an alternate syntax might make your code easier to understand. For these cases, Prettier [offers an escape hatch](https://prettier.io/docs/en/ignore.html), the `// prettier-ignore` comment, which you can use to make granular exceptions. Try to avoid using this if you can, because there are good reasons for most of the style preferences enforced by the linting.
46
+
47
+
## Unit Tests
48
+
49
+
Unit tests are small pieces of code which are created as complements to the primary logic and perform validation. If you are developing a major new feature for p5.js, you should probably include tests. Do not submit pull requests in which the tests do not pass, because that means something is broken.
50
+
51
+
To run the unit tests, use Grunt.
52
+
53
+
```
54
+
$ grunt
55
+
```
56
+
57
+
Sometimes it is useful to run the tests in the browser instead of on the command line. To do this, first start the [connect](https://github.com/gruntjs/grunt-contrib-connect) server:
58
+
59
+
```
60
+
$ npm run grunt connect -keepalive
61
+
```
62
+
63
+
With the server running, you should be able to open `test/test.html` in a browser.
64
+
65
+
# Development Process
66
+
67
+
1. Install [node.js](http://nodejs.org/), which also automatically installs the [npm](https://www.npmjs.org) package manager.
68
+
2.[Fork](https://help.github.com/articles/fork-a-repo) the [p5.js repository](https://github.com/processing/p5.js) into your own GitHub account.
69
+
3.[Clone](https://help.github.com/articles/cloning-a-repository/) your new fork of the repository from GitHub onto your local computer.
3. Navigate into the project folder and install dependencies via npm.
75
+
4. Navigate into the project folder and install all its necessary dependencies with npm.
52
76
53
77
```
54
-
cd p5.js
55
-
npm install
78
+
$ cd p5.js
79
+
$ npm install
56
80
```
57
81
58
-
4. To create the complete library from source, run Grunt.
82
+
5.[Grunt](https://gruntjs.com/) should now be installed, and you can use it to build the library from the source code.
59
83
60
84
```
61
-
npm run grunt
85
+
$ npm run grunt
62
86
```
63
-
**NEW** : To create the library with only certain components, use Grunt [as it is explained here.](https://github.com/processing/p5.js/blob/master/developer_docs/custom_p5_build.md)
64
-
65
-
If you're continuously changing files in the library, you may want to run `npm run grunt watch:quick` to automatically rebuild the library for you whenever any of its source files change.
66
-
67
-
5. Run `npm run grunt` one last time to make sure all the tests pass, and [submit a pull request](https://help.github.com/articles/creating-a-pull-request).
68
-
69
-
# Overview
87
+
88
+
If you're continuously changing files in the library, you may want to run `npm run grunt watch:quick` to automatically rebuild the library for you whenever any of its source files change without you having to first type the command manually.
70
89
71
-
This [looking inside p5.js video](http://www.luisapereira.net/teaching/looking-inside-p5/) describes the tools and files used in p5.js workflow.
90
+
6. Make some changes to the codebase and [commit](https://help.github.com/articles/github-glossary/#commit) them with Git.
72
91
73
-
`lib/` Contains the concatenated p5.js and p5.min.js libraries, generated by Grunt.
92
+
7. Run `npm run grunt` again to make sure there are no syntax errors, test failures, or other problems.
74
93
75
-
`src/` Contains all the source code for the library. The code is broken up into folders and files corresponding with the [Processing reference page](http://processing.org/reference/). Additionally, there is a core folder that holds constants, and internal helper functions and variables.
94
+
8.[Push](https://help.github.com/articles/github-glossary/#push) your new changes to your fork on GitHub.
76
95
77
-
`tests/` Contains unit testing files.
78
-
79
-
# Code Style
96
+
```
97
+
$ git push
98
+
```
80
99
81
-
p5.js uses [Prettier](https://prettier.io/) to automatically enforce a consistent code style and [Eslint](https://eslint.org/) to find other problematic code patterns. The rules are checked both when tests are run and before you make a commit.
100
+
9. Once everything is ready, submit your changes as a [pull request](https://help.github.com/articles/creating-a-pull-request).
82
101
83
-
## Editor integration
102
+
#Building Documentation
84
103
85
-
It's a good idea to add an [Eslint plugin to your editor](https://eslint.org/docs/user-guide/integrations#editors) which will show problems as you write your code. Many of the Eslint plugins can also fix style problems while you edit your code. You can also use an integration for [Prettier](https://prettier.io/), but the Eslint plugins provide most of the same features and more.
104
+
Inline comments in p5.js are built into the public-facing [reference manual](https://p5js.org/reference/). You can also view this locally:
86
105
87
-
## Automatic style fixing
106
+
```
107
+
$ npm run docs:dev
108
+
```
88
109
89
-
`npm run lint:fix` will format your code so that it follows the code style rules. You can check for style errors / code problems without fixing them by running `npm run lint`.
110
+
# Overview
90
111
91
-
## My commit got rejected ?!
92
-
Whenever you make a commit, Eslint and Prettier will check that your code follows the style rules and reject commits that break the rules. The error often looks like this:
93
-
```
94
-
eslint found some errors. Please fix them and try committing again.
112
+
This [looking inside p5.js video](http://www.luisapereira.net/teaching/looking-inside-p5/) describes the tools and files used in p5.js workflow.
95
113
96
-
✖ 3 problem (2 error, 1 warnings)
97
-
1 error, 1 warnings potentially fixable with the `--fix` option.
98
-
```
114
+
`lib/` Contains the concatenated p5.js and p5.min.js libraries, generated by Grunt.
99
115
100
-
Errors or warnings that are ``fixable with the `--fix` option`` are fixed by running `npm run lint:fix`.
116
+
`src/` Contains all the source code for the library. The code is broken up into folders and files corresponding with the [Processing reference page](http://processing.org/reference/). Additionally, there is a core folder that holds constants, and internal helper functions and variables.
101
117
102
-
## My code needs a special format!
103
-
In [some special cases](https://github.com/processing/p5.js/search?utf8=%E2%9C%93&q=prettier-ignore&type=) your code needs special formatting to look more clear. Prettier [offers an escape hatch](https://prettier.io/docs/en/ignore.html) to ignore a block of code from being formatted, via the `// prettier-ignore` comment. Use with caution!
118
+
`tests/` Contains unit testing files.
104
119
105
120
# Testing
106
121
@@ -120,36 +135,6 @@ To get started:
120
135
3. Link to the src and test files in `test.html`.
121
136
4. Run the tests with `npm run grunt`.
122
137
123
-
## Building and testing the Reference Docs & Examples
124
-
125
-
This will build the p5.js library, generate the documentation files, run a web server, and open a browser to the main documentation page.
126
-
127
-
````
128
-
npm run docs:dev
129
-
````
130
-
131
-
## Running tests in the browser
132
-
Sometimes it is useful to run tests in browser especially when trying to debug test failures. To run the tests in the browser:
133
-
134
-
1. Run the connect server. ```npm run grunt connect -keepalive```
135
-
2. Open test/test.html in your favourite web browser.
136
-
137
-
# Master branch development
138
-
139
-
1. Fork p5.js
140
-
2. Create a feature branch: `git checkout -b my_branch`
141
-
3. Make local changes
142
-
4. Commit and push changes. When you first attempt to push your feature branch, `git` will give you instructions on how to have your local branch track a similarly-named one on Github.
143
-
5. Submit a PR against the `p5.js/master` branch
144
-
6. checkout the master branch: `git checkout master`
145
-
146
-
## Bringing your master branch up-to-date
147
-
148
-
1. Make sure you have no uncommitted changes, or any additional commits in your master branch. The following commands will discard any changes you have made.
149
-
2.`git checkout master`
150
-
3.`git fetch`
151
-
4.`git reset --hard upstream/master`
152
-
5.`git push -f`
153
138
154
139
# Repositories
155
140
@@ -166,4 +151,5 @@ An alternative to setting up node, grunt, php, apache, and the p5.js & p5.js-web
166
151
167
152
# p5.js API JSON file
168
153
169
-
[This file](https://p5js.org/reference/data.json) can be used for auto-complete. This [gist](https://gist.github.com/jonohayon/b059a029755f84f42b29f005323ec165) explains how to parse the file. Note that the data.json file is generated when the `npm run grunt` command is run, it is found on the p5js.org website but is not included in the repo.
154
+
[This file](https://p5js.org/reference/data.json) can be used for auto-complete. This [gist](https://gist.github.com/jonohayon/b059a029755f84f42b29f005323ec165) explains how to parse the file. Note that the data.json file is generated when the `npm run grunt` command is run, it is found on the p5js.org website but is not included in the repo.
0 commit comments