mirror of
https://github.com/angular/angular.git
synced 2026-09-14 13:54:52 +08:00
chore: remove accessor type workaround (#7659)
Due to https://github.com/angular/dgeni-packages/issues/246 the Material docs package used a workaround for accessor types. The issue has been fixed with https://github.com/angular/dgeni-packages/pull/247 and the workaround can be removed now.
This commit is contained in:
committed by
Andrew Seguin
parent
0680481b06
commit
b6f7f1740b
Generated
+7
-7
@@ -3025,9 +3025,9 @@
|
||||
}
|
||||
},
|
||||
"dgeni-packages": {
|
||||
"version": "0.21.2",
|
||||
"resolved": "https://registry.npmjs.org/dgeni-packages/-/dgeni-packages-0.21.2.tgz",
|
||||
"integrity": "sha1-sDEZQXZQe3x9HJc16hRmSXB2OGY=",
|
||||
"version": "0.22.0",
|
||||
"resolved": "https://registry.npmjs.org/dgeni-packages/-/dgeni-packages-0.22.0.tgz",
|
||||
"integrity": "sha1-ftB6+QdPZUeEclbBpltIiloXrQM=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"canonical-path": "0.0.2",
|
||||
@@ -12088,13 +12088,13 @@
|
||||
"integrity": "sha1-Be/1fw70V3+xRKefi5qWemzERRA=",
|
||||
"dev": true,
|
||||
"requires": {
|
||||
"@types/node": "6.0.88"
|
||||
"@types/node": "6.0.89"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/node": {
|
||||
"version": "6.0.88",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.88.tgz",
|
||||
"integrity": "sha512-bYDPZTX0/s1aihdjLuAgogUAT5M+TpoWChEMea2p0yOcfn5bu3k6cJb9cp6nw268XeSNIGGr+4+/8V5K6BGzLQ==",
|
||||
"version": "6.0.89",
|
||||
"resolved": "https://registry.npmjs.org/@types/node/-/node-6.0.89.tgz",
|
||||
"integrity": "sha512-Z/67L97+6H1qJiEEHSN1SQapkWjDss1D90rAnFcQ6UxKkah9juzotK5UNEP1bDv/0lJ3NAQTnVfc/JWdgCGruA==",
|
||||
"dev": true
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -61,7 +61,7 @@
|
||||
"axe-webdriverjs": "^1.1.1",
|
||||
"chalk": "^1.1.3",
|
||||
"dgeni": "^0.4.9",
|
||||
"dgeni-packages": "^0.21.1",
|
||||
"dgeni-packages": "^0.22.0",
|
||||
"firebase": "^4.0.0",
|
||||
"firebase-admin": "^5.0.0",
|
||||
"firebase-tools": "^3.11.0",
|
||||
|
||||
@@ -1,62 +0,0 @@
|
||||
import {getTypeText} from 'dgeni-packages/typescript/services/TsParser/getTypeText';
|
||||
import {getDecorators} from 'dgeni-packages/typescript/services/TsParser/getDecorators';
|
||||
import {
|
||||
ClassDeclaration,
|
||||
SyntaxKind,
|
||||
GetAccessorDeclaration,
|
||||
SetAccessorDeclaration,
|
||||
Symbol,
|
||||
displayPartsToString
|
||||
} from 'typescript';
|
||||
import {CategorizedPropertyMemberDoc} from '../processors/categorizer';
|
||||
|
||||
/**
|
||||
* Accessors are not being parsed properly within the latest Dgeni-packages version.
|
||||
* This function re-analyzes the accessors and resolves the necessary API docs information.
|
||||
* See: https://github.com/angular/dgeni-packages/issues/246
|
||||
*/
|
||||
export function dgeniAccessorsParse(propertyDoc: CategorizedPropertyMemberDoc) {
|
||||
if ((propertyDoc.isGetAccessor || propertyDoc.isSetAccessor) && !propertyDoc.type) {
|
||||
const classDeclaration = propertyDoc.containerDoc.symbol.valueDeclaration as ClassDeclaration;
|
||||
|
||||
// Walk through every TypeScript member node of the class declaration and filter for accessors
|
||||
// with a name that match the current property member. For accessors there may be two
|
||||
// declarations with the same name but with different type information.
|
||||
classDeclaration.members
|
||||
.filter((member: any) => member.kind === SyntaxKind.GetAccessor ||
|
||||
member.kind === SyntaxKind.SetAccessor)
|
||||
.filter((member: any) => member.name && member.name.text === propertyDoc.name)
|
||||
.forEach((member: GetAccessorDeclaration|SetAccessorDeclaration) => {
|
||||
if (member.type) {
|
||||
// If there is a type specified for the current member, then this node is a getter
|
||||
// declaration and its type describes the property.
|
||||
propertyDoc.type = getTypeText(member.type, []);
|
||||
propertyDoc.decorators = getDecorators(member);
|
||||
} else if (member.parameters.length === 1 && member.parameters[0].type) {
|
||||
const type = member.parameters[0].type;
|
||||
|
||||
// If there is a type specified for the first parameter of the property, then this
|
||||
// can be considered a setter and the type of the parameter would describe the actual
|
||||
// property. Transforming the type node to a string is done by the `getTypeText` function
|
||||
// from Dgeni Packages.
|
||||
if (type) {
|
||||
propertyDoc.type = getTypeText(type, []);
|
||||
propertyDoc.decorators = getDecorators(member);
|
||||
}
|
||||
}
|
||||
|
||||
// If the current property document doesn't have any description set and the current
|
||||
// TypeScript has a symbol from the TypeChecker, we can try to find a documentation
|
||||
// comment on that symbol.
|
||||
if (!propertyDoc.description && (member as any).symbol) {
|
||||
const memberSymbol = (member as any).symbol as Symbol;
|
||||
propertyDoc.description = displayPartsToString(memberSymbol.getDocumentationComment());
|
||||
}
|
||||
});
|
||||
|
||||
if (!propertyDoc.type) {
|
||||
console.warn(`Could not find type information for property "${propertyDoc.name}" in ` +
|
||||
`${propertyDoc.fileInfo.relativePath}:${propertyDoc.startingLine}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2,7 +2,7 @@ import {CategorizedMethodMemberDoc, CategorizedPropertyMemberDoc} from '../proce
|
||||
import {isDirectiveInput, isDirectiveOutput} from './decorators';
|
||||
|
||||
/** Combined type for a categorized method member document. */
|
||||
type CategorizedMemberDoc = CategorizedMethodMemberDoc | CategorizedPropertyMemberDoc;
|
||||
type CategorizedMemberDoc = CategorizedMethodMemberDoc & CategorizedPropertyMemberDoc;
|
||||
|
||||
/** Sorts members by deprecated status, member decorator, and name. */
|
||||
export function sortCategorizedMembers(docA: CategorizedMemberDoc, docB: CategorizedMemberDoc) {
|
||||
|
||||
@@ -20,7 +20,6 @@ import {
|
||||
isService
|
||||
} from '../common/decorators';
|
||||
import {MethodMemberDoc} from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc';
|
||||
import {dgeniAccessorsParse} from '../common/dgeni-accessors-parse';
|
||||
import {sortCategorizedMembers} from '../common/sort-members';
|
||||
|
||||
export interface CategorizedClassDoc extends ClassExportDoc {
|
||||
@@ -119,7 +118,6 @@ export class Categorizer implements Processor {
|
||||
*/
|
||||
private decoratePropertyDoc(propertyDoc: CategorizedPropertyMemberDoc) {
|
||||
decorateDeprecatedDoc(propertyDoc);
|
||||
dgeniAccessorsParse(propertyDoc);
|
||||
|
||||
propertyDoc.isDirectiveInput = isDirectiveInput(propertyDoc);
|
||||
propertyDoc.directiveInputAlias = getDirectiveInputAlias(propertyDoc);
|
||||
|
||||
Reference in New Issue
Block a user