Open mwcz opened 5 years ago
Thanks for you interest in this library!
First of all, sorry for my late answer. I have been very busy this week :-)
Right now the JSON format just outputs the internal data structure directly and replaces internal non-serializable types like nodes and types with "{NODE}"
and "{TYPE}"
(see this file).
I print the warning because I want it to output serialized types with ts-simple-type, locations of nodes and source file names. I want it to include as much information as possible. Therefore I don't think my final format will be missing information that's available right now.
In short, I want the JSON format to contain as much information as possible while being decoupled from my internal data structures.
I'm also very open for suggestions, so do you have any specific requirements in mind for your use case?
I will be focusing on improving the JSON output during the next two weeks. I'll keep you updated here 👍
Thanks for the reply!
Mostly I just wanted to know what you had planned, which all sounds great to me. There are a few things I would like to have access to in the JSON output. CMS integration of web components is the main driver for them, for example allowing a CMS to present web components in a highly visual authoring view. To do that, the CMS would need to know a few more things, such as:
@attr
)@attr {value1|value2} foo
but isn't a perfect approach since the underlying type is lost)<my-tabs>
may require contents to be <my-tab> + <my-tab-panel>
and a CMS should enforce that)I'm happy to open separate issues for each of these with more description and impl proposals. Happy to work up PRs too, if you like the suggestions.
Can it be something like VSCode HTML so that it is recognized by autocomplete?
That would be awesome, and it would solve item 2 above. I looked through https://github.com/microsoft/vscode-html-languageservice/blob/master/src/htmlLanguageTypes.ts and it looks like my items 1, 3, and 4 would still need to be provided somewhere outside of the VSCode HTML data structure. Still, getting autocompletion would be a great win!
@mwcz I have noted your needs and they all seem doable.
@attr {string} [attrname="default value"]
(https://jsdoc.app/tags-type.html). I don't parse this syntax right now, so we should open an issue on it.json
output, but the types are actually already outputted in the vscode
format (see below). @slot {"my-tab"|"my-tab-panel"} myslot
would make sense.I would be really happy if you open issues for each of these points! :-)
@goatandsheep I already support this format 🎉 (I call the output format vscode
). You can generate it by running the following command:
wca analyze my-component.js --format=vscode --outFile=output.json
I just published a couple of fixes to the output, so you should try version 0.1.8
of wca
when generating it :-)
@mwcz I agree that right now, all of your needs would probably be better met by the future json format generated by wca
. Version 1 of the vscode format is very light weight as of now, but I'm sure it will be able to contain more information in the future.
The recommendation is to put other component information into description.
@goatandsheep That would be a great addition to the output! I have created issue #6 to track it.
Hi @runem! I just discovered wca and have been enjoying experimenting with it.
One thing I'd like to use wca for is to automatically generate JSON schemas for our components (the project is PatternFly Elements). My plan is to ask wca for JSON, then feed that JSON into a schema template, which will then output the final schema.json file.
Before going all-in on that though, I wanted to ask about this output from wca:
What sort of JSON changes do you have in mind for wca? For now, I pinned the version of wca so we won't be surprised by any JSON format changes, so we're all good there. I just wanted to get a sense of what you plan to change.