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
Copy file name to clipboardExpand all lines: contributor_docs/Adding_examples.md
+33-30Lines changed: 33 additions & 30 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,30 +4,33 @@ Examples help demonstrate different programming concepts and functionality of th
4
4
5
5
## Getting started
6
6
7
-
0. If you are not yet familiar with GitHub we recommend checking out this [tutorial](https://guides.github.com/activities/hello-world/).
8
-
1. Install [node.js](https://nodejs.org/en/), which also automatically installs the npm package manager.
9
-
2.[Fork](https://help.github.com/articles/fork-a-repo/) the [p5.js-website](https://github.com/processing/p5.js-website) repository into your own GitHub account.
10
-
3.[Clone](https://help.github.com/articles/cloning-a-repository/) your new fork of the repository from GitHub onto your local computer.
11
-
4. Using the command line, navigate to the `src/data/examples/build_examples` folder, and install all its necessary dependencies with npm.
12
-
```
13
-
cd src/data/examples/build_examples
14
-
npm install
15
-
```
7
+
0. If you are not yet familiar with GitHub we recommend checking out this [tutorial](https://guides.github.com/activities/hello-world/).
8
+
1. Install [node.js](https://nodejs.org/en/), which also automatically installs the npm package manager.
9
+
2.[Fork](https://help.github.com/articles/fork-a-repo/) the [p5.js-website](https://github.com/processing/p5.js-website) repository into your own GitHub account.
10
+
3.[Clone](https://help.github.com/articles/cloning-a-repository/) your new fork of the repository from GitHub onto your local computer.
11
+
4. Using the command line, navigate to the `src/data/examples/build_examples` folder, and install all its necessary dependencies with npm.
12
+
13
+
```bash
14
+
cd src/data/examples/build_examples
15
+
npm install
16
+
```
16
17
17
18
## Make an issue
19
+
18
20
1. Open a new issue on the [p5.js-website repository](https://github.com/processing/p5.js-website/issues) listing the examples you are creating with your name, so efforts aren't duplicated.
19
21
22
+
20
23
## Create your example
21
24
22
25
1. First, build and test the example code using your own HTML file, linking to the most recent version of p5.js. You can find examples to port here.
23
-
* Please use two spaces tabs and see this code style guide.
24
-
* Examples should typically be 710px wide, and a recommended height is 400px. You can modify these dimensions (especially the height) as appropriate.
26
+
* Please use two spaces tabs and see this code style guide.
27
+
* Examples should typically be 710px wide, and a recommended height is 400px. You can modify these dimensions (especially the height) as appropriate.
25
28
26
29
2. At the top of the JS file you create, add a heading using the template below.
27
-
* The @name field determines the title of the example and the text of it's corresponding link on the examples page.
28
-
* The @frame field determines the dimensions of the example frame on the page. If you leave this field out, your running example will default to the size you set with createCanvas(). If you'd like to specify an alternate size (maybe because you have elements outside the canvas, for example), include the @frame line with dimensions separated by comma.
30
+
* The @name field determines the title of the example and the text of it's corresponding link on the examples page.
31
+
* The @frame field determines the dimensions of the example frame on the page. If you leave this field out, your running example will default to the size you set with createCanvas(). If you'd like to specify an alternate size (maybe because you have elements outside the canvas, for example), include the @frame line with dimensions separated by comma.
29
32
30
-
```
33
+
```jsdoc
31
34
/*
32
35
* @name Your Example Name Here (This shows up on the examples page as well.)
33
36
* @frame 710,400 (optional)
@@ -38,41 +41,41 @@ Examples help demonstrate different programming concepts and functionality of th
38
41
```
39
42
40
43
## Add your example to p5js.org
44
+
41
45
1. Place the JS file with your code and heading (do not include the HTML or p5.js files) in `src/data/examples/en/` of your local repository.
42
-
* The subfolder the file is placed in determines the topic heading the examples displays under on [p5js.org/examples](https://p5js.org/examples/). Add your file into the appropriate folder, or create a new one if necessary.
43
-
* If you create a new folder, you will also need to add the folder name to the `examples` section in the `src/data/en.yml`, `src/data/es.yml`, and `src/data/zh-Hans.yml` files in order for the headings to show up properly.
44
-
* The filename should follow the format: `XX_name_of_your_example.js`. The XX_ prefix (starting with 00) indicates the order that the files will show up on the page.
46
+
* The subfolder the file is placed in determines the topic heading the examples displays under on [p5js.org/examples](https://p5js.org/examples/). Add your file into the appropriate folder, or create a new one if necessary.
47
+
* If you create a new folder, you will also need to add the folder name to the `examples` section in the `src/data/en.yml`, `src/data/es.yml`, and `src/data/zh-Hans.yml` files in order for the headings to show up properly.
48
+
* The filename should follow the format: `XX_name_of_your_example.js`. The XX_ prefix (starting with 00) indicates the order that the files will show up on the page.
45
49
46
50
2. Place duplicate copies of the file in the corresponding folders in `src/data/examples/es/`, and `src/data/examples/zh-Hans/`. This allows us to build the Spanish and Chinese versions of the example. If you know either of these languages, feel free to translate the heading text and comments.
47
51
48
52
3. If you have any extra files that need to be included (images, JSON, etc), place them in the `src/data/examples/assets` folder. Try to keep these files small.
49
53
50
54
4. [Grunt](https://gruntjs.com/) should now be installed, and you can use it to build the website by navigating to the top level directory and typing:
51
55
52
-
```
53
-
grunt server
54
-
```
56
+
```bash
57
+
grunt server
58
+
```
55
59
56
60
5. A local build of the p5js.org site should open in your web browser and you can navigate to the examples page to see your changes.
57
61
58
62
6. Once everything is ready, submit your changes as a [pull request](https://help.github.com/articles/creating-a-pull-request/).
59
63
60
64
## Notes about translating examples
61
-
* The [p5js.org/examples](https://p5js.org/examples/) page is built from the data in [src/data/](https://github.com/processing/p5.js-website/tree/master/src/data).
62
-
* Within the examples folder, there is a folder for each of the three languages we currently support: `en/`, `es/`, and `zh-Hans/`.
63
-
* Translations for the topic headers on the example index page are done in the YML files `src/data/*.yml`.
65
+
66
+
* The [p5js.org/examples](https://p5js.org/examples/) page is built from the data in [src/data/](https://github.com/processing/p5.js-website/tree/master/src/data).
67
+
* Within the examples folder, there is a folder for each of the three languages we currently support: `en/`, `es/`, and `zh-Hans/`.
68
+
* Translations for the topic headers on the example index page are done in the YML files `src/data/*.yml`.
64
69
65
70
## To add examples
66
-
1. Locate the JS file within [`src/data/examples`] that corresponds to the example you want to add a translation for.
71
+
72
+
1. Locate the JS file within `src/data/examples` that corresponds to the example you want to add a translation for.
67
73
2. Translate the heading and comments. Do not change variable or function names. Do not change the filename.
68
74
3. To update a category heading on [p5js.org/examples](https://p5js.org/examples/), edit the YML files at `src/data/*.yml`.
69
75
70
-
## When adding a new examples
76
+
## When adding a new example
77
+
71
78
1. First add an English version of the file to the `en/` folder, then make sure it is duplicated in the same place in all other languages, then translate for whichever languages you can.
72
-
2. The folder, file, and numbering structure should match exactly between the different languages. Do not change the filenames. The text for the example name, description, and source code are all in the .js files in the folders.
79
+
2. The folder, file, and numbering structure should match exactly between the different languages. Do not change the filenames. The text for the example name, description, and source code are all in the `.js` files in the folders.
73
80
3. If you have created a new folder, add entries to the "Examples" section of each of the YML files `src/data/*.yml` with the foldername as the key.
0 commit comments