1 | "use strict";
|
2 |
|
3 |
|
4 | var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
5 | if (k2 === undefined) k2 = k;
|
6 | var desc = Object.getOwnPropertyDescriptor(m, k);
|
7 | if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
8 | desc = { enumerable: true, get: function() { return m[k]; } };
|
9 | }
|
10 | Object.defineProperty(o, k2, desc);
|
11 | }) : (function(o, m, k, k2) {
|
12 | if (k2 === undefined) k2 = k;
|
13 | o[k2] = m[k];
|
14 | }));
|
15 | var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
16 | Object.defineProperty(o, "default", { enumerable: true, value: v });
|
17 | }) : function(o, v) {
|
18 | o["default"] = v;
|
19 | });
|
20 | var __importStar = (this && this.__importStar) || function (mod) {
|
21 | if (mod && mod.__esModule) return mod;
|
22 | var result = {};
|
23 | if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
24 | __setModuleDefault(result, mod);
|
25 | return result;
|
26 | };
|
27 | Object.defineProperty(exports, "__esModule", { value: true });
|
28 | exports.GenerateAction = void 0;
|
29 | const path = __importStar(require("path"));
|
30 | const BaseAction_1 = require("./BaseAction");
|
31 | const DocumenterConfig_1 = require("../documenters/DocumenterConfig");
|
32 | const ExperimentalYamlDocumenter_1 = require("../documenters/ExperimentalYamlDocumenter");
|
33 | const node_core_library_1 = require("@rushstack/node-core-library");
|
34 | const MarkdownDocumenter_1 = require("../documenters/MarkdownDocumenter");
|
35 | class GenerateAction extends BaseAction_1.BaseAction {
|
36 | constructor(parser) {
|
37 | super({
|
38 | actionName: 'generate',
|
39 | summary: 'EXPERIMENTAL',
|
40 | documentation: 'EXPERIMENTAL - This action is a prototype of a new config file driven mode of operation for' +
|
41 | ' API Documenter. It is not ready for general usage yet. Its design may change in the future.'
|
42 | });
|
43 | }
|
44 | async onExecute() {
|
45 |
|
46 |
|
47 | let configFilePath = path.join(process.cwd(), DocumenterConfig_1.DocumenterConfig.FILENAME);
|
48 |
|
49 | if (!node_core_library_1.FileSystem.exists(configFilePath)) {
|
50 |
|
51 | configFilePath = path.join(process.cwd(), 'config', DocumenterConfig_1.DocumenterConfig.FILENAME);
|
52 | if (!node_core_library_1.FileSystem.exists(configFilePath)) {
|
53 | throw new Error(`Unable to find ${DocumenterConfig_1.DocumenterConfig.FILENAME} in the current folder or in a "config" subfolder`);
|
54 | }
|
55 | }
|
56 | const documenterConfig = DocumenterConfig_1.DocumenterConfig.loadFile(configFilePath);
|
57 | const { apiModel, outputFolder } = this.buildApiModel();
|
58 | if (documenterConfig.configFile.outputTarget === 'markdown') {
|
59 | const markdownDocumenter = new MarkdownDocumenter_1.MarkdownDocumenter({
|
60 | apiModel,
|
61 | documenterConfig,
|
62 | outputFolder
|
63 | });
|
64 | markdownDocumenter.generateFiles();
|
65 | }
|
66 | else {
|
67 | const yamlDocumenter = new ExperimentalYamlDocumenter_1.ExperimentalYamlDocumenter(apiModel, documenterConfig);
|
68 | yamlDocumenter.generateFiles(outputFolder);
|
69 | }
|
70 | }
|
71 | }
|
72 | exports.GenerateAction = GenerateAction;
|
73 |
|
\ | No newline at end of file |