-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathplugin.ts
32 lines (29 loc) · 1.23 KB
/
plugin.ts
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
import { Component, ConverterComponent } from "typedoc/dist/lib/converter/components";
import { Converter } from "typedoc/dist/lib/converter/converter";
import { Options, OptionsReadMode } from "typedoc/dist/lib/utils/options";
import { Context } from "typedoc/dist/lib/converter/context";
import { Reflection } from "typedoc/dist/lib/models/reflections/abstract";
@Component({ name: 'ensure-internal' })
export class EnsureInternalPlugin extends ConverterComponent {
initialize() {
var options: Options = this.application.options;
var config = options.getRawValues();
if (config.excludeExternals && config.mode === 0) {
this.listenTo(this.owner, {
[Converter.EVENT_BEGIN]: this.onBegin
});
} else {
this.application.logger.warn('typedoc-plugin-ensure-internal does nothing, review your TypeDoc config.');
}
}
private onBegin(context: Context) {
let currentDirectory = context.program.getCurrentDirectory().replace(/\\/g, '/') + '/';
let relativePaths = [];
for (var i = 0; i < context.fileNames.length; i++) {
if (context.fileNames[i].indexOf(currentDirectory) > -1) {
relativePaths.push(context.fileNames[i].replace(currentDirectory, ''));
}
}
context.fileNames = context.fileNames.concat(relativePaths);
}
}