Skip to content
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

Svelte 5: API docs solution #435

Open
techniq opened this issue Jul 13, 2024 · 5 comments
Open

Svelte 5: API docs solution #435

techniq opened this issue Jul 13, 2024 · 5 comments
Labels
documentation Improvements or additions to documentation

Comments

@techniq
Copy link
Owner

techniq commented Jul 13, 2024

Since the AST has changed in Svelte 5 (and is not a public API guarantee), currently sveld's ComponentParser does not work, which we use to generate the API docs for each component (LayerChart as well).

Svelte 4 Svelte 5
image image

although the instance AST looks identical for a very basic example:

Svelte 4 Svelte 5
image image
@techniq
Copy link
Owner Author

techniq commented Jul 13, 2024

Actually the issue might be that Svelte 5 now natively supports Typescript, but in Svelte 4 it would be preprocessed away (I believe).

image

This was referenced Jul 13, 2024
@techniq techniq added the documentation Improvements or additions to documentation label Sep 28, 2024
@ryanatkn
Copy link

If you'd like to borrow ideas/code I got a usable amount working here: https://github.com/ryanatkn/svelte_docinfo_sketch

@techniq
Copy link
Owner Author

techniq commented Oct 13, 2024

@ryanatkn This looks great! Let me dig in and give it a test with Svelte UX (and LayerChart if all goes well).

Does this only support Svelte 5 syntax ($props, etc)? One of the challenges is I'm hoping to keep Svelte UX and LayerChart 1.x to be Svelte 3-5 compatible (and thus can not use Svelte 5 syntax yet), and make 2.x a breaking changes and require Svelte 5. I would love to find a solution that allows this iterative transition, but that might be too challenging.

With Svelte 5 going public VERY soon (looking at you Svelte Summit), I'll be going all in on migrating to Svelte 5 very soon, but would love to do it as iteratively as possible.

@ryanatkn
Copy link

ryanatkn commented Oct 14, 2024

I hope it helps, I'm happy to answer any questions. Yeah it's only Svelte 5, my hacky recommendation would be to detect runes and use Sveld for v3/4. I wouldn't want to discourage anyone from trying to to extend either Sveld with my sketch's stuff or the other way around, but the intregration doesn't look easy - starting from Sveld and using this as a guide may be easier. I haven't seen confirmation of their plans.

The main limitation of mine is that it currently only looks at the AST. I may either use ts-morph or the Svelte language server like Sveld to infer types - exports for example don't have them. (but if I use ts-morph I'm guessing I'd be duplicating a lot of work of the language server, and that's what Sveld does already - I'll look into this) Props are easier and the basics seem to work, but it it would probably be more correct with inference.

@techniq
Copy link
Owner Author

techniq commented Oct 22, 2024

In the short term I decided to remove the API docs as it was the only show stopper from deploying the doc sites with Svelte 5, and there currently isn't a solution (yet) that supports Svelte 3-5 syntax.

After a few other priorities are shipped, I plan to start on the Svelte 5 migration of both libraries, but it will be a breaking change (no Svelte 3/4 support). I wanted to validate the current codebase could run on Svelte 3-5 to ease the transition for projects to Svelte 5 (incremental, not big bang) which running the full docs of both Svelte UX and LayerChart accomplishes.

@ryanatkn Thanks so much for your project. I'll likely be leveraging it once both projects are on Svelte 5.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

2 participants