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

Use shiki-twoslash for .svelte code blocks #649

Open
Rich-Harris opened this issue Feb 18, 2022 · 7 comments · May be fixed by #955
Open

Use shiki-twoslash for .svelte code blocks #649

Rich-Harris opened this issue Feb 18, 2022 · 7 comments · May be fixed by #955

Comments

@Rich-Harris
Copy link
Member

Describe the problem

We just upgraded the docs to use shiki-twoslash, which provides tooltips on js code blocks:

image

It would be cool if svelte blocks got the same treatment.

Describe the proposed solution

Honestly no idea, but @jasonlyu123 got a POC working previously: sveltejs/kit#3324 (comment)

Alternatives considered

No response

Importance

nice to have

Additional Information

No response

@eltigerchino eltigerchino transferred this issue from sveltejs/kit Oct 26, 2024
@eltigerchino eltigerchino transferred this issue from sveltejs/svelte Oct 26, 2024
@jasonlyu123
Copy link
Member

Right, I never followed up on this. At some point, the POC became overly complicated when new stuff was added to the kit docs. The biggest issue is supporting the // ---cut--- comment as the script tag needs to be partly cut so source-map is harder. There is also some ts diagnostics error in svelte2tsx generated code that needs to be filtered out in a weird way and also requires a different sourcemap. So there are like a total of 3 or 4 kinds of sourcemap.

@eltigerchino
Copy link
Member

eltigerchino commented Oct 26, 2024

I assumed this was working when I saw the hover tooltips on variables for the new svelte site https://svelte.dev/docs/svelte/$state . I think I misunderstood since those blocks were JS only. Svelte blocks still don't have them.

@eltigerchino eltigerchino reopened this Oct 26, 2024
@jasonlyu123
Copy link
Member

Yeah. the library only works with ts/js so there isn't hover info in the svelte file. There is now a twoslash vue and eslint so maybe there would be more stuff added to the base library making it easier and not needing so many layers of source map.

@Hugos68
Copy link

Hugos68 commented Oct 31, 2024

I've made some efforts to build twoslash/svelte as a project for the upcoming Svelte hackathon:

If this is something that you think will be valueable to the docs I will gladly submit a PR to add twoslash to .svelte blocks. It has 100% feature parity, so highlights, hovers, queries, cutted blocks etc all works.
Just note that the PR is still just a PR so the package isn't out yet.

This is how it looks for example:
{F4824DA9-4F0F-4065-9C87-FE20D3824F2E}

@huntabyte
Copy link
Member

@Hugos68 I have been patiently waiting for someone to build a Svelte integration for this for quite some time. This is incredible and will benefit not only the svelte.dev site but the entire ecosystem of Svelte libraries 💪 incredible job!

@linear linear bot added the svelte.dev label Nov 5, 2024
@Rich-Harris
Copy link
Member Author

If this is something that you think will be valueable to the docs I will gladly submit a PR to add twoslash to .svelte blocks

This would be incredible, thank you!

@Hugos68
Copy link

Hugos68 commented Nov 5, 2024

Sure thing, once twoslash-svelte gets merged into twoslash I'll submit a PR 👍

@Hugos68 Hugos68 linked a pull request Dec 7, 2024 that will close this issue
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants