Skip to content

Commit 6dcdfc3

Browse files
authored
[LiquidDoc] Formatting support for implicit descriptions (#812)
## 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._
2 parents 55f615f + 357ea7f commit 6dcdfc3

File tree

4 files changed

+25
-2
lines changed

4 files changed

+25
-2
lines changed

.changeset/proud-chefs-relate.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/prettier-plugin-liquid': patch
3+
---
4+
5+
Prevent prettier from appending `@description` annotation before implicit descriptions

packages/prettier-plugin-liquid/src/printer/print/liquid.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,10 +581,14 @@ export function printLiquidDocDescription(
581581
_args: LiquidPrinterArgs,
582582
): Doc {
583583
const node = path.getValue();
584-
const parts: Doc[] = ['@description'];
584+
const parts: Doc[] = [];
585+
586+
if (!node.isImplicit) {
587+
parts.push('@description ');
588+
}
585589

586590
if (node.content?.value) {
587-
parts.push(' ', node.content.value);
591+
parts.push(node.content.value);
588592
}
589593

590594
return parts;

packages/prettier-plugin-liquid/src/test/liquid-doc/fixed.liquid

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,3 +124,10 @@ It should add padding between dissimilar nodes
124124
125125
@param {String} param3 - param with description
126126
{% enddoc %}
127+
128+
It should not append an implicit description with an @description annotation
129+
{% doc %}
130+
This is an implicit description
131+
132+
@description This is an explicit description
133+
{% enddoc %}

packages/prettier-plugin-liquid/src/test/liquid-doc/index.liquid

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,3 +118,10 @@ It should add padding between dissimilar nodes
118118
@description This is a description
119119
@param {String} param3 - param with description
120120
{% enddoc %}
121+
122+
It should not append an implicit description with an @description annotation
123+
{% doc %}
124+
This is an implicit description
125+
126+
@description This is an explicit description
127+
{% enddoc %}

0 commit comments

Comments
 (0)