UNPKG

vue-docgen-cli

Version:

Generate documentation markdown files from VueJs components using the vue-docgen-api.

90 lines 4.1 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 __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.defineConfig = exports.extractConfig = exports.defaultTemplates = void 0; const path = __importStar(require("path")); const singleMd_1 = __importDefault(require("./singleMd")); const multiMd_1 = __importDefault(require("./multiMd")); const extractConfig_1 = __importDefault(require("./extractConfig")); exports.extractConfig = extractConfig_1.default; const getSources_1 = __importDefault(require("./getSources")); const compileTemplates_1 = require("./compileTemplates"); /** * expose default rendering templates so they can be enriched */ exports.defaultTemplates = { header: compileTemplates_1.header, events: compileTemplates_1.events, methods: compileTemplates_1.methods, slots: compileTemplates_1.slots, props: compileTemplates_1.props, component: compileTemplates_1.component, expose: compileTemplates_1.expose, defaultExample: compileTemplates_1.defaultExample, functionalTag: compileTemplates_1.functionalTag, renderTags: compileTemplates_1.renderTags, mdclean: compileTemplates_1.mdclean }; function hasComponents(config) { return !!config.components; } exports.default = async (config) => { // if at a level that has no components (top level) just give up if (!hasComponents(config)) { return; } // if componentsRoot is not specified we start with current cwd config.componentsRoot = path.resolve(config.cwd, config.componentsRoot); // outdir can be specified as relative to cwd so absolutize it config.outDir = path.resolve(config.cwd, config.outDir); // outfile needs to be absolutized too. relative the outDir will allow us to // specify the root dir of docs no top of pages and build the path as we go // avoiding to repeat the start path config.outFile = config.outFile ? path.resolve(config.outDir, config.outFile) : undefined; // set the default sorting of components to be alphabetical by filepath config.sortComponents = config.sortComponents || ((a, b) => a.filePath.localeCompare(b.filePath)); // then create the watcher if necessary const { watcher, componentFiles, docMap } = await (0, getSources_1.default)(config.components, config.ignore ? (Array.isArray(config.ignore) ? config.ignore : [config.ignore]) : [], config.componentsRoot, config.getDocFileName, config.propsParser, config.apiOptions); if (config.outFile) { // create one combined documentation file await (0, singleMd_1.default)(componentFiles, watcher, config, docMap); } else { // create one documentation file per component await (0, multiMd_1.default)(componentFiles, watcher, config, docMap); } if (!config.watch) { watcher.close(); } }; function defineConfig(config) { return config; } exports.defineConfig = defineConfig; //# sourceMappingURL=docgen.js.map