Skip to content

Commit dbb2244

Browse files
committed
Expand the api-documenter.schema.json to include "outputTarget" and "plugins" fields
1 parent 9e1e7b3 commit dbb2244

3 files changed

Lines changed: 54 additions & 2 deletions

File tree

apps/api-documenter/src/cli/GenerateAction.ts

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import { IConfigFile } from '../documenters/IConfigFile';
1111

1212
import { ApiModel } from '@microsoft/api-extractor-model';
1313
import { FileSystem } from '@microsoft/node-core-library';
14+
import { MarkdownDocumenter } from '../documenters/MarkdownDocumenter';
15+
import { PluginContext } from '../plugin/PluginContext';
1416

1517
export class GenerateAction extends BaseAction {
1618
constructor(parser: ApiDocumenterCommandLine) {
@@ -38,10 +40,19 @@ export class GenerateAction extends BaseAction {
3840

3941
const configFile: IConfigFile = DocumenterConfig.loadFile(configFilePath);
4042

43+
const pluginContext: PluginContext = new PluginContext();
44+
pluginContext.load(configFile.plugins || [], configFilePath);
45+
4146
const apiModel: ApiModel = this.buildApiModel();
4247

43-
const yamlDocumenter: ExperimentalYamlDocumenter = new ExperimentalYamlDocumenter(apiModel, configFile);
44-
yamlDocumenter.generateFiles(this.outputFolder);
48+
if (configFile.outputTarget === 'docfx') {
49+
const yamlDocumenter: ExperimentalYamlDocumenter = new ExperimentalYamlDocumenter(apiModel, configFile);
50+
yamlDocumenter.generateFiles(this.outputFolder);
51+
} else {
52+
const markdownDocumenter: MarkdownDocumenter = new MarkdownDocumenter(apiModel);
53+
markdownDocumenter.generateFiles(this.outputFolder);
54+
}
55+
4556
return Promise.resolve();
4657
}
4758
}

apps/api-documenter/src/documenters/IConfigFile.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,10 +50,36 @@ export interface IConfigTableOfContents {
5050
nonEmptyCategoryNodeNames?: string[];
5151
}
5252

53+
/**
54+
* Describes plugin packages to be loaded, and which features to enable.
55+
*/
56+
export interface IConfigPlugin {
57+
/**
58+
* Specifies the name of an API Documenter plugin package to be loaded. By convention, the NPM package name
59+
* should have the prefix `doc-plugin-`. Its main entry point should export an object named
60+
* `apiDocumenterPluginManifest` which implements the {@link IApiDocumenterPluginManifest} interface.
61+
*/
62+
packageName: string;
63+
64+
/**
65+
* A list of features to be enabled. The features are defined in {@link IApiDocumenterPluginManifest.features}.
66+
* The `enabledFeatureNames` strings are matched with {@link IFeatureDefinition.featureName}.
67+
*/
68+
enabledFeatureNames: string[];
69+
}
70+
5371
/**
5472
* This interface represents the api-extractor.json file format.
5573
*/
5674
export interface IConfigFile {
75+
/**
76+
* Specifies the output target.
77+
*/
78+
outputTarget: 'docfx' | 'markdown';
79+
80+
/** {@inheritDoc IConfigPlugin} */
81+
plugins?: IConfigPlugin[];
82+
5783
/** {@inheritDoc IConfigTableOfContents} */
5884
tableOfContents?: IConfigTableOfContents;
5985
}

apps/api-documenter/src/schemas/api-documenter.schema.json

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,26 @@
88
"type": "string"
99
},
1010

11+
"outputTarget": {
12+
"description": "Specifies what type of documentation will be generated",
13+
"type": "string",
14+
"enum": [
15+
"docfx",
16+
"markdown"
17+
]
18+
},
19+
20+
"plugins": {
21+
"description": "Specifies plugin packages to be loaded",
22+
"type": "array"
23+
},
24+
1125
"tableOfContents": {
1226
"description": "Configures how the table of contents is generated.",
1327
"type": "object",
1428
"additionalProperties": true
1529
},
1630
},
31+
1732
"additionalProperties": false
1833
}

0 commit comments

Comments
 (0)