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

Generate web-types for @ionic/vue package #19522

Closed
piotrtomiak opened this issue Oct 2, 2019 · 17 comments · Fixed by #22428
Closed

Generate web-types for @ionic/vue package #19522

piotrtomiak opened this issue Oct 2, 2019 · 17 comments · Fixed by #22428
Labels
help wanted a good issue for the community package: vue @ionic/vue package type: feature request a new feature, enhancement, or improvement
Milestone

Comments

@piotrtomiak
Copy link
Contributor

piotrtomiak commented Oct 2, 2019

Feature Request

Ionic version:

[x] @ionic/vue 0.0.x

Feature Request

This is a feature request to include web-types metadata information with @ionic/vue library to provide users of WebStorm (and possibly other IDEs in the future) with precise code completion, inspections and documentation for Ionic components.

Preferred Solution

The best solution would be to generate the file based on existing Ionic documentation JSONs during the build process and ship it with the library. This solution has been implemented in quasar library and are being worked on in vuetify and bootstrap-vue. I've looked at some of the JSONs generated by ionic documentation and it should be relatively straightforward to transform information to a slightly different format.

I can work on the transformation code itself, but it would be pretty difficult for me to hook into the build process in the correct place, so I need some help from your side, before I can create a PR for this.

Alternatives

It's difficult for an IDE to analyze contents of compiled Vue library and the quality of code completion, inspection and documentation is pretty poor. web-types offer excellent opportunity to provide consumers of your library with precise information. It is especially useful for new users of the library as it allows to avoid constant looking into documentation on the web.

Related Code

Here is an example PR from Quasar - quasarframework/quasar#4749

Additional Context

The feature has been requested by one of our users on Twitter: https://twitter.com/leereichardt/status/1165554297225891841

@ionitron-bot ionitron-bot bot added the triage label Oct 2, 2019
@liamdebeasi
Copy link
Member

Thanks for the issue! We recently released an all new Ionic Vue beta that should fix most of the issues reported. Can you try out the latest Ionic Vue beta and let me know if this is still an issue?

Getting Started with the latest Ionic Vue beta

The new Ionic Vue beta is built for Vue 3. Moving forward, we are not going to support Vue 2. For information on how to get started with the latest beta, check out our Ionic Vue Getting Started Guide.

At this time, we do not have a migration path from Ionic Vue built for Vue 2 to Ionic Vue built for Vue 3, but the Ionic Framework differences should be minimal.

Feel free to check out our Ionic Vue Beta Announcement blog post for more details on this release.

Help! The reported issue still happens in the latest Ionic Vue beta.

Please follow up here with the issue reproduced in an Ionic starter application running the latest Ionic Vue beta. Also include any revised steps to reproduce the issue. Issues that do not have a GitHub repo with the issue reproduced in an Ionic starter app will be closed.

My issue is resolved/My issue is no longer relevant.

You can either close the issue yourself, or do nothing. If there is no response within 14 days, this thread will be automatically closed.

I have a new issue.

Please create a new issue. Be sure to reproduce the issue in an Ionic starter application running the latest Ionic Vue beta and include a link to the repo.

Be sure to search for your issue first, as the issue you are running into may have already been reported.

We are excited to get closer to the Ionic Vue release and look forward to welcoming new Vue developers to the Ionic community. Please let me know if there are any questions. Thanks!

@liamdebeasi liamdebeasi added needs: reply the issue needs a response from the user package: vue @ionic/vue package labels Sep 10, 2020
@piotrtomiak
Copy link
Contributor Author

@liamdebeasi It looks like the issue is still valid. Vue 3 doesn't provide good framework for documenting components, directives and filters provided by the library for use in templates.

@ionitron-bot ionitron-bot bot added triage and removed needs: reply the issue needs a response from the user labels Sep 13, 2020
@liamdebeasi
Copy link
Member

Thanks for checking! To clarify, this is just for WebStorm, correct?

@liamdebeasi liamdebeasi added type: feature request a new feature, enhancement, or improvement and removed triage labels Sep 14, 2020
@liamdebeasi liamdebeasi added this to the @ionic/vue beta 2 milestone Sep 14, 2020
@piotrtomiak
Copy link
Contributor Author

piotrtomiak commented Sep 14, 2020

@liamdebeasi At this point yes, but web-types (https://github.com/JetBrains/web-types) are open standard and we hope other editors will also support it. There is FR for VSCode Vetur plugin vuejs/vetur#2090 to support web-types. Vetur is currently using it's own format, which is very limited and doesn't support component slots, directives, filters etc.

I can contribute web-types generation. All I need is for someone familiar with the build system, to show me where to plug-in, so that I can access Ionic documentation and generate the file.

@liamdebeasi
Copy link
Member

Thanks! We would love to have a contribution for this. In terms of the build system, @ionic/vue is here: https://github.com/ionic-team/ionic-framework/tree/ionic-vue/packages/vue. During the beta, we are going to be working in the ionic-vue branch.

proxies.ts has all the Ionic components that are auto generated from the core directory.

components/ has additional components that wrap the regular Ionic components to provide additional features (such as router integration)

The build system is fairly straightforward: https://github.com/ionic-team/ionic-framework/blob/ionic-vue/packages/vue/package.json#L5-L12 We aren't really doing anything to fancy here.

Is there any other information that would be helpful?

@liamdebeasi liamdebeasi added the help wanted a good issue for the community label Sep 14, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented Sep 14, 2020

This issue has been labeled as help wanted. This label is added to issues that we believe would be good for contributors.

If you'd like to work on this issue, please comment here letting us know that you would like to submit a pull request for it. This helps us to keep track of the pull request and make sure there isn't duplicated effort.

For a guide on how to create a pull request and test this project locally to see your changes, see our contributing documentation.

Thank you!

@piotrtomiak
Copy link
Contributor Author

@liamdebeasi Thanks for the pointers! What I am missing here is the access to the actual documentation for the elements and attributes, not just the list of them. E.g. docs here https://ionicframework.com/docs/api/back-button have detailed description for color attribute. To generate web-types properly I need to access this documentation.

@liamdebeasi
Copy link
Member

Sure thing - so that will all be found in the core directory: https://github.com/ionic-team/ionic-framework/tree/master/core/src

All components have their documentation autogenerated into the following files:

  1. This file contains information regarding types: https://github.com/ionic-team/ionic-framework/blob/master/core/src/components.d.ts
  2. This file contains the entire API that is then used to automatically generate the component documentation pages you see on our Ionic Docs website. https://github.com/ionic-team/ionic-framework/blob/master/core/api.txt. It is generated via this file: https://github.com/ionic-team/ionic-framework/blob/master/core/scripts/api-spec-generator.js

Taking ion-back-button as an example:

  1. The component file is found here: https://github.com/ionic-team/ionic-framework/blob/master/core/src/components/back-button/back-button.tsx. Notice there are special comments which describe properties, shadow parts, etc.
  2. The types are generated into component.d.ts: https://github.com/ionic-team/ionic-framework/blob/master/core/src/components.d.ts#L155-L188
  3. The API is generated into api.txt: https://github.com/ionic-team/ionic-framework/blob/master/core/api.txt#L82-L125

@piotrtomiak
Copy link
Contributor Author

Thanks! Looks like I should be able to take it from here :)

@liamdebeasi
Copy link
Member

liamdebeasi commented Sep 14, 2020

Great! Happy to answer any additional questions if they come up 👍 We appreciate you taking a look at this!

@liamdebeasi liamdebeasi removed this from the @ionic/vue beta 2 milestone Sep 23, 2020
@grgur
Copy link

grgur commented Oct 14, 2020

If you like to use Vetur then you can try this simple plugin that adds autocompletion for tags and attributes to your Ionic Vue project: https://www.npmjs.com/package/@modus/ionic-vetur

Just add it to the project and it will work automatically (given that you already have Vetur installed)

npm i modus/ionic-vetur -D

@liamdebeasi
Copy link
Member

Hey there @piotrtomiak,

Wanted to check in and see if you were able to make any progress. Now that Ionic Vue has shipped, I have some additional time to help out if you need it.

@piotrtomiak
Copy link
Contributor Author

@liamdebeasi Sorry, I wasn't able to start it yet, I need to fix various Vue-related bugs for upcoming WebStorm release and I'll be able to work on this afterwards, probably within 2-3 weeks.

@liamdebeasi
Copy link
Member

No problem! Let me know if I can help with anything.

piotrtomiak added a commit to piotrtomiak/ionic-framework that referenced this issue Nov 4, 2020
piotrtomiak added a commit to piotrtomiak/ionic-framework that referenced this issue Nov 4, 2020
@piotrtomiak
Copy link
Contributor Author

piotrtomiak commented Nov 4, 2020

@liamdebeasi I've created a PR with the changes. Please review :) The generation code places web-types.json in dist folder, let me know if it should be a different location. I have decided to use docs/core.json as the source as it contains all of the required information to generate web-types and it's just a matter of translation between two formats.

@liamdebeasi liamdebeasi added this to the 5.5.0 milestone Nov 4, 2020
@liamdebeasi
Copy link
Member

Thanks for the issue. This has been resolved via #22428, and a fix will be available in an upcoming release of Ionic Framework.

Thank you for all your help!

liamdebeasi pushed a commit that referenced this issue Nov 5, 2020
TakumaKira pushed a commit to TakumaKira/ionic-framework that referenced this issue Nov 13, 2020
@ionitron-bot
Copy link

ionitron-bot bot commented Dec 5, 2020

Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Ionic, please create a new issue and ensure the template is fully filled out.

@ionitron-bot ionitron-bot bot locked and limited conversation to collaborators Dec 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
help wanted a good issue for the community package: vue @ionic/vue package type: feature request a new feature, enhancement, or improvement
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants