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

Add code actions to generate doc comments #4642

Merged
merged 5 commits into from
Jun 12, 2023
Merged

Conversation

sdankel
Copy link
Member

@sdankel sdankel commented Jun 7, 2023

Description

Closes #4571

Following the directory structure for code actions that was there before, I've added new modules for:

  • function decls
  • enum variants
  • storage fields
  • configurable constants

Following FuelLabs/sway-standards#5, the doc comment template is the same for all of these except for functions. For functions, the template includes the argument names & types, return value, and a generated example of usage which is just meant to be a starting point for the comment author.

For the basic template that most of these use, I created BasicDocCommentCodeAction. I also refactored some of the "generate impl" code actions that were there before into a trait called GenerateImplCodeAction to keep their common functionality separate from the "generate doc comment" code actions.

I updated the existing code action tests for enums & structs, and added a new one for functions. I didn't think it was necessary to test enum variants, storage fields, etc. since the template and underlying code is the same.

Example generating docs for a function

Jun-07-2023 17-01-17

Checklist

  • I have linked to any relevant issues.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have updated the documentation where relevant (API docs, the reference, and the Sway book).
  • I have added tests that prove my fix is effective or that my feature works.
  • I have added (or requested a maintainer to add) the necessary Breaking* or New Feature labels where relevant.
  • I have done my best to ensure that my PR adheres to the Fuel Labs Code Review Standards.
  • I have requested a review from the relevant team or maintainers.

@sdankel sdankel marked this pull request as ready for review June 8, 2023 00:02
Copy link
Member

@bitzoic bitzoic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So cool!!!! I tried it out for enums, structs, functions, storage, and config blocks. Needless to say my mind was blown 🚀

I noticed that it doesn't give me the option to generate docs for function definitions within an ABI/interfaces. Will that be in another PR?

Copy link
Member

@JoshuaBatty JoshuaBatty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice work @sdankel 🚀

Looks good.

@JoshuaBatty JoshuaBatty added the language server LSP server label Jun 8, 2023
@sdankel
Copy link
Member Author

sdankel commented Jun 9, 2023

I noticed that it doesn't give me the option to generate docs for function definitions within an ABI/interfaces. Will that be in another PR?

Good catch! I will do that in a separate PR: #4645

@sdankel sdankel enabled auto-merge (squash) June 9, 2023 21:52
@sdankel sdankel merged commit 733d9b5 into master Jun 12, 2023
26 checks passed
@sdankel sdankel deleted the sophie/comments-code-actions branch June 12, 2023 12:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Code actions: generate doc comments per Sway standard
4 participants