kkoomen / vim-doge

(Do)cumentation (Ge)nerator for nearly 20 languages 📚 Generate proper code documentation with a single keypress. ⚡️🔥
GNU General Public License v3.0
1.01k stars 51 forks source link

[Feature] Add support for Svelte #628

Closed HendrikPetertje closed 1 year ago

HendrikPetertje commented 1 year ago

Heya,

When running doge#generate on a .js, .ts or even .tsx file I see no problems at all, but when I try to execute doge on a .svelte file then I'm met with this error:

image

I can't really switch filetype on my svelte files to HTML (which it essentially looks like) as LSP and completion are all helping me out with svelte-specific help.

Can I do something to make doge play nicely or is a change required in this plugin to make jsdoc generation work on svelte files?

HendrikPetertje commented 1 year ago

I tried adding this:

vim.g.doge_filetype_aliases = {
  javascript = { 'svelte' }
}

But then my entire file is parsed as a javascript file all of a sudden (which does not recognize HTML tags)

Without this rule: image

With the above snippet enabled: image

kkoomen commented 1 year ago

This indeed gives error in the current version. There is a tree-sitter svelt parser. I can implement this logic soon and make it a bit more dynamic so that I can also implement support for Vue files.

kkoomen commented 1 year ago

@HendrikPetertje I have implemented everything locally on a new branch including tests. Basically the root-level <script> tag right now is being parsed and then the contents are passed to the typescript parser. I will dig in a bit deeper in other possible use cases this weekend in how people tend to work with Svelte, just to make sure I've handled all the use cases. I'll let you know once I'm finished, but I can definitely do a release with proper support for svelte.

kkoomen commented 1 year ago

This has been added v4.4.0.

HendrikPetertje commented 1 year ago

THIS IS SO COOL, THANKS!

kkoomen commented 1 year ago

@HendrikPetertje Hope you enjoy. By the way, I've already did release v4.5.0 which also supports HTML and VueJS as well.