Skip to content

Commit 76ac7d3

Browse files
author
Lauren McCarthy
committed
Merge branch 'master' of github.com:processing/p5.js
2 parents cbae780 + b7485c6 commit 76ac7d3

File tree

5 files changed

+52
-24
lines changed

5 files changed

+52
-24
lines changed

Gruntfile.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,9 @@ module.exports = function(grunt) {
362362
open: {
363363
yui: {
364364
path: 'http://127.0.0.1:9001/docs/reference/'
365+
},
366+
dev: {
367+
path: 'http://127.0.0.1:9001/test/'
365368
}
366369
},
367370
'saucelabs-mocha': {

developer_docs/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ $ grunt
7878
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:
7979

8080
```
81-
$ npm run grunt connect -keepalive
81+
$ npm run dev
8282
```
8383

8484
With the server running, you should be able to open `test/test.html` in a browser.
@@ -108,7 +108,7 @@ A complete guide to unit testing is beyond the scope of the p5.js documentation,
108108
$ npm run grunt
109109
```
110110

111-
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.
111+
If you're continuously changing files in the library, you may want to run `npm run dev` to automatically rebuild the library for you whenever any of its source files change without you having to first type the command manually.
112112

113113
6. Make some changes to the codebase and [commit](https://help.github.com/articles/github-glossary/#commit) them with Git.
114114

developer_docs/inline_documentation.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,13 @@ If the parameter is optional, add square brackets around the name:
6868
@param {type} [name] Description here.
6969
```
7070

71+
If the parameter takes one or more values defined in `constants.js`,
72+
then the type should be specified as `{Constant}` and the valid values should be enumerated in the comment following the `either` keyword, eg:
73+
74+
```
75+
@param {Constant} horizAlign horizontal alignment, either LEFT, CENTER, or RIGHT
76+
```
77+
7178
## Specify return type
7279

7380
The `@return` is identical to `@params`, but without the name. It should be the last element in `@method`. The JS types are: String, Number, Boolean, Object, Array, Null, and Undefined. If there is no return type, do not include `@return`.

docs/preprocessor.js

Lines changed: 39 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,40 @@ function mergeOverloadedMethods(data) {
7070
}
7171
};
7272

73-
var extractConsts = function(params) {
74-
params &&
75-
params.forEach(function(param) {
76-
if (param.type.split('|').indexOf('Constant') >= 0) {
77-
var match;
78-
if (classitem.name === 'endShape' && param.name === 'mode') {
79-
match = 'CLOSE';
80-
} else {
81-
var constantRe = /either\s+(?:[A-Z0-9_]+\s*,?\s*(?:or)?\s*)+/g;
82-
var execResult = constantRe.exec(param.description);
83-
match = execResult && execResult[0];
84-
}
85-
if (match) {
86-
var reConst = /[A-Z0-9_]+/g;
87-
var matchConst;
88-
while ((matchConst = reConst.exec(match)) !== null) {
89-
methodConsts[matchConst] = true;
90-
}
91-
}
73+
var extractConsts = function(param) {
74+
if (!param.type) {
75+
console.log(param);
76+
}
77+
if (param.type.split('|').indexOf('Constant') >= 0) {
78+
var match;
79+
if (classitem.name === 'endShape' && param.name === 'mode') {
80+
match = 'CLOSE';
81+
} else {
82+
var constantRe = /either\s+(?:[A-Z0-9_]+\s*,?\s*(?:or)?\s*)+/g;
83+
var execResult = constantRe.exec(param.description);
84+
match = execResult && execResult[0];
85+
if (!match) {
86+
throw new Error(
87+
classitem.file +
88+
':' +
89+
classitem.line +
90+
', Constant-typed parameter ' +
91+
fullName +
92+
'(...' +
93+
param.name +
94+
'...) is missing valid value enumeration. ' +
95+
'See inline_documentation.md#specify-parameters.'
96+
);
97+
}
98+
}
99+
if (match) {
100+
var reConst = /[A-Z0-9_]+/g;
101+
var matchConst;
102+
while ((matchConst = reConst.exec(match)) !== null) {
103+
methodConsts[matchConst] = true;
92104
}
93-
});
105+
}
106+
}
94107
};
95108

96109
var processOverloadedParams = function(params) {
@@ -125,10 +138,10 @@ function mergeOverloadedMethods(data) {
125138
);
126139
} else {
127140
paramNames[param.name] = param;
141+
extractConsts(param);
128142
}
129143
});
130144

131-
extractConsts(params);
132145
return params;
133146
};
134147

@@ -182,7 +195,11 @@ function mergeOverloadedMethods(data) {
182195
method.overloads.push(makeOverload(classitem));
183196
return false;
184197
} else {
185-
extractConsts(classitem.params);
198+
if (classitem.params) {
199+
classitem.params.forEach(function(param) {
200+
extractConsts(param);
201+
});
202+
}
186203
methodsByFullName[fullName] = classitem;
187204
}
188205

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"scripts": {
55
"grunt": "grunt",
66
"build": "grunt build",
7+
"dev": "grunt browserify connect open:dev watch:quick",
78
"docs": "grunt yui",
89
"docs:dev": "grunt yui:dev",
910
"test": "grunt",

0 commit comments

Comments
 (0)