Skip to content

Commit 15ec1b3

Browse files
committed
fix: improve path handling, add missing .bind()
1 parent f5e47e1 commit 15ec1b3

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

src/extracter.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,9 @@ export default class Extracter {
9898
}
9999
return d;
100100
});
101+
if (!exists(this.dir)) {
102+
throw new Error(`${ this.dir } does not exist, cannot extract documention from it`);
103+
}
101104
}
102105

103106
/**
@@ -143,7 +146,7 @@ export default class Extracter {
143146

144147
detectSourceType(): 'typescript' | 'javascript' | null {
145148
// Typescript
146-
if (exists(path.join(this.dir, 'tsconfig.json'))) {
149+
if (glob(path.join(this.dir, `{${ this.sourceDirs.join(',') }}`, '**', '*.ts'))) {
147150
return 'typescript';
148151
// JavaScript
149152
} else if (glob(path.join(this.dir, `{${ this.sourceDirs.join(',') }}`, '**', '*.js'))) {

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export { default as Extracter } from './extracter';
1+
export { default as Extracter, ExtractedDocs } from './extracter';
22
export { default as ExtracterTree } from './trees/extracter';

src/source-extracters/typescript.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default class TypescriptSourceExtracter extends SourceExtracter {
2121
sourcePatterns() {
2222
return this.sourceDirs.reduce((files, dir) => {
2323
let pattern = path.join(dir, '**', '*.ts');
24-
return files.concat(glob(pattern));
24+
return files.concat(glob(pattern, { cwd: this.baseDir }));
2525
}, <string[]>[]);
2626
}
2727

@@ -30,15 +30,15 @@ export default class TypescriptSourceExtracter extends SourceExtracter {
3030
let files = this.sourcePatterns();
3131
let originalDir = process.cwd();
3232
process.chdir(this.baseDir);
33-
let app = new Application({ tsconfig: path.join(this.baseDir, 'tsconfig.json'), ignoreCompilerErrors: true });
33+
let app = new Application({ ignoreCompilerErrors: true });
3434
let result = app.convert(files);
3535
process.chdir(originalDir);
3636
return result;
3737
}
3838

3939
normalize(project: ProjectReflection) {
4040
debug(`Transforming Typedoc output into Documenter standard format`);
41-
project.children.forEach((file) => {
41+
(project.children || []).forEach((file) => {
4242
(file.children|| []).forEach((item) => {
4343
if (item.flags.isExported) {
4444
let packageName = this.getPackageName(item);
@@ -244,7 +244,7 @@ export default class TypescriptSourceExtracter extends SourceExtracter {
244244

245245
// Add any type args it might take, recursing into those types to render them properly
246246
if (type.typeArguments) {
247-
displayType += '<' + type.typeArguments.map(this.displayTypeFrom).join(', ') + '>';
247+
displayType += '<' + type.typeArguments.map(this.displayTypeFrom.bind(this)).join(', ') + '>';
248248
}
249249

250250
return displayType;

0 commit comments

Comments
 (0)