11import { DocCollection , Processor } from 'dgeni' ;
22import { MethodMemberDoc } from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc' ;
3+ import { getComponentMetadata } from '../common/component-metadata' ;
34import {
4- decorateDeprecatedDoc ,
5- getDirectiveInputAlias ,
6- getDirectiveOutputAlias ,
7- getDirectiveSelectors ,
8- getMetadataProperty ,
9- isDirective ,
10- isDirectiveInput ,
11- isDirectiveOutput ,
12- isMethod ,
13- isNgModule ,
14- isProperty ,
5+ decorateDeprecatedDoc , getDirectiveSelectors , isDirective , isMethod , isNgModule , isProperty ,
156 isService
167} from '../common/decorators' ;
178import {
18- CategorizedClassDoc ,
19- CategorizedClassLikeDoc ,
20- CategorizedMethodMemberDoc ,
9+ CategorizedClassDoc , CategorizedClassLikeDoc , CategorizedMethodMemberDoc ,
2110 CategorizedPropertyMemberDoc
2211} from '../common/dgeni-definitions' ;
2312import { normalizeMethodParameters } from '../common/normalize-method-parameters' ;
13+ import { getInputBindingData , getOutputBindingData } from '../common/property-bindings' ;
2414import { sortCategorizedMembers } from '../common/sort-members' ;
2515
2616
@@ -56,6 +46,11 @@ export class Categorizer implements Processor {
5646 . filter ( isProperty )
5747 . filter ( filterDuplicateMembers ) as CategorizedPropertyMemberDoc [ ] ;
5848
49+ // Special decorations for real class documents that don't apply for interfaces.
50+ if ( classLikeDoc . docType === 'class' ) {
51+ this . decorateClassDoc ( classLikeDoc as CategorizedClassDoc ) ;
52+ }
53+
5954 // Call decorate hooks that can modify the method and property docs.
6055 classLikeDoc . methods . forEach ( doc => this . decorateMethodDoc ( doc ) ) ;
6156 classLikeDoc . properties . forEach ( doc => this . decoratePropertyDoc ( doc ) ) ;
@@ -65,11 +60,6 @@ export class Categorizer implements Processor {
6560 // Sort members
6661 classLikeDoc . methods . sort ( sortCategorizedMembers ) ;
6762 classLikeDoc . properties . sort ( sortCategorizedMembers ) ;
68-
69- // Special decorations for real class documents that don't apply for interfaces.
70- if ( classLikeDoc . docType === 'class' ) {
71- this . decorateClassDoc ( classLikeDoc as CategorizedClassDoc ) ;
72- }
7363 }
7464
7565 /**
@@ -82,12 +72,13 @@ export class Categorizer implements Processor {
8272 // clauses for the Dgeni document. To make the template syntax simpler and more readable,
8373 // store the extended class in a variable.
8474 classDoc . extendedDoc = classDoc . extendsClauses [ 0 ] ? classDoc . extendsClauses [ 0 ] . doc ! : null ;
75+ classDoc . componentMetadata = getComponentMetadata ( classDoc ) ;
8576
8677 // Categorize the current visited classDoc into its Angular type.
87- if ( isDirective ( classDoc ) ) {
78+ if ( isDirective ( classDoc ) && classDoc . componentMetadata ) {
8879 classDoc . isDirective = true ;
89- classDoc . directiveExportAs = getMetadataProperty ( classDoc , 'exportAs' ) ;
90- classDoc . directiveSelectors = getDirectiveSelectors ( classDoc ) ;
80+ classDoc . directiveExportAs = classDoc . componentMetadata . get ( 'exportAs' ) ;
81+ classDoc . directiveSelectors = getDirectiveSelectors ( classDoc ) ;
9182 } else if ( isService ( classDoc ) ) {
9283 classDoc . isService = true ;
9384 } else if ( isNgModule ( classDoc ) ) {
@@ -114,13 +105,17 @@ export class Categorizer implements Processor {
114105 private decoratePropertyDoc ( propertyDoc : CategorizedPropertyMemberDoc ) {
115106 decorateDeprecatedDoc ( propertyDoc ) ;
116107
117- // TODO(devversion): detect inputs based on the `inputs` property in the component metadata.
108+ const metadata = propertyDoc . containerDoc . docType === 'class' ?
109+ ( propertyDoc . containerDoc as CategorizedClassDoc ) . componentMetadata : null ;
110+
111+ const inputMetadata = metadata ? getInputBindingData ( propertyDoc , metadata ) : null ;
112+ const outputMetadata = metadata ? getOutputBindingData ( propertyDoc , metadata ) : null ;
118113
119- propertyDoc . isDirectiveInput = isDirectiveInput ( propertyDoc ) ;
120- propertyDoc . directiveInputAlias = getDirectiveInputAlias ( propertyDoc ) ;
114+ propertyDoc . isDirectiveInput = ! ! inputMetadata ;
115+ propertyDoc . directiveInputAlias = ( inputMetadata && inputMetadata . alias ) || '' ;
121116
122- propertyDoc . isDirectiveOutput = isDirectiveOutput ( propertyDoc ) ;
123- propertyDoc . directiveOutputAlias = getDirectiveOutputAlias ( propertyDoc ) ;
117+ propertyDoc . isDirectiveOutput = ! ! outputMetadata ;
118+ propertyDoc . directiveOutputAlias = ( outputMetadata && outputMetadata . alias ) || '' ;
124119 }
125120}
126121
0 commit comments