feat(editor): Add missing documentation to autocomplete items for inline code editor (#5560)

*  Added documentation for extension functions with arguments

*  Adding custom autocomplete item types. This enables us to show different items with same labels.

* 📚 Adding missing info for extensions autocomplete items

*  Added Luxon autocomplete docs

* 💡 Completing Luxon static methods autocomplete documentation

*  Refactoring Luxon autocomplete logic

*  Handling the case when autocomplete item doesn't have defined inline documentation

*  Added correct doc info to Luxon instance properties

*  Added missing documentation and notice footer for autocomplete popup.

* 👕 Fixing lint error

* ✔️ Removing `Object.hasOwn` function, since it's not supported in node v14
This commit is contained in:
Milorad FIlipović
2023-02-28 05:34:03 +01:00
committed by GitHub
parent bb4db58819
commit ae634407a4
15 changed files with 1281 additions and 181 deletions

View File

@@ -206,56 +206,100 @@ function plus(date: Date | DateTime, extraArgs: unknown[]): Date | DateTime {
endOfMonth.doc = {
name: 'endOfMonth',
returnType: 'Date',
description: 'Transforms a date to the last possible moment that lies within the month',
description: 'Transforms a date to the last possible moment that lies within the month.',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-endOfMonth',
};
isDst.doc = {
name: 'isDst',
returnType: 'boolean',
description: 'Checks if a Date is within Daylight Savings Time',
description: 'Checks if a Date is within Daylight Savings Time.',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-isDst',
};
isWeekend.doc = {
name: 'isWeekend',
returnType: 'boolean',
description: 'Checks if the Date falls on a Saturday or Sunday',
description: 'Checks if the Date falls on a Saturday or Sunday.',
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-isWeekend',
};
// @TODO_NEXT_PHASE: Surface extensions below which take args
beginningOf.doc = {
name: 'beginningOf',
description: 'Transform a Date to the start of the given time period. Default unit is `week`.',
returnType: 'Date',
args: [{ name: 'unit?', type: 'DurationUnit' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-beginningOf',
};
extract.doc = {
name: 'extract',
description: 'Extracts the part defined in `datePart` from a Date. Default unit is `week`.',
returnType: 'number',
args: [{ name: 'datePart?', type: 'DurationUnit' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-extract',
};
format.doc = {
name: 'format',
returnType: '(?)',
description: 'Formats a Date in the given structure.',
returnType: 'string',
args: [{ name: 'fmt', type: 'TimeFormat' }],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-format',
};
isBetween.doc = {
name: 'isBetween',
description: 'Checks if a Date is between two given dates.',
returnType: 'boolean',
args: [
{ name: 'date1', type: 'Date|string' },
{ name: 'date2', type: 'Date|string' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-isBetween',
};
isInLast.doc = {
name: 'isInLast',
description: 'Checks if a Date is within a given time period. Default unit is `minute`.',
returnType: 'boolean',
args: [
{ name: 'n', type: 'number' },
{ name: 'unit?', type: 'DurationUnit' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-isInLast',
};
minus.doc = {
name: 'minus',
description: 'Subtracts a given time period from a Date. Default unit is `minute`.',
returnType: 'Date',
args: [
{ name: 'n', type: 'number' },
{ name: 'unit?', type: 'DurationUnit' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-minus',
};
plus.doc = {
name: 'plus',
description: 'Adds a given time period to a Date. Default unit is `minute`.',
returnType: 'Date',
args: [
{ name: 'n', type: 'number' },
{ name: 'unit?', type: 'DurationUnit' },
],
docURL:
'https://docs.n8n.io/code-examples/expressions/data-transformation-functions/dates/#date-plus',
};
export const dateExtensions: ExtensionMap = {