Skip to content

Commit f807f97

Browse files
TypeDoc compatibility updates
1 parent 9246a94 commit f807f97

File tree

5 files changed

+127
-62
lines changed

5 files changed

+127
-62
lines changed

bin/typedoc.d.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1152,6 +1152,24 @@ declare module td.converter {
11521152
* @returns TRUE if file names are case sensitive on the current platform, FALSE otherwise.
11531153
*/
11541154
useCaseSensitiveFileNames(): boolean;
1155+
/**
1156+
* Check whether the given file exists.
1157+
*
1158+
* Implementation of ts.CompilerHost.fileExists(fileName)
1159+
*
1160+
* @param fileName
1161+
* @returns {boolean}
1162+
*/
1163+
fileExists(fileName: string): boolean;
1164+
/**
1165+
* Return the contents of the given file.
1166+
*
1167+
* Implementation of ts.CompilerHost.readFile(fileName)
1168+
*
1169+
* @param fileName
1170+
* @returns {string}
1171+
*/
1172+
readFile(fileName: string): string;
11551173
/**
11561174
* Return the canonical file name of the given file.
11571175
*

bin/typedoc.js

Lines changed: 81 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -186,8 +186,7 @@ var td;
186186
var __extends = (this && this.__extends) || function (d, b) {
187187
for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p];
188188
function __() { this.constructor = d; }
189-
__.prototype = b.prototype;
190-
d.prototype = new __();
189+
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
191190
};
192191
/**
193192
* The TypeDoc main module and namespace.
@@ -708,7 +707,7 @@ var td;
708707
if (diagnostic.file) {
709708
output = diagnostic.file.fileName;
710709
output += '(' + ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start).line + ')';
711-
output += ts.sys.newLine + ' ' + diagnostic.messageText;
710+
output += ts.sys.newLine + ' ' + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine);
712711
}
713712
else {
714713
output = diagnostic.messageText;
@@ -2128,6 +2127,28 @@ var td;
21282127
Converter.prototype.useCaseSensitiveFileNames = function () {
21292128
return ts.sys.useCaseSensitiveFileNames;
21302129
};
2130+
/**
2131+
* Check whether the given file exists.
2132+
*
2133+
* Implementation of ts.CompilerHost.fileExists(fileName)
2134+
*
2135+
* @param fileName
2136+
* @returns {boolean}
2137+
*/
2138+
Converter.prototype.fileExists = function (fileName) {
2139+
return ts.sys.fileExists(fileName);
2140+
};
2141+
/**
2142+
* Return the contents of the given file.
2143+
*
2144+
* Implementation of ts.CompilerHost.readFile(fileName)
2145+
*
2146+
* @param fileName
2147+
* @returns {string}
2148+
*/
2149+
Converter.prototype.readFile = function (fileName) {
2150+
return ts.sys.readFile(fileName);
2151+
};
21312152
/**
21322153
* Return the canonical file name of the given file.
21332154
*
@@ -2285,16 +2306,16 @@ var td;
22852306
if (!node.initializer)
22862307
return;
22872308
switch (node.initializer.kind) {
2288-
case 8 /* StringLiteral */:
2309+
case 9 /* StringLiteral */:
22892310
return '"' + node.initializer.text + '"';
22902311
break;
2291-
case 7 /* NumericLiteral */:
2312+
case 8 /* NumericLiteral */:
22922313
return node.initializer.text;
22932314
break;
2294-
case 95 /* TrueKeyword */:
2315+
case 97 /* TrueKeyword */:
22952316
return 'true';
22962317
break;
2297-
case 80 /* FalseKeyword */:
2318+
case 82 /* FalseKeyword */:
22982319
return 'false';
22992320
break;
23002321
default:
@@ -2332,72 +2353,72 @@ var td;
23322353
}
23332354
var result;
23342355
switch (node.kind) {
2335-
case 228 /* SourceFile */:
2356+
case 246 /* SourceFile */:
23362357
result = visitSourceFile(context, node);
23372358
break;
2338-
case 175 /* ClassExpression */:
2339-
case 202 /* ClassDeclaration */:
2359+
case 184 /* ClassExpression */:
2360+
case 212 /* ClassDeclaration */:
23402361
result = visitClassDeclaration(context, node);
23412362
break;
2342-
case 203 /* InterfaceDeclaration */:
2363+
case 213 /* InterfaceDeclaration */:
23432364
result = visitInterfaceDeclaration(context, node);
23442365
break;
2345-
case 206 /* ModuleDeclaration */:
2366+
case 216 /* ModuleDeclaration */:
23462367
result = visitModuleDeclaration(context, node);
23472368
break;
2348-
case 181 /* VariableStatement */:
2369+
case 191 /* VariableStatement */:
23492370
result = visitVariableStatement(context, node);
23502371
break;
2351-
case 132 /* PropertySignature */:
2352-
case 133 /* PropertyDeclaration */:
2353-
case 225 /* PropertyAssignment */:
2354-
case 226 /* ShorthandPropertyAssignment */:
2355-
case 199 /* VariableDeclaration */:
2356-
case 153 /* BindingElement */:
2372+
case 138 /* PropertySignature */:
2373+
case 139 /* PropertyDeclaration */:
2374+
case 243 /* PropertyAssignment */:
2375+
case 244 /* ShorthandPropertyAssignment */:
2376+
case 209 /* VariableDeclaration */:
2377+
case 161 /* BindingElement */:
23572378
result = visitVariableDeclaration(context, node);
23582379
break;
2359-
case 205 /* EnumDeclaration */:
2380+
case 215 /* EnumDeclaration */:
23602381
result = visitEnumDeclaration(context, node);
23612382
break;
2362-
case 227 /* EnumMember */:
2383+
case 245 /* EnumMember */:
23632384
result = visitEnumMember(context, node);
23642385
break;
2365-
case 136 /* Constructor */:
2366-
case 140 /* ConstructSignature */:
2386+
case 142 /* Constructor */:
2387+
case 146 /* ConstructSignature */:
23672388
result = visitConstructor(context, node);
23682389
break;
2369-
case 134 /* MethodSignature */:
2370-
case 135 /* MethodDeclaration */:
2371-
case 201 /* FunctionDeclaration */:
2390+
case 140 /* MethodSignature */:
2391+
case 141 /* MethodDeclaration */:
2392+
case 211 /* FunctionDeclaration */:
23722393
result = visitFunctionDeclaration(context, node);
23732394
break;
2374-
case 137 /* GetAccessor */:
2395+
case 143 /* GetAccessor */:
23752396
result = visitGetAccessorDeclaration(context, node);
23762397
break;
2377-
case 138 /* SetAccessor */:
2398+
case 144 /* SetAccessor */:
23782399
result = visitSetAccessorDeclaration(context, node);
23792400
break;
2380-
case 139 /* CallSignature */:
2381-
case 143 /* FunctionType */:
2401+
case 145 /* CallSignature */:
2402+
case 150 /* FunctionType */:
23822403
result = visitCallSignatureDeclaration(context, node);
23832404
break;
2384-
case 141 /* IndexSignature */:
2405+
case 147 /* IndexSignature */:
23852406
result = visitIndexSignatureDeclaration(context, node);
23862407
break;
2387-
case 180 /* Block */:
2388-
case 207 /* ModuleBlock */:
2408+
case 190 /* Block */:
2409+
case 217 /* ModuleBlock */:
23892410
result = visitBlock(context, node);
23902411
break;
2391-
case 155 /* ObjectLiteralExpression */:
2412+
case 163 /* ObjectLiteralExpression */:
23922413
result = visitObjectLiteral(context, node);
23932414
break;
2394-
case 146 /* TypeLiteral */:
2415+
case 153 /* TypeLiteral */:
23952416
result = visitTypeLiteral(context, node);
23962417
break;
2397-
case 215 /* ExportAssignment */:
2418+
case 225 /* ExportAssignment */:
23982419
result = visitExportAssignment(context, node);
23992420
break;
2400-
case 204 /* TypeAliasDeclaration */:
2421+
case 214 /* TypeAliasDeclaration */:
24012422
result = visitTypeAliasDeclaration(context, node);
24022423
break;
24032424
}
@@ -2407,7 +2428,7 @@ var td;
24072428
converter.visit = visit;
24082429
function visitBlock(context, node) {
24092430
if (node.statements) {
2410-
var prefered = [202 /* ClassDeclaration */, 203 /* InterfaceDeclaration */, 205 /* EnumDeclaration */];
2431+
var prefered = [212 /* ClassDeclaration */, 213 /* InterfaceDeclaration */, 215 /* EnumDeclaration */];
24112432
var statements = [];
24122433
node.statements.forEach(function (statement) {
24132434
if (prefered.indexOf(statement.kind) != -1) {
@@ -2616,12 +2637,12 @@ var td;
26162637
context.withScope(variable, function () {
26172638
if (node.initializer) {
26182639
switch (node.initializer.kind) {
2619-
case 164 /* ArrowFunction */:
2620-
case 163 /* FunctionExpression */:
2640+
case 172 /* ArrowFunction */:
2641+
case 171 /* FunctionExpression */:
26212642
variable.kind = scope.kind & td.models.ReflectionKind.ClassOrInterface ? td.models.ReflectionKind.Method : td.models.ReflectionKind.Function;
26222643
visitCallSignatureDeclaration(context, node.initializer);
26232644
break;
2624-
case 155 /* ObjectLiteralExpression */:
2645+
case 163 /* ObjectLiteralExpression */:
26252646
if (!isSimpleObjectLiteral(node.initializer)) {
26262647
variable.kind = td.models.ReflectionKind.ObjectLiteral;
26272648
variable.type = new td.models.IntrinsicType('object');
@@ -2910,28 +2931,28 @@ var td;
29102931
}
29112932
// Node based type conversions by node kind
29122933
switch (node.kind) {
2913-
case 8 /* StringLiteral */:
2934+
case 9 /* StringLiteral */:
29142935
return convertStringLiteralExpression(node);
2915-
case 147 /* ArrayType */:
2936+
case 154 /* ArrayType */:
29162937
return convertArrayTypeNode(context, node);
2917-
case 148 /* TupleType */:
2938+
case 155 /* TupleType */:
29182939
return convertTupleTypeNode(context, node);
2919-
case 149 /* UnionType */:
2940+
case 156 /* UnionType */:
29202941
return convertUnionTypeNode(context, node);
29212942
}
29222943
// Node based type conversions by type flags
29232944
if (type) {
29242945
if (type.flags & 512 /* TypeParameter */) {
29252946
return convertTypeParameterNode(context, node);
29262947
}
2927-
else if (type.flags & 48128 /* ObjectType */) {
2948+
else if (type.flags & 80896 /* ObjectType */) {
29282949
return convertTypeReferenceNode(context, node, type);
29292950
}
29302951
}
29312952
}
29322953
// Type conversions by type flags
29332954
if (type) {
2934-
if (type.flags & 1048703 /* Intrinsic */) {
2955+
if (type.flags & 16777343 /* Intrinsic */) {
29352956
return convertIntrinsicType(type);
29362957
}
29372958
else if (type.flags & 256 /* StringLiteral */) {
@@ -2946,7 +2967,7 @@ var td;
29462967
else if (type.flags & 16384 /* Union */) {
29472968
return convertUnionType(context, type);
29482969
}
2949-
else if (type.flags & 48128 /* ObjectType */) {
2970+
else if (type.flags & 80896 /* ObjectType */) {
29502971
return convertTypeReferenceType(context, type);
29512972
}
29522973
else {
@@ -3333,7 +3354,7 @@ var td;
33333354
* @returns The type reflection representing the given binding pattern.
33343355
*/
33353356
function convertDestructuringType(context, node) {
3336-
if (node.kind == 152 /* ArrayBindingPattern */) {
3357+
if (node.kind == 160 /* ArrayBindingPattern */) {
33373358
var types = [];
33383359
node.elements.forEach(function (element) {
33393360
types.push(convertType(context, element));
@@ -3781,7 +3802,7 @@ var td;
37813802
if (kind == td.models.ReflectionKind.ExternalModule) {
37823803
isExported = true; // Always mark external modules as exported
37833804
}
3784-
else if (node.parent && node.parent.kind == 200 /* VariableDeclarationList */) {
3805+
else if (node.parent && node.parent.kind == 210 /* VariableDeclarationList */) {
37853806
isExported = isExported || !!(node.parent.parent.flags & 1 /* Export */);
37863807
}
37873808
else {
@@ -3801,10 +3822,10 @@ var td;
38013822
if (nonStaticKinds.indexOf(kind) == -1) {
38023823
isStatic = !!(node.flags & 128 /* Static */);
38033824
if (container.kind == td.models.ReflectionKind.Class) {
3804-
if (node.parent && node.parent.kind == 136 /* Constructor */) {
3825+
if (node.parent && node.parent.kind == 142 /* Constructor */) {
38053826
isConstructorProperty = true;
38063827
}
3807-
else if (!node.parent || node.parent.kind != 202 /* ClassDeclaration */) {
3828+
else if (!node.parent || node.parent.kind != 212 /* ClassDeclaration */) {
38083829
isStatic = true;
38093830
}
38103831
}
@@ -3951,7 +3972,7 @@ var td;
39513972
*/
39523973
function extractSignatureType(context, node) {
39533974
var checker = context.checker;
3954-
if (node.kind & 139 /* CallSignature */ || node.kind & 158 /* CallExpression */) {
3975+
if (node.kind & 145 /* CallSignature */ || node.kind & 166 /* CallExpression */) {
39553976
try {
39563977
var signature = checker.getSignatureFromDeclaration(node);
39573978
return converter.convertType(context, node.type, checker.getReturnTypeOfSignature(signature));
@@ -4252,18 +4273,18 @@ var td;
42524273
CommentPlugin.getComment = function (node) {
42534274
var sourceFile = ts.getSourceFileOfNode(node);
42544275
var target = node;
4255-
if (node.kind == 206 /* ModuleDeclaration */) {
4276+
if (node.kind == 216 /* ModuleDeclaration */) {
42564277
var a, b;
42574278
// Ignore comments for cascaded modules, e.g. module A.B { }
4258-
if (node.nextContainer && node.nextContainer.kind == 206 /* ModuleDeclaration */) {
4279+
if (node.nextContainer && node.nextContainer.kind == 216 /* ModuleDeclaration */) {
42594280
a = node;
42604281
b = node.nextContainer;
42614282
if (a.name.end + 1 == b.name.pos) {
42624283
return null;
42634284
}
42644285
}
42654286
// Pull back comments of cascaded modules
4266-
while (target.parent && target.parent.kind == 206 /* ModuleDeclaration */) {
4287+
while (target.parent && target.parent.kind == 216 /* ModuleDeclaration */) {
42674288
a = target;
42684289
b = target.parent;
42694290
if (a.name.pos == b.name.end + 1) {
@@ -4274,13 +4295,13 @@ var td;
42744295
}
42754296
}
42764297
}
4277-
if (node.parent && node.parent.kind == 200 /* VariableDeclarationList */) {
4298+
if (node.parent && node.parent.kind == 210 /* VariableDeclarationList */) {
42784299
target = node.parent.parent;
42794300
}
42804301
var comments = ts.getJsDocComments(target, sourceFile);
42814302
if (comments && comments.length) {
42824303
var comment;
4283-
if (node.kind == 228 /* 'SourceFile' */) {
4304+
if (node.kind == 246 /* 'SourceFile' */) {
42844305
if (comments.length == 1)
42854306
return null;
42864307
comment = comments[0];
@@ -4516,10 +4537,10 @@ var td;
45164537
var callExpression;
45174538
var identifier;
45184539
switch (decorator.expression.kind) {
4519-
case 65 /* Identifier */:
4540+
case 67 /* Identifier */:
45204541
identifier = decorator.expression;
45214542
break;
4522-
case 158 /* CallExpression */:
4543+
case 166 /* CallExpression */:
45234544
callExpression = decorator.expression;
45244545
identifier = callExpression.expression;
45254546
break;

src/td/Logger.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ module td
151151
if (diagnostic.file) {
152152
output = diagnostic.file.fileName;
153153
output += '(' + ts.getLineAndCharacterOfPosition(diagnostic.file, diagnostic.start).line + ')';
154-
output += ts.sys.newLine + ' ' + diagnostic.messageText;
154+
output += ts.sys.newLine + ' ' + ts.flattenDiagnosticMessageText(diagnostic.messageText, ts.sys.newLine);
155155
} else {
156156
output = diagnostic.messageText;
157157
}

src/td/converter/Converter.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,32 @@ module td.converter
444444
}
445445

446446

447+
/**
448+
* Check whether the given file exists.
449+
*
450+
* Implementation of ts.CompilerHost.fileExists(fileName)
451+
*
452+
* @param fileName
453+
* @returns {boolean}
454+
*/
455+
fileExists(fileName:string):boolean {
456+
return ts.sys.fileExists(fileName);
457+
}
458+
459+
460+
/**
461+
* Return the contents of the given file.
462+
*
463+
* Implementation of ts.CompilerHost.readFile(fileName)
464+
*
465+
* @param fileName
466+
* @returns {string}
467+
*/
468+
readFile(fileName:string):string {
469+
return ts.sys.readFile(fileName);
470+
}
471+
472+
447473
/**
448474
* Return the canonical file name of the given file.
449475
*

0 commit comments

Comments
 (0)