forked from microsoft/rushstack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathYamlAction.ts
More file actions
55 lines (45 loc) · 2.33 KB
/
YamlAction.ts
File metadata and controls
55 lines (45 loc) · 2.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// Copyright (c) Microsoft Corporation. All rights reserved. Licensed under the MIT license.
// See LICENSE in the project root for license information.
import {
CommandLineFlagParameter
} from '@rushstack/ts-command-line';
import { ApiDocumenterCommandLine } from './ApiDocumenterCommandLine';
import { BaseAction } from './BaseAction';
import { YamlDocumenter } from '../documenters/YamlDocumenter';
import { OfficeYamlDocumenter } from '../documenters/OfficeYamlDocumenter';
import { ApiModel } from '@microsoft/api-extractor-model';
export class YamlAction extends BaseAction {
private _officeParameter: CommandLineFlagParameter;
private _newDocfxNamespacesParameter: CommandLineFlagParameter;
public constructor(parser: ApiDocumenterCommandLine) {
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.'
});
}
protected onDefineParameters(): void { // override
super.onDefineParameters();
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.`
});
}
protected onExecute(): Promise<void> { // override
const apiModel: ApiModel = this.buildApiModel();
const yamlDocumenter: YamlDocumenter = this._officeParameter.value
? new OfficeYamlDocumenter(apiModel, this.inputFolder, this._newDocfxNamespacesParameter.value)
: new YamlDocumenter(apiModel, this._newDocfxNamespacesParameter.value);
yamlDocumenter.generateFiles(this.outputFolder);
return Promise.resolve();
}
}