New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[WIP] Add experimental type-checker for reference tests #1287
Conversation
This is very exciting. I like that it forces us to keep the documentation updated and correct. Regarding your questions, I guess the whitelist with eventual switch to blacklist makes sense and sounds most doable. It seems to make more sense to have you guys focus your time with this effort on the structural stuff rather than reviewing the documentation for every example, so let's not let that hold you up. I'm not sure what to do about the "secret" arg acceptance... maybe we need to add an option into yuidocs for params/signatures that aren't documented but are accepted? A tangential question that has come up for me is the way we display params in the reference. It works fine when there is an optional argument, we just use [ ] to make this clear. It gets more confusing when there are actually different sets up arguments that could fit. Then we end up with confusion params documentation like this: * @method color
* @param {Number|String} v1 gray value or red or hue value relative to
* the current color range, or a color string
* @param {Number} [v2] gray value or green or saturation value
* relative to the current color range (or
* alpha value if first param is gray value)
* @param {Number} [v3] gray value or blue or brightness value
* relative to the current color range
* @param {Number} [alpha] alpha value relative to current color range or * @param {Array|Number|p5.Color} c1 interpolate from this color
* @param {Array/Number} c2 interpolate to this color
* @param {Array|Number|p5.Color} c2 interpolate to this color It's not totally clear which ones get used in combination with each other. I think the examples help a lot, but I really like the way that the processing ref just shows each different option under syntax: I wonder if it's possible to change the rendering of the ref pages to include multiple options like this, and also that that might mean for the way we are documenting inline. |
Awesome! I totally agree regarding your tangential question, and I think it's important to figure it out sooner rather than later, as it will not only make the docs easier to understand, but the friendly error feedback too! I'll do some digging into yuidocs to see if there's something we can do. Quick update: I found yui/yuidoc#190, which suggests that method overloading is sort-of supported. One possibility may be for me to contribute to yuidoc upstream so it supports this use case better. Quick update update: Working on this now in #1295! |
Hey!! I just had an idea for a sort-of alternative approach to solving the same kind of problem as this PR, and I wrote a blog post about it here: http://processing.toolness.org/general/2016/03/16/typescript-to-the-rescue.html Technically the two approaches are independent of one another, and each is useful in its own way, I think, so we could potentially use both. |
The typescript approach looks great, too! I also like that the typescript files generated could be used by users independently, if they had some other way they wanted to incorporate them. I agree about keeping things as DRY as possible -- because we have a lot of different people working on this project at different times and with different levels of experience and familiarity, anything that alerts us to errors or inconsistencies will further increase the sustainability of the project and the workflow we have. |
hi @toolness I'm doing some cleanup here and wanted to check in on this pull request. this one says don't merge yet, are there further plans for this or should it be merged or closed? thanks! |
Oh shoot, sorry I have been totally delinquent on this! |
This is a work-in-progress pull request, please don't merge it yet.
@lmccart: let me know if it's annoying to have a WIP PR lying about here--it's fine if that's the case, I can just move it over to my fork. I thought it might be nice to have it in the p5.js PR list so others can participate.
This is an attempt to use p5's own yuidocs to actively type-check its own examples. This can be beneficial for a number of reasons:
lerpColor()
can actually take ap5.Color
as a first argument--and it's likely that users will want to do this--but it isn't documented, then we should document it. Or if the argument typeNumber
is misspelled asNimber
, we should throw an error at build or test time.Limitations of this PR:
save()
. There's a number of ways we can do this but for now we'll use one of two strategies:FILES_TO_IGNORE_FOR_NOW
andMETHODS_TO_IGNORE_FOR_NOW
intest/js/typeChecker.js
.customValidators
mapping intest/js/typeChecker.js
.Other concerns:
p5.color()
can actually take ap5.Color
instance as its single argument, and internal p5 methods do this all the time. I'm not entirely sure what the point of this is, and it may be too confusing for beginners to document this in our yuidocs, so I wrote a custom validator for this method that makes it not complain if the first argument is ap5.Color
.Finally, note that this PR is an experiment! It's okay if it ends up being rejected. Hopefully we can learn from its mistakes, at least.