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

Sveld descriptions not coming through to end dev projects #576

Closed
niktek opened this issue Nov 18, 2022 · 6 comments
Closed

Sveld descriptions not coming through to end dev projects #576

niktek opened this issue Nov 18, 2022 · 6 comments
Assignees
Labels
bug Something isn't working help wanted Extra attention is needed

Comments

@niktek
Copy link
Contributor

niktek commented Nov 18, 2022

Current Behavior

So, some bad news. In projects where Skeleton is installed as a package into node_modules, we no longer get all the description information in intellisense. I've also tried installing vite-plugin-sveld and sveld as devDep's in the end-dev project, which doesn't improve the situation either.

This also brings up another point - the actual type exports are only available through the sveld cli, which we know only works with Svelte projects. However, with the upcoming monorepo and the splitting of docsite from the component lib, there may be scope for moving the lib into a pure Svelte project ? Which could bring the in project descriptions back for end developers.

Steps To Reproduce

No response

Anything else?

No response

@niktek niktek added the bug Something isn't working label Nov 18, 2022
@niktek niktek changed the title Sveld comments not coming through to end dev projects Sveld descriptions not coming through to end dev projects Nov 18, 2022
@endigo9740
Copy link
Contributor

I was checking this - so it's the prop descriptions that are not working, not the component description for anyone confused like myself! The former are definitely not working, while the latter are. The Component description is a non-standard comment feature of SvelteKit though so I suppose that's why.

@endigo9740 endigo9740 added this to the v1.0 milestone Dec 4, 2022
@endigo9740 endigo9740 added the help wanted Extra attention is needed label Dec 4, 2022
@endigo9740
Copy link
Contributor

@niktek You shared some notes on this on Discord - can you reiterate what was learned here to preserve this for this future? If I remember correctly this is a limitation of Typescript (or SvelteKit) and we may not be able to proceed with a fix in the short term.

Is that correct? If so let's remove the v1 milestone from this please.

@niktek
Copy link
Contributor Author

niktek commented Jan 8, 2023

Long story short - currently svelte-package does not emit JSDoc comments into the .d.ts files. This is likely not svelte-package's problem at all, but more to do with TS stripping comments: microsoft/TypeScript#14619

Goal: Put the jsdoc comments back into the generated .d.ts files that are created by the svelte-package process.

I've looked at using svelte/compiler's parse() functionality to return an AST that we can then walk through to get to get the docs and related identifier. This will not work as it requires svelte-preprocess to transform the components into their respective parsed components (TS/CSS/component body HTML/svelte flow control)

I've looked at using svelte-preprocess. It's not going to work as it expects to be in a Vite environment due to the external plugins it relies on to do the preprocessing. Whereas our script would be operating in a pure Node environment.

At this point there are two options left to explore:

  • Naive string parsing, super simple to extract the JSDoc blocks, but a bit tricker to reliably find the identifier they are related to - considering that we are only wanting it for exported props and thus have to only check the line following the JSDoc block for an 'export' word, this will probably be the easiest/dumbest route to go. If it fails, then the description disappears in Intellisense. Not the end of the world.
  • Extract the <script *> portion of each component into a string and then use the acorn package (which SK uses internally) to get an AST that will more reliably find the associated prop. It's another dep and raises the maintenance requirements both package wise and mentally in terms of a future dev trying to make changes or troubleshoot.

A reluctant third option (but probably the most correct) is to deep dive into svelte-package and try and fix the problem at the source for everyone.

@endigo9740
Copy link
Contributor

Thanks Nik. Given this I'm going to drop this from the v1 milestones. This just means is not required for v1, but we can still continue working on as the opportunity arises.

@endigo9740 endigo9740 modified the milestones: v1.0, Future/Whenever Jan 8, 2023
@niktek niktek self-assigned this Jan 10, 2023
@endigo9740
Copy link
Contributor

@niktek this is working now, right?

@niktek
Copy link
Contributor Author

niktek commented Feb 16, 2023

yep!

@niktek niktek closed this as completed Feb 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants