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kB,CAAC;gBACpE,QAAQ;gBACR,gBAAgB;gBAChB,YAAY;aACb,CAAC,CAAC;YACH,kBAAkB,CAAC,aAAa,EAAE,CAAC;SACpC;aAAM;YACL,MAAM,cAAc,GAA+B,IAAI,uDAA0B,CAC/E,QAAQ,EACR,gBAAgB,CACjB,CAAC;YACF,cAAc,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;SAC5C;IACH,CAAC;CACF;AA/CD,wCA+CC","sourcesContent":["// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.\n// See LICENSE in the project root for license information.\n\nimport * as path from 'path';\n\nimport type { ApiDocumenterCommandLine } from './ApiDocumenterCommandLine';\nimport { BaseAction } from './BaseAction';\nimport { DocumenterConfig } from '../documenters/DocumenterConfig';\nimport { ExperimentalYamlDocumenter } from '../documenters/ExperimentalYamlDocumenter';\n\nimport { FileSystem } from '@rushstack/node-core-library';\nimport { MarkdownDocumenter } from '../documenters/MarkdownDocumenter';\n\nexport class GenerateAction extends BaseAction {\n public constructor(parser: ApiDocumenterCommandLine) {\n super({\n actionName: 'generate',\n summary: 'EXPERIMENTAL',\n documentation:\n 'EXPERIMENTAL - This action is a prototype of a new config file driven mode of operation for' +\n ' API Documenter. It is not ready for general usage yet. Its design may change in the future.'\n });\n }\n\n protected async onExecute(): Promise<void> {\n // override\n // Look for the config file under the current folder\n\n let configFilePath: string = path.join(process.cwd(), DocumenterConfig.FILENAME);\n\n // First try the current folder\n if (!FileSystem.exists(configFilePath)) {\n // Otherwise try the standard \"config\" subfolder\n configFilePath = path.join(process.cwd(), 'config', DocumenterConfig.FILENAME);\n if (!FileSystem.exists(configFilePath)) {\n throw new Error(\n `Unable to find ${DocumenterConfig.FILENAME} in the current folder or in a \"config\" subfolder`\n );\n }\n }\n\n const documenterConfig: DocumenterConfig = DocumenterConfig.loadFile(configFilePath);\n\n const { apiModel, outputFolder } = this.buildApiModel();\n\n if (documenterConfig.configFile.outputTarget === 'markdown') {\n const markdownDocumenter: MarkdownDocumenter = new MarkdownDocumenter({\n apiModel,\n documenterConfig,\n outputFolder\n });\n markdownDocumenter.generateFiles();\n } else {\n const yamlDocumenter: ExperimentalYamlDocumenter = new ExperimentalYamlDocumenter(\n apiModel,\n documenterConfig\n );\n yamlDocumenter.generateFiles(outputFolder);\n }\n }\n}\n"]}
\No newline at end of file