Skip to content

Commit

Permalink
Improve navigation for extensions in the documentation (#5950)
Browse files Browse the repository at this point in the history
  • Loading branch information
4ian authored Nov 24, 2023
1 parent 5abc74b commit d34f1a6
Showing 1 changed file with 45 additions and 4 deletions.
49 changes: 45 additions & 4 deletions newIDE/app/scripts/extract-extensions-document.js
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,41 @@ const generateAllExtensionsSections = extensions => {
return extensionSectionsContent;
};

/**
* @param {Array<any>} extensions The extension (gdEventsFunctionsExtension)
*/
const generateExtensionsMkDocsDotPagesFile = async (extensions) => {
const extensionsByCategory = sortKeys(
groupBy(extensions, pair => pair.getCategory() || 'General')
);

let pagesList = '';
for (const category in extensionsByCategory) {
pagesList += ` - ${category}:\n`;

const extensions = extensionsByCategory[category];
for (const extension of extensions) {
const folderName = getExtensionFolderName(extension.getName());
pagesList += ` - ${extension.getFullName()}: ${folderName}\n`;
}
}

const dotPagesContent = `nav:
- index.md
- search.md
- tiers.md
- Create your own extensions:
- Create a new extension : create.md
- best-practices.md
- share-extension.md
${pagesList} - ...
`;

const extensionsDotPagesFilePath = path.join(extensionsRootPath, '.pages');
await fs.writeFile(extensionsDotPagesFilePath, dotPagesContent);
console.info(`ℹ️ File generated: ${extensionsDotPagesFilePath}`);
};

const generateExtensionsList = async gd => {
let content = `## Extensions list
Expand All @@ -400,11 +435,11 @@ Here are listed all the extensions available in GDevelop. The list is divided in
header => header.tier === 'community'
);

const reviewedExtensions = reviewedExtensionShortHeaders.map(
header => project.getEventsFunctionsExtension(header.name)
const reviewedExtensions = reviewedExtensionShortHeaders.map(header =>
project.getEventsFunctionsExtension(header.name)
);
const communityExtensions = communityExtensionShortHeaders.map(
header => project.getEventsFunctionsExtension(header.name)
const communityExtensions = communityExtensionShortHeaders.map(header =>
project.getEventsFunctionsExtension(header.name)
);

content += '## Reviewed extensions\n\n';
Expand Down Expand Up @@ -454,6 +489,12 @@ does or inspect its content before using it.
);
}
content += generateAllExtensionsSections(communityExtensions);

await generateExtensionsMkDocsDotPagesFile([
...reviewedExtensions,
...communityExtensions,
]);

project.delete();
return content;
};
Expand Down

0 comments on commit d34f1a6

Please sign in to comment.