Skip to content

Support rest types in Syntax section of reference #836

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

Merged
merged 3 commits into from
May 13, 2025
Merged

Conversation

davepagurek
Copy link
Collaborator

@davepagurek davepagurek commented May 10, 2025

Some of our signatures now support rest types, e.g. createVector. We currently do not display or type check this correctly. I've made a PR here to support type checking processing/p5.js#7803, and this adds the capability to display them in the reference.

It currently looks like this, using @GregStanton's idea borrowing from MDN the x1, x2, ..., xn syntax.
image

The Number: type is a little awkward here, but probably fine for now, and better than what we currently have.

For reference, how some other things display variadic arguments:

JavaScript

If we want the syntax section to reflect how one would write this in your own function, it would be:

createVector(...components)

...and also we'd document components as an array.

MDN

image

w3schools

image

Three.js

image

Lodash

image

Immutable.js

image

Oracle Java docs

image

@GregStanton
Copy link

This is fantastic @davepagurek! I love the list of documentation practices across the JS ecosystem and beyond :)

@davepagurek davepagurek merged commit c30d49e into 2.0 May 13, 2025
4 checks passed
@davepagurek davepagurek deleted the rest-types branch May 13, 2025 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants