Skip to content

Commit ebc1cf1

Browse files
committed
Merge branch 'master' of https://github.com/TypeStrong/typedoc
2 parents db0cae5 + cd7bfab commit ebc1cf1

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

src/lib/application.ts

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ export class Application extends ChildableComponent<Application, AbstractCompone
7878

7979
@Option({
8080
name: 'exclude',
81-
help: 'Define a pattern for excluded files when specifying paths.',
82-
type: ParameterType.String
81+
help: 'Define patterns for excluded files when specifying paths.',
82+
type: ParameterType.Array
8383
})
84-
exclude: string;
84+
exclude: Array<string>;
8585

8686
/**
8787
* The version number of TypeDoc.
@@ -247,9 +247,11 @@ export class Application extends ChildableComponent<Application, AbstractCompone
247247
* @returns The list of input files with expanded directories.
248248
*/
249249
public expandInputFiles(inputFiles?: string[]): string[] {
250-
let exclude: IMinimatch, files: string[] = [];
251-
if (this.exclude) {
252-
exclude = new Minimatch(this.exclude);
250+
let files: string[] = [];
251+
const exclude: Array<IMinimatch> = this.exclude ? this.exclude.map(pattern => new Minimatch(pattern)) : [];
252+
253+
function isExcluded(fileName: string): boolean {
254+
return exclude.some(mm => mm.match(fileName));
253255
}
254256

255257
function add(dirname: string) {
@@ -258,7 +260,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone
258260
if (FS.statSync(realpath).isDirectory()) {
259261
add(realpath);
260262
} else if (/\.tsx?$/.test(realpath)) {
261-
if (exclude && exclude.match(realpath.replace(/\\/g, '/'))) {
263+
if (isExcluded(realpath.replace(/\\/g, '/'))) {
262264
return;
263265
}
264266

@@ -271,7 +273,7 @@ export class Application extends ChildableComponent<Application, AbstractCompone
271273
file = Path.resolve(file);
272274
if (FS.statSync(file).isDirectory()) {
273275
add(file);
274-
} else if (!exclude || !exclude.match(file)) {
276+
} else if (!isExcluded(file)) {
275277
files.push(file);
276278
}
277279
});

src/test/typedoc.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,15 @@ describe('TypeDoc', function() {
4242
application.options.setValue('exclude', '**/+(class|access).ts');
4343
const expanded = application.expandInputFiles([inputFiles]);
4444

45+
Assert.equal(expanded.indexOf(Path.join(inputFiles, 'class', 'class.ts')), -1);
46+
Assert.equal(expanded.indexOf(Path.join(inputFiles, 'access', 'access.ts')), -1);
47+
Assert.equal(expanded.indexOf(inputFiles), -1);
48+
});
49+
it('supports array of excludes', function() {
50+
const inputFiles = Path.join(__dirname, 'converter');
51+
application.options.setValue('exclude', [ '**/class.ts', '**/access.ts' ]);
52+
const expanded = application.expandInputFiles([inputFiles]);
53+
4554
Assert.equal(expanded.indexOf(Path.join(inputFiles, 'class', 'class.ts')), -1);
4655
Assert.equal(expanded.indexOf(Path.join(inputFiles, 'access', 'access.ts')), -1);
4756
Assert.equal(expanded.indexOf(inputFiles), -1);

0 commit comments

Comments
 (0)