Fix FES errors, parameter data omitting classes #7497
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
Parameter validation was failing when
createCanvas(200, 200)
was called innpm run dev
. It turns out there were some FES issues introduced with the most recent FES PR, partially from other changes that have happened since it was started.Fixed constant lookups
Previously, a regex would be used to find constants, and it would grab the values out of the constants file. However, the regex didn't handle
P2D
since it has a number in it, and it didn't handleRADIANS
which comes from another file.Now, it just checks for any key in
p5
that starts with a capital letter and then is followed by capital letters or numbers.Fixed missing p5 classes
Previously, it would only handle type references to p5 classes, e.g.
p5.Color
, by checking for their presence in the parameterData.json info. However, classes will only show up there if they have methods. (A bunch were also missing due to the reasons in the next paragraph.) I've updated it to look up p5 classes again by checking for functions inp5.prototype
that start with a capital and are not already a constant.Fixed missing class methods in parameterData.json
The largest change was in how we export classes. Previously, it looked like this:
Now, it looks like this:
Earlier, everything just worked, and methods on the exported class would be correctly parsed by Documentation.js. Now, Documentation.js parses all methods on the class as belonging to
Framebuffer
, notp5.Framebuffer
, which doesn't have exported docs, which caused them to not get used in validation.To fix this, I'm now adding
p5.
to all class memberships inconvert.js
. @diyaayay, I suspect you'll need to do the same in the TypeScript type generator, maybe we can try to factor out some of these common helpers and use them in both scripts to ensure some consistency?Added tuple type support
paletteLerp
previously had a non-functional special case in the code. I noticed it wasn't even present in dev-2.0 yet, so I added it in and added actual support for tuple types in param signatures.