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

Update JSDoc comments that get shown in editor #2999

Merged
merged 4 commits into from
Apr 7, 2022

Conversation

Princesseuh
Copy link
Member

@Princesseuh Princesseuh commented Apr 5, 2022

Changes

This updates all of our JSDoc comments on public-facing API in Astro files (so, Astro global, its methods etc) in order to improve the hover info we provide to users in the editor

It is not necessary to document client directives and other Astro-attributes as the language-server provides its own description for those using another mechanism (because those kinda lives in "HTML" land)

Example:

Before
image

After
image

I am not the best writer in the world regarding those short snippets so really, suggestions are very much welcome!

Testing

No tests needed

Docs

I guess, this is technically docs itself..

@changeset-bot
Copy link

changeset-bot bot commented Apr 5, 2022

🦋 Changeset detected

Latest commit: 752d62d

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
astro Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Apr 5, 2022
@Princesseuh Princesseuh marked this pull request as draft April 5, 2022 19:03
@Princesseuh Princesseuh changed the title [WIP] Update JSDoc comments in order to provide better hover information in editor [WIP] Update JSDoc comments that get shown in editor Apr 5, 2022
@Princesseuh Princesseuh changed the title [WIP] Update JSDoc comments that get shown in editor Update JSDoc comments that get shown in editor Apr 6, 2022
@Princesseuh Princesseuh marked this pull request as ready for review April 6, 2022 23:08
* [Astro documentation](https://docs.astro.build/en/guides/server-side-rendering/#astroredirect)
*/
redirect(path: string): Response;
/** Utility functions for modifying an Astro component’s slotted children
Copy link
Member Author

Choose a reason for hiding this comment

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

Since writing just Astro.slots is rare, I just copied the documentation and didn't elaborate further outside of a link

I know this technically does not document what Astro.slots really is, but our documentation also doesn't, so I figured we might not want users to use it directly (instead preferring the helper methods)

@@ -95,12 +175,29 @@ export interface AstroGlobalPartial {
/**
* @deprecated since version 0.24. See the {@link https://astro.build/deprecated/resolve upgrade guide} for more details.
*/
resolve: (path: string) => string;
/** @deprecated Use `Astro.glob()` instead. */
resolve(path: string): string;
Copy link
Member Author

Choose a reason for hiding this comment

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

As far as I know, in an interface there's no functional difference between defining a method using an arrow function or like this.

However, using an arrow function does change JSDoc behavior as we want the JSDoc comment on the function and not the resolve attribute, othewise TypeScript won't show the comment (and not get tags such as @deprecated) when using the method

This is particularly relevant here because Astro.resolve is deprecated and as such, should be striked-through in editors (which it didn't before this change)

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh! Very interesting, good to know.

Copy link
Member

@natemoo-re natemoo-re left a comment

Choose a reason for hiding this comment

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

LGTM! Great work!

@Princesseuh Princesseuh merged commit d1f2921 into main Apr 7, 2022
This was referenced Apr 7, 2022
@Princesseuh Princesseuh deleted the update-jsdoc-comments branch September 22, 2022 17:07
SiriousHunter pushed a commit to SiriousHunter/astro that referenced this pull request Feb 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: astro Related to the core `astro` package (scope)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants