-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
[docs] adds jsdoc for most functions in runtime API #7235
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
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.
Thank you! Generally I think these are good additions. I'm not sure though if we need the docs to start with the function signature, that is something the user knows already from the other IDE visualizations.
its kind of obscured in typescript and not reads well |
I would agree we should not include the function signature. If there's some tool that doesn't display the function signature well we should fix that tool rather than updating all of our documentation |
I'm also not sure we need examples of these functions being called |
Its some thing helpful during development why not ? |
Co-authored-by: Ben McCann <[email protected]>
Co-authored-by: Ben McCann <[email protected]>
what about signiture of transitions? transition:fly={params} |
Quite a lot of them don't add anything. E.g. the first one I see in the PR is |
Looking at Re |
component.$destroy() is obvious even in the svelte.dev/docs but it doesn't mean that it shouldn't be there ! Jsdoc could reduce the need for referring to documentation for developers most of the time. |
If you're typing: const app = new App({ target: document.body })
app.$d| where Also side note, it looks like when I test the above example in VSCode. There're already JSDocs from |
so It might be a problem for component jsdoc. but my main Idea was about the runtime functions for example specially I find it really annoying to refer to documentation every time I want just know what stiffness does in spring function for example ! |
I generally agree. |
We could have just text to describe the properties of the option, which I think this PR already does, but I think the point was that we should avoid having example code in the jsdoc unless it provides more value that the text can cover. Now in most cases, it would be better with text only. It'll also benefit if we can get shorter jsdoc since inline documentation should be more straightforward than a full documentation. Of course, writing/adding docs is subjective though so I can't blame you with the first pass of the PR 😬 For now, it would be great to keep it simple and enhance it later in the future. |
you know I am really a fan of Rust and its ecosystem and almost all crates in rust ecosystem have a good documentation through inline docs which is really helpful and that was a great experience. In most IDEs the full documentation is not showing up so the users will see what their expect at the first time. if the user wants more scroll is available ... although at the end of the day I think svelte ( or even javascript ) community wouldn't accept it or consider it helpful so what should I do now ? |
* off(); | ||
* ``` | ||
* | ||
* @param type |
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 if we're going to add @param
tags then they should have descriptions of those parameters
export function spring<T=any>(value?: T, opts: SpringOpts = {}): Spring<T> { | ||
const store = writable(value); | ||
/** | ||
* A `spring` store gradually changes to its target value based on its `stiffness` and `damping` parameters. Whereas `tweened` stores change their values over a fixed duration, `spring` stores change over a duration that is determined by their existing velocity, allowing for more natural-seeming motion in many situations. The following options are available: |
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 is copied from https://svelte.dev/docs#run-time-svelte-motion-spring
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 making the effort to improve the docs
I think that copying info from the docs into the JSDocs is not the right approach. Almost certainly we will end up with cases where one version of the docs is updated and not the other leading to confusion and difficulty maintaining the docs. We're planning to investigate a tighter integration between the code and docs. We're going to start with that in the SvelteKit docs by trying out https://shikijs.github.io/twoslash/. I understand the convenience of seeing more in the editor and not having to pull up the docs in a separate browser window. However, I think we need to figure out the tooling piece of this so that we can have just a single place to maintain the docs
I'm not sure it's worth continuing with this PR. The better approach might be to close it and instead work on improving the tooling of the SvelteKit docs and then leveraging those improvements in the Svelte core docs once we've decided on a good way of doing things
Yes of course it is not a good idea to just copy/paste the docs. and this was the reason why I've added all code examples and even the function signature at first |
It's an interesting idea. I think we need to agree on a plan and what tooling we want to use before we start changing stuff. I'd suggest the #contributing channel in Discord or an issue in SvelteKit might be a good place to start. We want to experiment with SvelteKit before making any changes here, so I'm going to go ahead and close this. Thanks for your efforts on this |
Before submitting the PR, please make sure you do the following
[feat]
,[fix]
,[chore]
, or[docs]
.Tests
npm test
and lint the project withnpm run lint
what happened ?
this PR adds jsdoc for most functions in runtime API
some parameters are renamed for better readability and more meaningful names
some interfaces are exported ( they were used in public api but didn't exported ) and they are mostly renamed ( it does not cause breaking change because its a new export )
additionally the fallback parameter off crossfade is merged into single interface ( it was separated )
#7230