Skip to content

Commit 5c6ba5b

Browse files
committed
Add missing functions and fix descriptions
1 parent 16b9218 commit 5c6ba5b

File tree

1 file changed

+64
-7
lines changed

1 file changed

+64
-7
lines changed

scripts/generate-extensions-registry.js

Lines changed: 64 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -137,15 +137,52 @@ const findAllRequiredBehaviorTypes = (
137137
};
138138

139139
/**
140+
* @param {EventsFunction[]} eventFunctions
140141
* @param {EventsFunction} eventFunction
141142
* @returns {EventsFunctionInsideExtensionShortHeader}
142143
*/
143-
const formatEventFunctionInsideExtensionShortHeader = (eventFunction) => {
144+
const formatEventFunctionInsideExtensionShortHeader = (
145+
eventFunctions,
146+
eventFunction
147+
) => {
148+
if (eventFunction.functionType === 'ActionWithOperator') {
149+
const getterFunction = eventFunctions.find(
150+
(otherEventsFunction) =>
151+
otherEventsFunction.name === eventFunction.getterName
152+
);
153+
154+
if (getterFunction) {
155+
return {
156+
name: eventFunction.name,
157+
fullName: getterFunction.fullName,
158+
description:
159+
'Change ' + (getterFunction.description || getterFunction.fullName),
160+
functionType: 'Action',
161+
};
162+
} else {
163+
return {
164+
name: eventFunction.name,
165+
fullName: eventFunction.fullName,
166+
description: 'Change ' + eventFunction.description,
167+
functionType: 'Action',
168+
};
169+
}
170+
}
171+
172+
if (eventFunction.functionType === 'ExpressionAndCondition') {
173+
return {
174+
name: eventFunction.name,
175+
fullName: eventFunction.fullName,
176+
description: 'Compare ' + eventFunction.description,
177+
functionType: 'Condition',
178+
};
179+
}
180+
144181
return {
145-
description: eventFunction.description,
182+
name: eventFunction.name,
146183
fullName: eventFunction.fullName,
184+
description: eventFunction.description,
147185
functionType: eventFunction.functionType,
148-
name: eventFunction.name,
149186
};
150187
};
151188

@@ -163,7 +200,12 @@ const formatEventsBasedBehaviorInsideExtensionShortHeader = (
163200
objectType: eventsBasedBehavior.objectType,
164201
eventsFunctions: filterEventsFunctions(
165202
eventsBasedBehavior.eventsFunctions
166-
).map(formatEventFunctionInsideExtensionShortHeader),
203+
).map((eventsFunction) =>
204+
formatEventFunctionInsideExtensionShortHeader(
205+
eventsBasedBehavior.eventsFunctions,
206+
eventsFunction
207+
)
208+
),
167209
};
168210
};
169211

@@ -181,7 +223,12 @@ const formatEventsBasedObjectInsideExtensionShortHeader = (
181223
defaultName: eventsBasedObject.defaultName,
182224
eventsFunctions: filterEventsFunctions(
183225
eventsBasedObject.eventsFunctions
184-
).map(formatEventFunctionInsideExtensionShortHeader),
226+
).map((eventsFunction) =>
227+
formatEventFunctionInsideExtensionShortHeader(
228+
eventsBasedObject.eventsFunctions,
229+
eventsFunction
230+
)
231+
),
185232
};
186233
};
187234

@@ -196,7 +243,13 @@ const filterEventsBasedObjects = (objects) =>
196243
/** @param {Array<EventsFunction>} eventsFunctions */
197244
const filterEventsFunctions = (eventsFunctions) =>
198245
eventsFunctions.filter(
199-
(eventFunction) => eventFunction.fullName && !eventFunction.private
246+
(eventFunction) =>
247+
// Lifecycle functions, which have no full names, are never shown.
248+
// ActionWithOperator have no full name but will read it from their associated getter.
249+
(eventFunction.fullName ||
250+
eventFunction.functionType === 'ActionWithOperator') &&
251+
// Private functions are never shown.
252+
!eventFunction.private
200253
);
201254

202255
(async () => {
@@ -331,7 +384,11 @@ const filterEventsFunctions = (eventsFunctions) =>
331384
formatEventsBasedBehaviorInsideExtensionShortHeader
332385
);
333386
extensionShortHeader.eventsFunctions = eventsFunctions.map(
334-
formatEventFunctionInsideExtensionShortHeader
387+
(eventsFunction) =>
388+
formatEventFunctionInsideExtensionShortHeader(
389+
extension.eventsFunctions,
390+
eventsFunction
391+
)
335392
);
336393
extensionShortHeader.eventsBasedObjects = eventsBasedObjects.map(
337394
formatEventsBasedObjectInsideExtensionShortHeader

0 commit comments

Comments
 (0)