-
-
Notifications
You must be signed in to change notification settings - Fork 8.6k
docs: comments on reactivity functions (fixes #4832) #4836
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
docs: comments on reactivity functions (fixes #4832) #4836
Conversation
I found that there's no documentation for |
Also: Maybe we could think about having all API-describing documentation in the actual source code and vue-docs somehow pulls those chapters from there? That way, we wouldn't need to maintain the same doc twice. |
Allow me to summon @yyx990803 to ask for his opinion on this :) |
This is a nice start but comments should follow https://tsdoc.org/ and use I also think adding full examples for all the methods is too much and won't be as practical when hovering definitions. It would be better to keep a short explanation about the functions with links to the actual docs. And maybe add some short code samples, especially for reactivity functions that are not used that often. |
If we start adding And: you're leaning towards having a dedicated, exhaustive documentation in vue-docs and a shorter, more brief version in the in-line docs, right? |
I've shortened the doc blocks a bit and sprinkled some tsdoc goodness, as well. Did not add For the dev-only params like But in VSCode, this doesn't work: It shows up in the quick doc overlay... Since most devs here are most likely using VSCode, I removed the empty |
@posva I hope I've covered all functions that are exported from the reactivity module. What do you think? Regarding the documentation for |
Thanks for the great effort! It will probably take me some time to go over all of them but looking good so far. |
✅ Deploy Preview for vuejs-coverage ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
✅ Deploy Preview for vue-next-template-explorer ready!
To edit notification comments on pull requests, go to your Netlify site settings. |
👷 Deploy Preview for vue-sfc-playground processing.
|
I was quite occupied with my normal job so I missed that this PR was out of sync. It's updated now so it could be merged again 😇 Fixes #4832 |
Trying to keep this up to date with the |
I truly believe that those comments can greatly improve DX! I hope that the Vue team can merge them soon 🙏 |
A belated merry christmas and happy new year to everyone 😘 I've updated the PR so it can be merged again. |
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.
Thank you for this! I think it's worth getting multiple pairs of eyes on this PR. I think it will be very welcomed! 😄
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.
It's looking great but we should definitely address the unresolved reviews as well!
I think that in general, using the vuejs.org API versions (sometimes without the example or with a shorter one) would make up for an overrall more correct, concise, and complete version.
I added a few comments to the remaining comments but I noticed there were more than I expected so I stopped midway 😅
* Provides access to the current effect scope. | ||
* | ||
* This may be undefined at times when there's no effect active effect scope at | ||
* this very moment. |
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.
I think we should just align with the API docs on this one: https://vuejs.org/api/reactivity-advanced.html#getcurrentscope (much shorter and complete)
packages/reactivity/src/reactive.ts
Outdated
@@ -65,26 +65,33 @@ function getTargetType(value: Target) { | |||
export type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T> | |||
|
|||
/** | |||
* Creates a reactive copy of the original object. | |||
* Creates a deeply-reactive copy of the original object. |
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.
This still remains
packages/reactivity/src/reactive.ts
Outdated
* Return a shallowly-reactive copy of the original object, where only the root | ||
* level properties are reactive. It also does not auto-unwrap refs (even at the | ||
* root level). | ||
* Creates a shallowly-reactive copy of the original object. |
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.
still remains
packages/reactivity/src/reactive.ts
Outdated
@@ -147,8 +164,32 @@ export type DeepReadonly<T> = T extends Builtin | |||
: Readonly<T> | |||
|
|||
/** | |||
* Creates a readonly copy of the original object. Note the returned copy is not | |||
* made reactive, but `readonly` can be called on an already reactive object. | |||
* Creates a readonly copy of the original object. |
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.
still remains
Relates to #4832 I basically copied over most of the documentation text and examples from the docs pages (and potentially merged it with already-existing inline docs).
Co-authored-by: Eduardo San Martin Morote <[email protected]>
Co-authored-by: Eduardo San Martin Morote <[email protected]>
Co-authored-by: Eduardo San Martin Morote <[email protected]>
Co-authored-by: Eduardo San Martin Morote <[email protected]>
Also shorten doc blocks a bit, remove overly-long examples etc.
Hey @posva I've shortened the doc blocks a bit, added links to the appropriate docs page where appropriate. What do you think? |
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! Almost finished 🙌
packages/reactivity/src/reactive.ts
Outdated
@@ -65,26 +65,33 @@ function getTargetType(value: Target) { | |||
export type UnwrapNestedRefs<T> = T extends Ref ? T : UnwrapRefSimple<T> | |||
|
|||
/** | |||
* Creates a reactive copy of the original object. | |||
* Creates a deeply-reactive copy of the original object. |
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.
This one hasn't change: it's not a copy
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 a lot!
Hey @posva 👋 Anything else I should do or could/should this be merged now? 🦄 |
@defaude Thanks for your hard work and patience! This is great. |
Not done yet. This is merely a starter so that others can check if I'm going in the right direction.
Closes #4832