-
Notifications
You must be signed in to change notification settings - Fork 29
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
[LiquidDoc] Add snippet hover support inside of {% render %} tag #703
Conversation
This stack of pull requests is managed by Graphite. Learn more about stacking. |
11023d6
to
c7b2d3b
Compare
9251a0f
to
d10e268
Compare
c7b2d3b
to
38316c6
Compare
d10e268
to
4e69c7c
Compare
38316c6
to
a58b45c
Compare
c132c46
to
915e388
Compare
6ce56e3
to
3b20751
Compare
packages/theme-language-server-common/src/server/startServer.ts
Outdated
Show resolved
Hide resolved
3b20751
to
e1c6500
Compare
3c9cefa
to
6ab6856
Compare
b6ca8f0
to
35d1735
Compare
3afb318
to
a167761
Compare
'@shopify/theme-check-common': minor | ||
--- | ||
|
||
Cache liquidDoc fetch results |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this comes from the upstream PR I merged in
|
||
import { LiquidDocParamNode } from '@shopify/liquid-html-parser'; | ||
|
||
export type GetSnippetDefinitionForURI = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm placing the types within its own module since this follows the pattern we're using for translations - link
This keeps everything self-contained while it's still subject to change as we continue building functionality into theme check, etc.
packages/theme-language-server-common/src/hover/providers/RenderSnippetHoverProvider.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
packages/theme-language-server-common/src/hover/providers/RenderSnippetHoverProvider.ts
Outdated
Show resolved
Hide resolved
packages/theme-language-server-common/src/hover/providers/RenderSnippetHoverProvider.ts
Outdated
Show resolved
Hide resolved
packages/theme-language-server-common/src/hover/providers/RenderSnippetHoverProvider.ts
Outdated
Show resolved
Hide resolved
packages/theme-language-server-common/src/hover/providers/RenderSnippetHoverProvider.ts
Outdated
Show resolved
Hide resolved
ef399e2
to
681ba72
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for this PR, @jamesmengo! Great stuff 🎩
I've left only two minor comments that I'd love to know your thoughts :)
packages/theme-language-server-common/src/hover/providers/RenderSnippetHoverProvider.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: string | null; | ||
type: string | null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: string | null; | |
type: string | null; | |
description?: string; | |
type?: string; |
description: node.paramDescription?.value ?? null, | ||
type: node.paramType?.value ?? null, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
description: node.paramDescription?.value ?? null, | |
type: node.paramType?.value ?? null, | |
description: node.paramDescription?.value, | |
type: node.paramType?.value, |
@param {String} firstParam - The first param | ||
@param {Number} secondParam - The second param | ||
@param paramWithNoType - param with no type | ||
@param paramWithOnlyName |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parameters: [ | ||
{ | ||
name: 'title', | ||
description: 'The title of the product', | ||
type: 'string', | ||
}, | ||
{ | ||
name: 'border-radius', | ||
description: 'The border radius in px', | ||
type: 'number', | ||
}, | ||
], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You should add more iterations of parameters (e.g. without description, type, etc) since you have logic behind the templating around them.
See review comment above for the ones I've done during tophatting.
…wn module ---- We didn't need to use the make pattern at least at this stage, so I'm removing the code in ThemeCheckCommon and placing it in its own module. We may need to revisit this when we are writing theme checks. However, for the purpose of hover, this is where the code should live.
…clarity - Renamed `GetLiquidDocDefinitionsForURI` to `GetSnippetDefinitionForURI` - Introduced `SnippetDefinition` type to replace `LiquidDocDefinition`, enhancing type specificity.
681ba72
to
52bf118
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, @jamesmengo! LGTM and works as expected as well 🎩 :)
What are you adding in this PR?
https://github.com/Shopify/develop-advanced-edits/issues/496
1) Hover support for Liquid snippets inside of a
{% render %}
tag. Users will now see:documented)
If there is no
{% doc %}
present in the snippet, we will just render the snippet name2) Caching for fetching LiquidDoc definitions
Example snippet documentation:
When hovering over
product-card
in{% render 'product-card' %}
, users will see:Uploading Cursor - liquidDoc.ts — theme-tools.mp4…
Hovering a snippet with docs
Hovering a snippet without liquiddoc
What's next? Any followup issues?
What did you learn?
This is my first time working with the hover API in VS code. Pretty cool to read up on!
Before you deploy
changeset