Skip to content

Commit

Permalink
[LiquidDoc] Formatting support for implicit descriptions (#812)
Browse files Browse the repository at this point in the history
## What are you adding in this PR?
Closes Shopify/developer-tools-team#587

Mothing too complicated here. We just need to use the is implicit property to determine if we should append the `@description` annotation or not.

Indenting, etc should behave similarly to a normal description.

## Before you deploy
- [x] I included a patch bump `changeset`

_The ends result of this change is more of a bug fix from introducing a new node,so I chose to go with a patch._
  • Loading branch information
jamesmengo authored Feb 25, 2025
2 parents 55f615f + 357ea7f commit 6dcdfc3
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/proud-chefs-relate.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@shopify/prettier-plugin-liquid': patch
---

Prevent prettier from appending `@description` annotation before implicit descriptions
8 changes: 6 additions & 2 deletions packages/prettier-plugin-liquid/src/printer/print/liquid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -581,10 +581,14 @@ export function printLiquidDocDescription(
_args: LiquidPrinterArgs,
): Doc {
const node = path.getValue();
const parts: Doc[] = ['@description'];
const parts: Doc[] = [];

if (!node.isImplicit) {
parts.push('@description ');
}

if (node.content?.value) {
parts.push(' ', node.content.value);
parts.push(node.content.value);
}

return parts;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,10 @@ It should add padding between dissimilar nodes

@param {String} param3 - param with description
{% enddoc %}

It should not append an implicit description with an @description annotation
{% doc %}
This is an implicit description

@description This is an explicit description
{% enddoc %}
Original file line number Diff line number Diff line change
Expand Up @@ -118,3 +118,10 @@ It should add padding between dissimilar nodes
@description This is a description
@param {String} param3 - param with description
{% enddoc %}

It should not append an implicit description with an @description annotation
{% doc %}
This is an implicit description

@description This is an explicit description
{% enddoc %}

0 comments on commit 6dcdfc3

Please sign in to comment.