-
Notifications
You must be signed in to change notification settings - Fork 463
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
Add some docs to stblib Symbol #7336
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thanks for your PR! I think you have to add Stdlib_Symbol.cmti/resi
to packages/artifacts.txt
to make the tests pass.
While you're there, I'd also convert the documentations to docstring tests, that'd make it even more useful!
runtime/Stdlib_Symbol.resi
Outdated
Console.log(Symbol.keyFor(globalSym)) | ||
// Expected output: "sym1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Make those a test instead of just documenting it, it'd be even more useful!
Console.log(Symbol.keyFor(globalSym)) | |
// Expected output: "sym1" | |
Symbol.keyFor(globalSym)->assetEqual("sym1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
two typos to fix and we should be good to go :)
runtime/Stdlib_Symbol.resi
Outdated
## Examples | ||
|
||
```rescript | ||
Symbol.make("sym1")->assetEqual("sym1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
my bad it's assertEqual
Symbol.make("sym1")->assetEqual("sym1") | |
Symbol.make("sym1")->assertEqual("sym1") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
runtime/Stdlib_Symbol.resi
Outdated
## Examples | ||
|
||
```rescript | ||
Symbol.getFor("sym1")->assetEqual(Symbol.getFor("sym1")) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
runtime/Stdlib_Symbol.resi
Outdated
``` | ||
*/ | ||
@val | ||
external getFor: string => t = "Symbol.for" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you also forgot to update the interface file, and while we're there, I'd also use @scope
for these bindings, which is cleaner IMO:
external getFor: string => t = "Symbol.for" | |
@scope("Symbol") | |
external getFor: string => option<t> = "for" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed.
@jderochervlk tests fail, did you try to run them locally?
|
I'm trying to get things to run locally, but the setup docs seem to leave me in a place where things don't work.
|
sorry @jderochervlk I meant
|
I'm getting a permissions issue.
|
@jderochervlk try deleting node_modules and install again. |
Weird, that did the trick, thanks! |
Tests are now passing locally. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good to me now :)
This adds a
.resi
file forStdlib_Symbol
with documentation for most of the common uses for Symbols. I added adescription
andtoString
to the bindings.A good chunk of what Symbols are used for aren't really applicable or possible with ReScript, such as the static properties. I'm not sure if there is value in including those bindings in the stdlib, but for now I just omitted documentation.