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/documentation_style_guide.md
+20-17Lines changed: 20 additions & 17 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ Our community is large and diverse. Many people learn to code using p5.js, and a
15
15
## Table of Contents
16
16
17
17
### Writing
18
-
-[YUIDoc](#yuidoc)
18
+
-[documentation.js and JSDoc](#documentationjs-and-jsdoc)
19
19
-[English](#english)
20
20
-[Oxford Comma](#oxford-comma)
21
21
-[Wording](#wording)
@@ -42,15 +42,13 @@ Our community is large and diverse. Many people learn to code using p5.js, and a
42
42
-[Classes](#classes)
43
43
-[Assets](#assets)
44
44
45
-
## YUIDoc
45
+
## documentation.js and JSDoc
46
46
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.
48
48
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.
52
50
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.
54
52
55
53
**[⬆ back to top](#table-of-contents)**
56
54
@@ -141,7 +139,7 @@ Always use `let` to declare variables.
141
139
142
140
**Accessibility terminology**
143
141
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).
145
143
146
144
| Recommended | Not Recommended |
147
145
| -- | -- |
@@ -1267,25 +1265,30 @@ class Mover {
1267
1265
1268
1266
## Assets
1269
1267
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:
1271
1269
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:
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
-
* @moduleRendering
13
-
*/
14
-
```
15
-
16
-
e.g. for both:
17
-
```js
18
-
/**
19
-
* @moduleData
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
-
classMyClass {
31
-
// ...
32
-
}
33
-
34
-
exportdefaultfunctionmyAddon(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
-
classMyClass {
43
-
/**
44
-
* Description goes here
45
-
*/
46
-
myMethod() {
47
-
return4;
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
-
classMyClass {
56
-
constructor(n) {
57
-
this.n= n;
58
-
}
59
-
}
60
-
61
-
exportdefaultfunctionmyAddon(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
-
classMyClass {
76
-
myProperty;
77
-
constructor() {
78
-
myProperty =2;
79
-
}
80
-
}
81
-
82
-
exportdefaultfunctionmyAddon(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
-
exportdefaultfunctionmyAddon(p5, fn) {
105
-
/**
106
-
* Description goes here!
107
-
*
108
-
* @methodmyFunction
109
-
*/
110
-
p5.myFunction=function() {
111
-
return8;
112
-
};
113
-
}
114
-
```
115
-
116
-
- For dynamically generated methods, do the same as usual, but add `@for p5`.
117
-
118
-
```js
119
-
functionmyAddon(p5, fn) {
120
-
for (constkeyof ['nameA', 'nameB']) {
121
-
fn[key] =function() {
122
-
return`Hello from ${key}!`;
123
-
};
124
-
}
125
-
126
-
/**
127
-
* @methodnameA
128
-
* @for p5
129
-
*/
130
-
131
-
/**
132
-
* @methodnameB
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
-
classMyClass {
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)
0 commit comments