-
Notifications
You must be signed in to change notification settings - Fork 39
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
Example tag hover support #763
Conversation
e14c075
to
15b7590
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.
@@ -60,6 +60,14 @@ export class RenderSnippetHoverProvider implements BaseHoverProvider { | |||
parts.push('', '**Parameters:**', parameters); | |||
} | |||
|
|||
if (liquidDoc.examples?.length) { | |||
const examples = liquidDoc.examples | |||
?.map(({ content }) => `\`\`\`liquid\n${content.trimStart().trimEnd()}\n\`\`\``) |
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.
Not sure about this .trimStart().trimEnd()
- I get why you're doing it but seems clunky that we would have to worry about "examples" having extra spaces. Could we modify LiquidDocExampleNode
in liquidDoc.ts
so that we always trim the string for content. That way, we would never have to worry about it in the provider flow.
); | ||
LiquidDocExampleNode(node: LiquidDocExampleNode) { | ||
return { | ||
content: node.exampleContent.value, |
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.
Actually, we might have to be a bit smarter than just trimming the string. When we have an example written like the following, trimming the leading+trailing spaces will end up looking like the 2nd picture.
Instead, we should see how many space characters are leading the first line, then remove that many spaces for each line in the example. This also means that you need to update the prettier rule so that we allow format on save. What do you think?
cc: @jamesmengo
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.
Great thought. thanks @aswamy. I think I want to have a bigger chat surrounding how we format our prettier rules and what we want to get out of the example tags.
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.
If you want, you can separate multi-line example support and multi-line param support into another ticket. I assume they would encounter the same formatting issues.
@EvilGenius13 +1 to Alok's comment - though I agree we can follow up with that: Follow up with a change that:
I have an example here I'll document this in our decision log. |
16a33f9
to
3444477
Compare
3444477
to
d628ec8
Compare
What are you adding in this PR?
Closes: https://github.com/Shopify/developer-tools-team/issues/529
Add hover support for
@example
in liquid{% doc %}
tags.Along with
parameter
hover introduced in #703, we are adding support for examples.Example product card snippet:
Hovering over the render snippet will look like:

Before you deploy
changeset