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

docs(cli): improve spinner.message document #4785

Merged
merged 2 commits into from
May 23, 2024

Conversation

andrewthauer
Copy link
Contributor

This makes the Spinner in @std/cli expose a message property to be consistent with the existing color property. It also adds doc comments and an examples for both message and color

NOTE: I noticed another issue while making this change. The Color type also includes Ansi which is defined as a string. However, the actual code in the set color property will never let you set this to anything other then a valid COLORS value.

@andrewthauer andrewthauer requested a review from kt3k as a code owner May 21, 2024 03:31
@CLAassistant
Copy link

CLAassistant commented May 21, 2024

CLA assistant check
All committers have signed the CLA.

@andrewthauer andrewthauer force-pushed the cli-spinner-message-docs branch from eff5d38 to 21c9b8e Compare May 21, 2024 03:31
@github-actions github-actions bot added the cli label May 21, 2024
@kt3k
Copy link
Member

kt3k commented May 21, 2024

Changing message seems already supported? See #4079

@andrewthauer andrewthauer force-pushed the cli-spinner-message-docs branch from 21c9b8e to 7a62478 Compare May 22, 2024 10:19
@andrewthauer andrewthauer changed the title feat(cli): add spinner.message prop refactor(cli): change spinner.message to property & document May 22, 2024
@andrewthauer
Copy link
Contributor Author

andrewthauer commented May 22, 2024

Changing message seems already supported? See #4079

That's correct. The feature is already available. I've updated the commit message and PR title to better reflect the change.

Reason - I did not realize you could change message initially which led me to look at the code and realized it was a public field and not a property like color is. The documentation in jsr for fields isn't as clearly noticeable atm (separate issue).

So, I figured it would make more sense to use a formal property here so it's both consistent with color and has some documentation. I've also added docs for the existing color property methods too.

@andrewthauer andrewthauer force-pushed the cli-spinner-message-docs branch from 7a62478 to abdd318 Compare May 22, 2024 10:34
@kt3k
Copy link
Member

kt3k commented May 22, 2024

This sounds rather doc issue, or UI issue of JSR. message property doc appears in JSR https://jsr.io/@std/cli/doc/spinner/~/Spinner#property_message . So changing message to getter/setter seems like increasing unnecessary boilerplate.

How about updating the API doc of message property (Probably adding the @example of the current set message doc)?

@andrewthauer
Copy link
Contributor Author

andrewthauer commented May 22, 2024

This sounds rather doc issue, or UI issue of JSR. message property doc appears in JSR https://jsr.io/@std/cli/doc/spinner/~/Spinner#property_message . So changing message to getter/setter seems like increasing unnecessary boilerplate.

How about updating the API doc of message property (Probably adding the @example of the current set message doc)?

To me this is more about consistency and readability of the class. The act of creating a property screams this is meant to be public. Where, a field could just be something you accidentally forgot to make private explicitly. Also, fields tend to be located at the top which then makes interlacing larger comments between fields a bit unwieldy imo.

Another thing that is potentially an issue is usage of constructor(public someField: string). It doesn't appear someField is easily document-able as far as I can tell. This might be something for consideration.

Anyways, I looked around and see there is some precedence for making fields public already. I'm happy to comment the field versus making is a property. If any of my thoughts resonate let me know and I'm happy to adjust.

An interesting note here is that LSP's seem to show both the same (property in vscode & field in neovim), but jsr distinguishes field & property differently.

@andrewthauer andrewthauer force-pushed the cli-spinner-message-docs branch from abdd318 to ccdc5aa Compare May 23, 2024 10:29
Copy link

codecov bot commented May 23, 2024

Codecov Report

Attention: Patch coverage is 78.57143% with 3 lines in your changes are missing coverage. Please review.

Project coverage is 91.97%. Comparing base (082107b) to head (65f5a8e).

Files Patch % Lines
cli/spinner.ts 78.57% 3 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4785      +/-   ##
==========================================
- Coverage   91.97%   91.97%   -0.01%     
==========================================
  Files         487      487              
  Lines       41539    41542       +3     
  Branches     5365     5365              
==========================================
+ Hits        38207    38208       +1     
- Misses       3274     3276       +2     
  Partials       58       58              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

Nice docs! LGTM

@kt3k kt3k changed the title refactor(cli): change spinner.message to property & document docs(cli): improve spinner.message document May 23, 2024
cli/spinner.ts Outdated
* }
*
* spinner.stop();
* spinner.message = "Done!";
Copy link
Contributor Author

@andrewthauer andrewthauer May 23, 2024

Choose a reason for hiding this comment

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

Just realized this should be console.log since setting the message after stop won't do anything. I'll fix!

Copy link
Member

@kt3k kt3k left a comment

Choose a reason for hiding this comment

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

LGTM again. Thanks for your contribution!

@kt3k kt3k merged commit 50951cc into denoland:main May 23, 2024
12 checks passed
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.

3 participants