Skip to content

Commit 8f73ed0

Browse files
authored
Merge branch 'dev-2.0' into dev-2.0
2 parents da8a336 + 666c425 commit 8f73ed0

File tree

16 files changed

+1272
-433
lines changed

16 files changed

+1272
-433
lines changed

contributor_docs/contributing_to_the_p5js_reference.md

Lines changed: 1146 additions & 179 deletions
Large diffs are not rendered by default.

contributor_docs/documentation_style_guide.md

Lines changed: 20 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Our community is large and diverse. Many people learn to code using p5.js, and a
1515
## Table of Contents
1616

1717
### Writing
18-
- [YUIDoc](#yuidoc)
18+
- [documentation.js and JSDoc](#documentationjs-and-jsdoc)
1919
- [English](#english)
2020
- [Oxford Comma](#oxford-comma)
2121
- [Wording](#wording)
@@ -42,15 +42,13 @@ Our community is large and diverse. Many people learn to code using p5.js, and a
4242
- [Classes](#classes)
4343
- [Assets](#assets)
4444

45-
## YUIDoc
45+
## documentation.js and JSDoc
4646

47-
We use YUIDoc to generate the p5.js API documentation. To generate the docs, navigate to the p5.js root directory, run `npm install`, and execute:
47+
We use [documentation.js](https://documentation.js.org/) to generate the p5.js API documentation from [JSDoc](https://jsdoc.app/) comments in the p5.js source code.
4848

49-
```
50-
$ npm run grunt yui:dev
51-
```
49+
Refer to the [inline documentation guide](./contributing_to_the_p5js_reference.md) for more information on how to structure the documentation comments and what tags to use.
5250

53-
The output will appear in docs/reference. Refer to the [inline documentation guide](./contributing_to_the_p5js_reference.md) for more information.
51+
It also discusses how to [generate and preview the reference documentation](./contributing_to_the_p5js_reference/#generating-and-previewing-the-reference) to see your changes.
5452

5553
**[⬆ back to top](#table-of-contents)**
5654

@@ -141,7 +139,7 @@ Always use `let` to declare variables.
141139

142140
**Accessibility terminology**
143141

144-
The following terminology is adapted from the WordPress documentation guidelines for [Writing inclusive documentation](https://make.wordpress.org/docs/style-guide/general-guidelines/inclusivity/#accessibility-terminology). For more background on people-first language, see the CDC's guide on [Communicating With and About People with Disabilities](https://www.cdc.gov/ncbddd/disabilityandhealth/materials/factsheets/fs-communicating-with-people.html).
142+
The following terminology is adapted from the WordPress documentation guidelines for [Writing inclusive documentation](https://make.wordpress.org/docs/style-guide/general-guidelines/inclusivity/#accessibility-terminology). For more background on people-first language, see the CDC's guide on [Communicating With and About People with Disabilities](https://www.cdc.gov/disability-and-health/articles-documents/communicating-with-and-about-people-with-disabilities.html).
145143

146144
| Recommended | Not Recommended |
147145
| -- | -- |
@@ -1267,25 +1265,30 @@ class Mover {
12671265

12681266
## Assets
12691267

1270-
- Always load assets from a folder called "assets".
1268+
Whether assets (such as images, fonts, sound files, etc) are being used in the descriptions or code examples of the reference documentation, or in tutorials, the same rules apply:
12711269

1272-
> Why? It models good project organization. It's also required for assets to load on the p5.js website. Place assets in the following folders to include them in our online documentation:
1273-
- Examples: [src/data/examples/assets](https://github.com/processing/p5.js-website/tree/main/src/data/examples)
1274-
- Reference Pages: [src/templates/pages/reference/assets](https://github.com/processing/p5.js-website/tree/main/src/templates/pages/reference/assets)
1275-
- Learn Pages: [src/assets/learn](https://github.com/processing/p5.js-website/tree/main/src/assets/learn)
1270+
- Always load assets from a folder called `assets`.
1271+
- Store the assets in the `public/assets` folder of the p5.js-website repository.
1272+
1273+
> Why? It models good project organization. It's also required for assets to load on the p5.js website.
12761274
12771275
```javascript
12781276
let img;
12791277

12801278
// Bad.
1281-
function preload() {
1282-
img = loadImage('moonwalk.jpg');
1279+
async function setup() {
1280+
img = await loadImage('moonwalk.jpg');
1281+
//...
12831282
}
12841283

12851284
// Good.
1286-
function preload() {
1287-
img = loadImage('assets/moonwalk.jpg');
1285+
async function setup() {
1286+
img = await loadImage('assets/moonwalk.jpg');
1287+
//...
12881288
}
12891289
```
12901290

1291+
There is more on working with assets in the guide: [Contributing to the p5.js reference](./contributing_to_the_p5js_reference/#using-assets).
1292+
1293+
12911294
**[⬆ back to top](#table-of-contents)**
146 KB
Loading

contributor_docs/jsdoc.md

Lines changed: 1 addition & 151 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,3 @@
11
# JSDoc Best Practices
22

3-
Documentation on the website is built from the comments in the p5.js repo. Here are a few things to keep in mind in order for the documentation to be parsed correctly!
4-
5-
## For everything
6-
7-
- At the top of a file, add a comment with the `@module` tag, and optionally also the `@submodule`. These reference the category and subcategory names that the contents of the file should appear under in the reference:
8-
9-
e.g. for just a category:
10-
```js
11-
/**
12-
* @module Rendering
13-
*/
14-
```
15-
16-
e.g. for both:
17-
```js
18-
/**
19-
* @module Data
20-
* @submodule LocalStorage
21-
*/
22-
```
23-
24-
## For classes
25-
26-
27-
- Create classes *outside* of the addon function, and assign them to `p5` *inside.* The class name should be the same always:
28-
29-
```js
30-
class MyClass {
31-
// ...
32-
}
33-
34-
export default function myAddon(p5, fn) {
35-
p5.MyClass = MyClass;
36-
}
37-
```
38-
39-
- Document class methods directly above the members in classes, *without* a `@method` tag:
40-
41-
```js
42-
class MyClass {
43-
/**
44-
* Description goes here
45-
*/
46-
myMethod() {
47-
return 4;
48-
}
49-
}
50-
```
51-
52-
- Documentation for the class itself should go at the spot where the class is added to `p5` and not right next to the class definition. This needs to include the `@class` tag, including a `p5.` prefix on the class name. Also include the parameters for the constructor in this description, if they exist.
53-
54-
```js
55-
class MyClass {
56-
constructor(n) {
57-
this.n = n;
58-
}
59-
}
60-
61-
export default function myAddon(p5, fn) {
62-
/**
63-
* Description of the class goes here!
64-
*
65-
* @class p5.MyClass
66-
* @param {Number} n A number to pass in
67-
*/
68-
p5.MyClass = MyClass;
69-
}
70-
```
71-
72-
- Documentation for class properties should appear after the class is added to `p5`, not within the class itself. It needs to have the `@for` tag referencing its class, and the `@property` tag naming the property itself:
73-
74-
```js
75-
class MyClass {
76-
myProperty;
77-
constructor() {
78-
myProperty = 2;
79-
}
80-
}
81-
82-
export default function myAddon(p5, fn) {
83-
/**
84-
* Description of the class goes here!
85-
*
86-
* @class p5.MyClass
87-
*/
88-
p5.MyClass = MyClass;
89-
90-
/**
91-
* Description of the property goes here!
92-
*
93-
* @property {Number} myProperty
94-
* @for p5.MyClass
95-
*/
96-
}
97-
```
98-
99-
## For global functions
100-
101-
- Add a comment with the `@method` tag listing its name:
102-
103-
```js
104-
export default function myAddon(p5, fn) {
105-
/**
106-
* Description goes here!
107-
*
108-
* @method myFunction
109-
*/
110-
p5.myFunction = function() {
111-
return 8;
112-
};
113-
}
114-
```
115-
116-
- For dynamically generated methods, do the same as usual, but add `@for p5`.
117-
118-
```js
119-
function myAddon(p5, fn) {
120-
for (const key of ['nameA', 'nameB']) {
121-
fn[key] = function() {
122-
return `Hello from ${key}!`;
123-
};
124-
}
125-
126-
/**
127-
* @method nameA
128-
* @for p5
129-
*/
130-
131-
/**
132-
* @method nameB
133-
* @for p5
134-
*/
135-
}
136-
```
137-
138-
- Mark things that you don't want showing up as `@private`. This is done automatically for methods whose names start with `_`.
139-
140-
```js
141-
class MyClass {
142-
/**
143-
* @private
144-
*/
145-
privateMethodA() {
146-
// ...
147-
}
148-
149-
_privateMethodB() {
150-
// ...
151-
}
152-
}
153-
```
3+
This material has been moved into [Contributing to the p5.js Reference](./contributing_to_the_p5js_reference.md)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"test/**/*.js": "eslint",
2121
"utils/**/*.{js,mjs}": "eslint"
2222
},
23-
"version": "2.2.2",
23+
"version": "2.2.3-rc.1",
2424
"dependencies": {
2525
"@davepagurek/bezier-path": "^0.0.7",
2626
"@japont/unicode-range": "^1.0.0",

0 commit comments

Comments
 (0)