Skip to content

Commit 16a33f9

Browse files
committed
rebase with main
1 parent e3ba41d commit 16a33f9

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

packages/theme-language-server-common/src/hover/providers/RenderSnippetHoverProvider.spec.ts

+8-1
Original file line numberDiff line numberDiff line change
@@ -17,30 +17,35 @@ describe('Module: RenderSnippetHoverProvider', async () => {
1717
description: 'The title of the product',
1818
type: 'string',
1919
required: true,
20+
nodeType: 'param',
2021
},
2122
{
2223
name: 'border-radius',
2324
description: 'The border radius in px',
2425
type: 'number',
2526
required: false,
27+
nodeType: 'param',
2628
},
2729
{
2830
name: 'no-type',
2931
description: 'This parameter has no type',
3032
type: null,
3133
required: true,
34+
nodeType: 'param',
3235
},
3336
{
3437
name: 'no-description',
3538
description: null,
3639
type: 'string',
3740
required: true,
41+
nodeType: 'param',
3842
},
3943
{
4044
name: 'no-type-or-description',
4145
description: null,
4246
type: null,
4347
required: true,
48+
nodeType: 'param',
4449
},
4550
],
4651
examples: [
@@ -61,7 +66,7 @@ describe('Module: RenderSnippetHoverProvider', async () => {
6166
provider = createProvider(async () => mockSnippetDefinition);
6267
await expect(provider).to.hover(
6368
`{% render 'product-car█d' %}`,
64-
'### product-card\n\n**Parameters:**\n- `title`: string - The title of the product\n- `border-radius` (Optional): number - The border radius in px\n- `no-type` - This parameter has no type\n- `no-description`: string\n- `no-type-or-description`\n\n**Examples:**\n\`\`\`liquid\n{{ product }}\n\`\`\`',
69+
'### product-card\n\n**Parameters:**\n- `title`: string - The title of the product\n- `border-radius` (Optional): number - The border radius in px\n- `no-type` - This parameter has no type\n- `no-description`: string\n- `no-type-or-description`\n\n**Examples:**\n```liquid{{ product }}```\n```liquid{{ product.title }}```',
6570
);
6671
});
6772

@@ -92,12 +97,14 @@ describe('Module: RenderSnippetHoverProvider', async () => {
9297
description: 'The title of the product',
9398
type: 'string',
9499
required: true,
100+
nodeType: 'param',
95101
},
96102
{
97103
name: 'border-radius',
98104
description: 'The border radius in px',
99105
type: 'number',
100106
required: false,
107+
nodeType: 'param',
101108
},
102109
],
103110
},

packages/theme-language-server-common/src/liquidDoc.spec.ts

+7
Original file line numberDiff line numberDiff line change
@@ -49,36 +49,42 @@ describe('Unit: getSnippetDefinition', () => {
4949
description: 'The first param',
5050
type: 'String',
5151
required: true,
52+
nodeType: 'param',
5253
},
5354
{
5455
name: 'secondParam',
5556
description: 'The second param',
5657
type: 'Number',
5758
required: true,
59+
nodeType: 'param',
5860
},
5961
{
6062
name: 'optionalParam',
6163
description: 'The optional param',
6264
type: 'String',
6365
required: false,
66+
nodeType: 'param',
6467
},
6568
{
6669
name: 'paramWithNoType',
6770
description: 'param with no type',
6871
type: null,
6972
required: true,
73+
nodeType: 'param',
7074
},
7175
{
7276
name: 'paramWithOnlyName',
7377
description: null,
7478
type: null,
7579
required: true,
80+
nodeType: 'param',
7681
},
7782
{
7883
name: 'paramWithNoDescription',
7984
description: null,
8085
type: 'Number',
8186
required: true,
87+
nodeType: 'param',
8288
},
8389
],
8490
examples: [],
@@ -151,6 +157,7 @@ describe('Unit: getSnippetDefinition', () => {
151157
name: 'product',
152158
description: 'The product',
153159
type: 'String',
160+
required: true,
154161
nodeType: 'param',
155162
},
156163
],

packages/theme-language-server-common/src/liquidDoc.ts

+14-13
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export type SnippetDefinition = {
1616

1717
type LiquidDocDefinition = {
1818
parameters?: LiquidDocParameter[];
19-
examples?: LiquidDocExample[]; // I don't think we need an array but maybe we'll allow multiple examples
19+
examples?: LiquidDocExample[];
2020
};
2121

2222
interface LiquidDocNode {
@@ -28,7 +28,7 @@ export interface LiquidDocParameter extends LiquidDocNode {
2828
description: string | null;
2929
type: string | null;
3030
required: boolean;
31-
};
31+
}
3232

3333
export interface LiquidDocExample extends LiquidDocNode {
3434
content: string;
@@ -39,17 +39,18 @@ export function getSnippetDefinition(
3939
snippet: LiquidHtmlNode,
4040
snippetName: string,
4141
): SnippetDefinition {
42-
const parameters: LiquidDocParameter[] = visit<SourceCodeType.LiquidHtml, LiquidDocParameter>(
43-
snippet,
44-
{
45-
LiquidDocParamNode(node: LiquidDocParamNode) {
46-
return {
47-
name: node.paramName.value,
48-
description: node.paramDescription?.value ?? null,
49-
type: node.paramType?.value ?? null,
50-
required: node.required,
51-
};
52-
},
42+
const nodes: (LiquidDocParameter | LiquidDocExample)[] = visit<
43+
SourceCodeType.LiquidHtml,
44+
LiquidDocParameter | LiquidDocExample
45+
>(snippet, {
46+
LiquidDocParamNode(node: LiquidDocParamNode) {
47+
return {
48+
name: node.paramName.value,
49+
description: node.paramDescription?.value ?? null,
50+
type: node.paramType?.value ?? null,
51+
required: node.required,
52+
nodeType: 'param',
53+
};
5354
},
5455
LiquidDocExampleNode(node: LiquidDocExampleNode) {
5556
return {

0 commit comments

Comments
 (0)