UNPKG

@appium/typedoc-plugin-appium

Version:

TypeDoc plugin for Appium & its extensions

63 lines 2.36 kB
"use strict"; /** * Handlebars template & partial helpers * @module */ var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.compileTemplate = exports.AppiumThemeTemplate = void 0; const handlebars_1 = __importDefault(require("handlebars")); const lodash_1 = __importDefault(require("lodash")); const node_fs_1 = __importDefault(require("node:fs")); const node_path_1 = __importDefault(require("node:path")); /** * Path to resources directory, containing all templates and partials. */ const RESOURCES_PATH = node_path_1.default.join(__dirname, 'resources'); /** * Path to templates directory within {@linkcode RESOURCES_PATH} */ const TEMPLATE_PATH = node_path_1.default.join(RESOURCES_PATH, 'templates'); /** * Path to partials directory within {@linkcode RESOURCES_PATH} */ const PARTIALS_PATH = node_path_1.default.join(RESOURCES_PATH, 'partials'); /** * Enum of all available partials */ var AppiumThemePartial; (function (AppiumThemePartial) { AppiumThemePartial["command"] = "command.hbs"; AppiumThemePartial["executeMethod"] = "execute-method.hbs"; })(AppiumThemePartial || (AppiumThemePartial = {})); /** * Enum of all available templates */ var AppiumThemeTemplate; (function (AppiumThemeTemplate) { /** * Template to render a list of commands */ AppiumThemeTemplate["Extension"] = "extension.hbs"; })(AppiumThemeTemplate = exports.AppiumThemeTemplate || (exports.AppiumThemeTemplate = {})); /** * Registers all partials found in {@linkcode PARTIALS_PATH} with {@linkcode Handlebars}. * * This is executed immediately upon loading this module. */ function registerPartials() { for (const [name, filename] of Object.entries(AppiumThemePartial)) { handlebars_1.default.registerPartial(name, node_fs_1.default.readFileSync(node_path_1.default.join(PARTIALS_PATH, filename), 'utf8')); } } registerPartials(); /** * Compiles a {@linkcode AppiumThemeTemplate}. */ exports.compileTemplate = lodash_1.default.memoize((template) => { const templatePath = node_path_1.default.join(TEMPLATE_PATH, template); return handlebars_1.default.compile(node_fs_1.default.readFileSync(templatePath, 'utf8')); }); //# sourceMappingURL=template.js.map