Skip to content

Commit 626ee72

Browse files
committed
Set help path to reference page for extensions having no dedicated help page
1 parent 2054e97 commit 626ee72

File tree

2 files changed

+45
-1
lines changed

2 files changed

+45
-1
lines changed

scripts/generate-extensions-registry.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ const {
55
validateExtension,
66
validateNoDuplicates,
77
} = require('./lib/ExtensionValidator');
8+
const { getExtensionReferencePagePath } = require('./lib/WikiHelpLink');
89
const args = require('minimist')(process.argv.slice(2));
910

1011
/** @typedef {import('./types').ExtensionShortHeader} ExtensionShortHeader */
@@ -322,7 +323,7 @@ const filterEventsFunctions = (eventsFunctions) =>
322323
name,
323324
eventsBasedBehaviorsCount: eventsBasedBehaviors.length,
324325
eventsFunctionsCount: eventsFunctions.length,
325-
helpPath: extension.helpPath,
326+
helpPath: extension.helpPath || getExtensionReferencePagePath(name),
326327
};
327328

328329
if (tier === 'reviewed') {

scripts/lib/WikiHelpLink.js

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
// @ts-check
2+
3+
/** @param {string} str */
4+
const toKebabCase = (str) => {
5+
return str
6+
.replace(/([a-z])([A-Z])/g, '$1-$2') // get all lowercase letters that are near to uppercase ones
7+
.replace(/[\s_]+/g, '-') // replace all spaces and low dash
8+
.toLowerCase(); // convert to lower case
9+
};
10+
11+
/** @type {Record<string, string>} */
12+
const renamedExtensionNames = {
13+
AdMob: 'Admob',
14+
BuiltinFile: 'Storage',
15+
FileSystem: 'Filesystem',
16+
TileMap: 'Tilemap',
17+
BuiltinMouse: 'MouseTouch',
18+
};
19+
20+
/**
21+
* @param {string} extensionName
22+
* @returns {string}
23+
*/
24+
const getExtensionFolderName = (extensionName) => {
25+
return toKebabCase(
26+
renamedExtensionNames[extensionName] ||
27+
extensionName.replace(/^Builtin/, '')
28+
);
29+
};
30+
31+
/**
32+
* @param {string} extensionName
33+
* @returns {string}
34+
*/
35+
const getExtensionReferencePagePath = (extensionName) => {
36+
const folderName = getExtensionFolderName(extensionName);
37+
const referencePagePath = `/extensions/${folderName}`;
38+
return referencePagePath;
39+
};
40+
41+
module.exports = {
42+
getExtensionReferencePagePath,
43+
};

0 commit comments

Comments
 (0)