UNPKG

pakt-api

Version:

This is a API HTML Documentation Generator

59 lines (58 loc) 2.65 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); const server_1 = require("react-dom/server"); const Index_1 = __importDefault(require("./pages/Index")); const fs_1 = require("fs"); const path_1 = __importDefault(require("path")); const StyleManager_1 = require("./styles/StyleManager"); __exportStar(require("./types/_types"), exports); class default_1 { buildPath; fileName; constructor(buildPath, fileName = "/documentation.html") { this.buildPath = buildPath; this.fileName = fileName; } generate(config) { const content = (0, server_1.renderToStaticMarkup)((0, Index_1.default)(config)); const script = (0, fs_1.readFileSync)(path_1.default.resolve(__dirname + '/utils/index.js')); const filePath = this.buildPath + this.fileName; if (!(0, fs_1.existsSync)(this.buildPath)) (0, fs_1.mkdirSync)(this.buildPath); (0, fs_1.writeFileSync)(filePath, `<!DOCTYPE html> <html lang="fr"> <head> <meta name="viewport" content="width=device-width, initial-scale=1" /> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@1.0.2/css/bulma.min.css" /> <link href="https://fonts.googleapis.com/css2?family=Ruda:wght@400..900&family=Source+Code+Pro:ital,wght@0,200..900;1,200..900&display=swap" rel="stylesheet" ></link> <script>${script}</script> </head> <body styles="font-family: Ruda" class="m-6"> ${content} <style>${StyleManager_1.StyleManager.instance.toString()}</style> </body> </html> `); } } exports.default = default_1;