runem / web-component-analyzer

CLI that analyzes web components and emits documentation
https://runem.github.io/web-component-analyzer
MIT License
503 stars 63 forks source link

Add Web-Types generation support #239

Open jpradelle opened 2 years ago

jpradelle commented 2 years ago

Add Web-Types transformer to generate web-types files.

Web-Types is a project to enable IDE auto-completion for web-components, currently implemented in IntelliJ and WebStorm: https://github.com/JetBrains/web-types

For example after generating web-types file with web-component-analyzer image

marcobeierer commented 2 years ago

@runem Thank you for your great work.

Quick question: Are you interested in adding support for web types or would your prefer if we maintain a fork?

jpradelle commented 2 years ago

Currently a release of fork is available here https://www.npmjs.com/package/web-component-analyzer-webtypes I would rather have it merged in this branch :) I'm currently using and maintaining the fork

marcobeierer commented 2 years ago

@jpradelle Thank you for the info, good to know :+1:

minijus commented 2 years ago

Would any of owners/contributors be able to review this awesome PR? @rictic @43081j @runem

43081j commented 2 years ago

ill try have a read through it this weekend if i can, and get my head around it.

interesting that jetbrains chose to build their own schema rather than use custom elements manifest. maybe it didn't exist when they made it.

piotrtomiak commented 2 years ago

@43081j Web-Types were in development much longer than the custom-elements-manifest and are more generic as they are not tied to a particular framework. Unfortunately we haven't made it in time before custom-elements-manifest was finished. Besides for Web Components, the format is used for Vue.js, Angular, HTMX and others. It also allows pattern processing, so works with for instance Fontawesome library.

It would be awesome if the PR is merged! I will then update documentation in the web-types GitHub repo on how to generate web-types for Web Components.

jpradelle commented 2 years ago

@piotrtomiak Great suggestion, I'll have a look to integrate that. I'll also take @Atulin work which is great, but I want to preserve a way to configure parameter in command line too, I'll need to do some adaptation: I build webtypes during release process, it needs to be build it with the next version number that will be released at end of release process

jpradelle commented 2 years ago

@piotrtomiak I made requested update taking inspiration from @atulin work, configuration of projects is cleaner this way :) For example: https://github.com/jpradelle/polymer-web-types/commit/4996ba7bc6f0b785637d3eaae96b3ba24976560f#diff-7ae45ad102eab3b6d7e7896acd08c427a9b25b346470d7bc6507b6481575d519

I did not read name or version from package.json, I took it from environment variable added by npm when you run a script from npm run, so if you don't run it from npm scripts package section this doesn't find name of version and it has to be provided via command line or package.json wca configuration. I think it does the job even if it's not perfect. I did that to avoid adding new dependencies to project. I would be happy if someone has a better way to suggest

jpradelle commented 2 years ago

For clean support of PolymerJS web comopnents, please also consider merging this PR https://github.com/runem/web-component-analyzer/pull/238

43081j commented 2 years ago

i haven't had time to try it myself but what i've read so far seems fine, makes sense.

it'd be really, really nice if you could add some tests though 👀

and ideally we need a review from @rictic if he gets some spare time

jpradelle commented 2 years ago

I added several tests

minijus commented 1 year ago

Any update on this PR? Would be lovely to have a review by code owners to get support for web-types merged and released.

43081j commented 1 year ago

Sorry it took so long to reply here.

I can re-review it (and will) but I think we need Peter or someone else from the lit team to review/merge. I'll see if I can pair with someone from the team in the new year and get things moving

m4olivei commented 2 months ago

Any updates here? Would love to see this land. I've used a fork of the fork mentioned here with success: https://github.com/tevey/web-component-analyzer

43081j commented 2 months ago

This repo is slow to update, and the alternative analyzer by the lit team doesn't yet have a vscode plugin etc

I think it'll be up to me or @justinfagnani to update if either of us get some time. Or we somehow find time to finish the official one and do this there instead

m4olivei commented 2 months ago

@43081j where is the official one?

43081j commented 2 months ago

You can find it here: https://github.com/lit/lit/tree/main/packages/labs/analyzer

There are plans to build an official vscode extension but work hasn't started on it yet