UNPKG

@microsoft/api-documenter

Version:

Read JSON files from api-extractor, generate documentation pages

43 lines 2.59 kB
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license. // See LICENSE in the project root for license information. import { BaseAction } from './BaseAction'; import { YamlDocumenter } from '../documenters/YamlDocumenter'; import { OfficeYamlDocumenter } from '../documenters/OfficeYamlDocumenter'; export class YamlAction extends BaseAction { constructor(parser) { super({ actionName: 'yaml', summary: 'Generate documentation as universal reference YAML files (*.yml)', documentation: 'Generates API documentation as a collection of files conforming' + ' to the universal reference YAML format, which is used by the docs.microsoft.com' + ' pipeline.' }); this._officeParameter = this.defineFlagParameter({ parameterLongName: '--office', description: `Enables some additional features specific to Office Add-ins` }); this._newDocfxNamespacesParameter = this.defineFlagParameter({ parameterLongName: '--new-docfx-namespaces', description: `This enables an experimental feature that will be officially released with the next major version` + ` of API Documenter. It requires DocFX 2.46 or newer. It enables documentation for namespaces and` + ` adds them to the table of contents. This will also affect file layout as namespaced items will be nested` + ` under a directory for the namespace instead of just within the package.` }); this._yamlFormatParameter = this.defineChoiceParameter({ parameterLongName: '--yaml-format', alternatives: ['udp', 'sdp'], defaultValue: 'sdp', description: `Specifies the YAML format - udp or sdp. Universal Document Processor (udp) should be used if you generating` + ` YAML files for DocFX 2.x. Schema Driven Processor (sdp) should be used with DocFX 3.x.` + ` NOTE: This parameter is ignored if you use --office.` }); } async onExecuteAsync() { const { apiModel, inputFolder, outputFolder } = this.buildApiModel(); const yamlDocumenter = this._officeParameter.value ? new OfficeYamlDocumenter(apiModel, inputFolder, this._newDocfxNamespacesParameter.value) : new YamlDocumenter(apiModel, this._newDocfxNamespacesParameter.value, this._yamlFormatParameter.value); yamlDocumenter.generateFiles(outputFolder); } } //# sourceMappingURL=YamlAction.js.map