Replaced pug-based help page generator with markdown generator
This commit is contained in:
parent
1a1f21628b
commit
eb6aae1227
3 changed files with 34 additions and 454 deletions
|
@ -1,40 +1,55 @@
|
|||
const pug = require("pug");
|
||||
const collections = require("./collections.js");
|
||||
const logger = require("./logger.js");
|
||||
const fs = require("fs");
|
||||
const template = `# <img src="https://raw.githubusercontent.com/TheEssem/esmBot/master/esmbot.png" width="64"> esmBot${process.env.NODE_ENV === "development" ? " Dev" : ""} Command List
|
||||
${process.env.NODE_ENV === "development" ? "\n**You are currently using esmBot Dev! Things may change at any time without warning and there will be bugs. Many bugs. If you find one, [report it here](https://github.com/TheEssem/esmBot/issues) or in the esmBot Support server.**\n" : ""}
|
||||
\`[]\` means an argument is required, \`{}\` means an argument is optional.
|
||||
|
||||
Default prefix is \`&\`.
|
||||
|
||||
> Tip: Use Ctrl+F to find the command you want!
|
||||
|
||||
## Table of Contents
|
||||
+ [**General**](#💻-general)
|
||||
+ [**Moderation**](#🔨-moderation)
|
||||
+ [**Tags**](#🏷️-tags)
|
||||
+ [**Fun**](#👌-fun)
|
||||
+ [**Image Editing**](#🖼️-image-editing)
|
||||
+ [**Soundboard**](#🔊-soundboard)
|
||||
`;
|
||||
|
||||
module.exports = async (output) => {
|
||||
const commands = Array.from(collections.commands.keys());
|
||||
const categories = {
|
||||
general: [],
|
||||
moderation: [],
|
||||
tags: [],
|
||||
fun: [],
|
||||
images: [],
|
||||
soundboard: []
|
||||
general: ["## 💻 General"],
|
||||
moderation: ["## 🔨 Moderation"],
|
||||
tags: ["## 🏷️ Tags"],
|
||||
fun: ["## 👌 Fun"],
|
||||
images: ["## 🖼️ Image Editing", "> These commands support the PNG, JPEG, and WEBP formats."],
|
||||
soundboard: ["## 🔊 Soundboard"]
|
||||
};
|
||||
for (const command of commands) {
|
||||
const category = collections.info.get(command).category;
|
||||
const description = collections.info.get(command).description;
|
||||
const params = collections.info.get(command).params;
|
||||
if (category === 1) {
|
||||
categories.general.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
||||
categories.general.push(`+ **${command}**${params ? ` ${params}` : ""} - ${description}`);
|
||||
} else if (category === 2) {
|
||||
categories.moderation.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
||||
categories.moderation.push(`+ **${command}**${params ? ` ${params}` : ""} - ${description}`);
|
||||
} else if (category === 3) {
|
||||
const subCommands = Array.from(Object.keys(description));
|
||||
for (const subCommand of subCommands) {
|
||||
categories.tags.push(`<strong>tags${subCommand !== "default" ? ` ${subCommand}` : ""}</strong>${params[subCommand] ? ` ${params[subCommand]}` : ""} - ${description[subCommand]}`);
|
||||
categories.tags.push(`+ **tags${subCommand !== "default" ? ` ${subCommand}` : ""}**${params[subCommand] ? ` ${params[subCommand]}` : ""} - ${description[subCommand]}`);
|
||||
}
|
||||
} else if (category === 4) {
|
||||
categories.fun.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
||||
categories.fun.push(`+ **${command}**${params ? ` ${params}` : ""} - ${description}`);
|
||||
} else if (category === 5) {
|
||||
categories.images.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
||||
categories.images.push(`+ **${command}**${params ? ` ${params}` : ""} - ${description}`);
|
||||
} else if (category === 6) {
|
||||
categories.soundboard.push(`<strong>${command}</strong>${params ? ` ${params}` : ""} - ${description}`);
|
||||
categories.soundboard.push(`+ **${command}**${params ? ` ${params}` : ""} - ${description}`);
|
||||
}
|
||||
}
|
||||
fs.writeFile(output, pug.renderFile("./assets/pages/help.pug", { commands: categories, dev: process.env.NODE_ENV === "development" ? true : false }), () => {
|
||||
fs.writeFile(output, `${template}\n${categories.general.join("\n")}\n\n${categories.moderation.join("\n")}\n\n${categories.tags.join("\n")}\n\n${categories.fun.join("\n")}\n\n${categories.images.join("\n")}\n\n${categories.soundboard.join("\n")}`, () => {
|
||||
logger.log("The help docs have been generated.");
|
||||
});
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue