Skip to content

Commit 8d0fdba

Browse files
Vitalius1octogonz
authored andcommitted
Pipe config file all the way to YamlDocumenter
1 parent 78f59df commit 8d0fdba

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ export class YamlAction extends BaseAction {
3939

4040
const yamlDocumenter: YamlDocumenter = this._officeParameter.value
4141
? new OfficeYamlDocumenter(apiModel, this.inputFolder)
42-
: new YamlDocumenter(apiModel, this.configFolder);
42+
: new YamlDocumenter(apiModel);
4343

44-
yamlDocumenter.generateFiles(this.outputFolder);
44+
yamlDocumenter.generateFiles(this.outputFolder, this.configFolder);
4545
return Promise.resolve();
4646
}
4747
}

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

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -55,30 +55,36 @@ const yamlApiSchema: JsonSchema = JsonSchema.fromFile(path.join(__dirname, '..',
5555
export class YamlDocumenter {
5656
private readonly _apiModel: ApiModel;
5757
private readonly _markdownEmitter: CustomMarkdownEmitter;
58-
private readonly _configFolder: string;
59-
58+
6059
// This is used by the _linkToUidIfPossible() workaround.
6160
// It stores a mapping from type name (e.g. "MyClass") to the corresponding ApiItem.
6261
// If the mapping would be ambiguous (e.g. "MyClass" is defined by multiple packages)
6362
// then it is excluded from the mapping. Also excluded are ApiItem objects (such as package
6463
// and function) which are not typically used as a data type.
6564
private _apiItemsByTypeName: Map<string, ApiItem>;
66-
65+
6766
private _outputFolder: string;
6867

69-
public constructor(apiModel: ApiModel, configFolder: string) {
68+
// ideally this needs to be an interface with a defined shape a config file can take. And whoever creates the config
69+
// should use it to leverage the type safety.
70+
private _config: {};
71+
72+
public constructor(apiModel: ApiModel) {
7073
this._apiModel = apiModel;
7174
this._markdownEmitter = new CustomMarkdownEmitter(this._apiModel);
7275
this._apiItemsByTypeName = new Map<string, ApiItem>();
73-
this._configFolder = configFolder;
74-
76+
7577
this._initApiItemsByTypeName();
7678
}
77-
79+
7880
/** @virtual */
79-
public generateFiles(outputFolder: string): void {
81+
public generateFiles(outputFolder: string, configFolder?: string): void {
8082
this._outputFolder = outputFolder;
8183

84+
const configFilePath: string = configFolder ? path.join(configFolder, 'api-documenter.json') : '';
85+
this._config = configFilePath && JsonFile.load(configFilePath);
86+
console.log(this._config);
87+
8288
console.log();
8389
this._deleteOldOutputFiles();
8490

0 commit comments

Comments
 (0)