-
Notifications
You must be signed in to change notification settings - Fork 31
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 parsing and prettier support for @example tags in liquid doc #725
Conversation
LGTM and 🎩 went well, thanks! We can write those tests in a follow-up. |
c1b702f
to
c24909d
Compare
@@ -765,6 +766,14 @@ export interface LiquidDocParamNode extends ASTNode<NodeTypes.LiquidDocParamNode | |||
/** Optional type annotation for the parameter (e.g. "{string}", "{number}") */ | |||
paramType: TextNode | null; | |||
} | |||
|
|||
/** Represents a `@example` node in a LiquidDoc comment - `@example @exampleContent` */ |
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.
/** Represents a `@example` node in a LiquidDoc comment - `@example @exampleContent` */ | |
/** Represents a `@example` node in a LiquidDoc comment - `@example exampleContent` */ |
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.
Fixed in #759
exampleContent: { | ||
type: NodeTypes.TextNode, | ||
value: node.exampleContent.value, | ||
position: position(node.exampleContent), | ||
source: node.exampleContent.source, | ||
}, |
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.
exampleContent: { | |
type: NodeTypes.TextNode, | |
value: node.exampleContent.value, | |
position: position(node.exampleContent), | |
source: node.exampleContent.source, | |
}, | |
exampleContent: toTextNode(node.exampleContent), |
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.
Could you also fix this for paramNode
? A follow-up PR is fine too :)
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.
Fixed in #759
Left out paramNode
as it's currently being refactored in another PR
|
||
if (node.exampleContent?.value) { | ||
const content = node.exampleContent.value; | ||
if (content) { |
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 (node.exampleContent?.value) { | |
const content = node.exampleContent.value; | |
if (content) { | |
const content = node.exampleContent?.value | |
if (content) { | |
.... | |
} |
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.
Fixed in #759
It should respect example content with param and description | ||
{% doc %} | ||
@param paramName - param with description | ||
@example |
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.
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.
Agreed. This will be tackled in a separate PR as there is some other prettier logic that will need refactoring as well.
Thanks for the changes! The only blocking comment I have is around this, let me know your thoughts! |
What are you adding in this PR?
References: https://github.com/Shopify/develop-advanced-edits/issues/471
Added support for parsing and formatting
@example
tags withinLiquidDoc
blocks.Feedback
Right now, we aren't controlling whitespace for example tags. If someone wants to write
check out. my great example
, it would stay in that format. Should trim whitespace or allow people writing examples to have full control?What's next? Any followup issues?
I want to add prettier support to automatically move
@example
tags and content below@param
as it is the proper flow.What did you learn?
AST's and CST's are quite puzzle to figure out.
Test
Example.tag.prettier.support.mp4
Before you deploy
changeset