dgeni-packages
Advanced tools
Comparing version 0.20.0-rc.1 to 0.20.0-rc.2
# Changelog | ||
# 0.20.0-rc.2 10 July 2017 | ||
## Bug Fixes | ||
- **typescript:** allow decorators to not be call expressions e41a392a | ||
# 0.20.0-rc.1 6 July 2017 | ||
@@ -4,0 +11,0 @@ |
{ | ||
"name": "dgeni-packages", | ||
"version": "0.20.0-rc.1", | ||
"version": "0.20.0-rc.2", | ||
"description": "A collection of dgeni packages for generating documentation from source code", | ||
@@ -109,4 +109,5 @@ "scripts": { | ||
"Rod Leviton <rod@rodleviton.com>", | ||
"Paul Gschwendtner <paulgschwendtner@gmail.com>" | ||
"Paul Gschwendtner <paulgschwendtner@gmail.com>", | ||
"Hagen Schulze <hagen.schulze@nextlabel.de>" | ||
] | ||
} |
@@ -1,2 +0,3 @@ | ||
import { Declaration, Decorator, Symbol } from 'typescript'; | ||
import { Declaration, Symbol } from 'typescript'; | ||
import { ParsedDecorator } from "../services/TsParser/getDecorators"; | ||
import { ContainerExportDoc } from './ContainerExportDoc'; | ||
@@ -8,10 +9,3 @@ import { ModuleDoc } from './ModuleDoc'; | ||
export declare abstract class ClassLikeExportDoc extends ContainerExportDoc { | ||
decorators: { | ||
argumentInfo: (string | string[] | { | ||
[key: string]: string | string[] | any; | ||
})[]; | ||
arguments: string[]; | ||
expression: Decorator; | ||
name: string; | ||
}[] | undefined; | ||
decorators: ParsedDecorator[] | undefined; | ||
extendsClauses: string[]; | ||
@@ -18,0 +12,0 @@ implementsClauses: string[]; |
@@ -1,3 +0,4 @@ | ||
import { Declaration, Decorator, Symbol } from 'typescript'; | ||
import { Declaration, Symbol } from 'typescript'; | ||
import { FileInfo } from '../services/TsParser/FileInfo'; | ||
import { ParsedDecorator } from "../services/TsParser/getDecorators"; | ||
import { ApiDoc } from './ApiDoc'; | ||
@@ -24,10 +25,3 @@ import { ContainerExportDoc } from './ContainerExportDoc'; | ||
readonly accessibility: string; | ||
readonly decorators: { | ||
argumentInfo: (string | string[] | { | ||
[key: string]: string | string[] | any; | ||
})[]; | ||
arguments: string[]; | ||
expression: Decorator; | ||
name: string; | ||
}[] | undefined; | ||
readonly decorators: ParsedDecorator[] | undefined; | ||
readonly type: string; | ||
@@ -34,0 +28,0 @@ readonly isOptional: boolean; |
@@ -5,7 +5,9 @@ import { Declaration, Decorator } from 'typescript'; | ||
}; | ||
export declare function getDecorators(declaration: Declaration): { | ||
argumentInfo: ArgumentInfo[]; | ||
arguments: string[]; | ||
export interface ParsedDecorator { | ||
argumentInfo?: ArgumentInfo[]; | ||
arguments?: string[]; | ||
expression: Decorator; | ||
isCallExpression: boolean; | ||
name: string; | ||
}[] | undefined; | ||
} | ||
export declare function getDecorators(declaration: Declaration): ParsedDecorator[] | undefined; |
@@ -8,11 +8,18 @@ "use strict"; | ||
var callExpression = getCallExpression(decorator); | ||
if (!callExpression) { | ||
throw new Error("Expected decorator to be a call expression: " + decorator.getText()); | ||
if (callExpression) { | ||
return { | ||
argumentInfo: callExpression.arguments.map(function (argument) { return parseArgument(argument); }), | ||
arguments: callExpression.arguments.map(function (argument) { return argument.getText(); }), | ||
expression: decorator, | ||
isCallExpression: true, | ||
name: callExpression.expression.getText(), | ||
}; | ||
} | ||
return { | ||
argumentInfo: callExpression.arguments.map(function (argument) { return parseArgument(argument); }), | ||
arguments: callExpression.arguments.map(function (argument) { return argument.getText(); }), | ||
expression: decorator, | ||
name: callExpression.expression.getText(), | ||
}; | ||
else { | ||
return { | ||
expression: decorator, | ||
isCallExpression: false, | ||
name: decorator.expression.getText(), | ||
}; | ||
} | ||
}); | ||
@@ -19,0 +26,0 @@ } |
@@ -6,3 +6,3 @@ /* tslint:disable:no-bitwise */ | ||
import { getAccessibility } from "../services/TsParser/getAccessibility"; | ||
import { getDecorators } from "../services/TsParser/getDecorators"; | ||
import { getDecorators, ParsedDecorator } from "../services/TsParser/getDecorators"; | ||
import { getTypeParametersText } from '../services/TsParser/getTypeParametersText'; | ||
@@ -9,0 +9,0 @@ import { getTypeText } from '../services/TsParser/getTypeText'; |
@@ -7,3 +7,3 @@ /* tslint:disable:no-bitwise */ | ||
import { getDeclarationTypeText } from "../services/TsParser/getDeclarationTypeText"; | ||
import { getDecorators } from "../services/TsParser/getDecorators"; | ||
import { getDecorators, ParsedDecorator } from "../services/TsParser/getDecorators"; | ||
import { getTypeText } from '../services/TsParser/getTypeText'; | ||
@@ -10,0 +10,0 @@ import { ApiDoc } from './ApiDoc'; |
@@ -5,15 +5,29 @@ import { ArrayLiteralExpression, CallExpression, Declaration, Decorator, Expression, ObjectLiteralElement, ObjectLiteralExpression, PropertyAssignment, SyntaxKind } from 'typescript'; | ||
export interface ParsedDecorator { | ||
argumentInfo?: ArgumentInfo[]; | ||
arguments?: string[]; | ||
expression: Decorator; | ||
isCallExpression: boolean; | ||
name: string; | ||
} | ||
export function getDecorators(declaration: Declaration) { | ||
if (declaration.decorators) { | ||
return declaration.decorators.map(decorator => { | ||
return declaration.decorators.map<ParsedDecorator>(decorator => { | ||
const callExpression = getCallExpression(decorator); | ||
if (!callExpression) { | ||
throw new Error(`Expected decorator to be a call expression: ${decorator.getText()}`); | ||
if (callExpression) { | ||
return { | ||
argumentInfo: callExpression.arguments.map(argument => parseArgument(argument)), | ||
arguments: callExpression.arguments.map(argument => argument.getText()), | ||
expression: decorator as Decorator, | ||
isCallExpression: true, | ||
name: callExpression.expression.getText(), | ||
}; | ||
} else { | ||
return { | ||
expression: decorator as Decorator, | ||
isCallExpression: false, | ||
name: decorator.expression.getText(), | ||
}; | ||
} | ||
return { | ||
argumentInfo: callExpression.arguments.map(argument => parseArgument(argument)), | ||
arguments: callExpression.arguments.map(argument => argument.getText()), | ||
expression: decorator as Decorator, | ||
name: callExpression.expression.getText(), | ||
}; | ||
}); | ||
@@ -20,0 +34,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
817183
565
13663