1- import { Processor , DocCollection } from 'dgeni' ;
2- import { ClassExportDoc } from 'dgeni-packages/typescript/api-doc-types/ClassExportDoc' ;
3- import { PropertyMemberDoc } from 'dgeni-packages/typescript/api-doc-types/PropertyMemberDoc' ;
4- import {
5- NormalizedMethodMemberDoc ,
6- normalizeMethodParameters
7- } from '../common/normalize-method-parameters' ;
1+ import { DocCollection , Processor } from 'dgeni' ;
2+ import { MethodMemberDoc } from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc' ;
83import {
94 decorateDeprecatedDoc ,
105 getDirectiveInputAlias ,
@@ -19,35 +14,15 @@ import {
1914 isProperty ,
2015 isService
2116} from '../common/decorators' ;
22- import { ClassLikeExportDoc } from 'dgeni-packages/typescript/api-doc-types/ClassLikeExportDoc' ;
23- import { MethodMemberDoc } from 'dgeni-packages/typescript/api-doc-types/MethodMemberDoc' ;
17+ import {
18+ CategorizedClassDoc ,
19+ CategorizedClassLikeDoc ,
20+ CategorizedMethodMemberDoc ,
21+ CategorizedPropertyMemberDoc
22+ } from '../common/dgeni-definitions' ;
23+ import { normalizeMethodParameters } from '../common/normalize-method-parameters' ;
2424import { sortCategorizedMembers } from '../common/sort-members' ;
2525
26- export interface CategorizedClassDoc extends ClassExportDoc {
27- methods : CategorizedMethodMemberDoc [ ] ;
28- properties : CategorizedPropertyMemberDoc [ ] ;
29- isDirective : boolean ;
30- isService : boolean ;
31- isNgModule : boolean ;
32- isDeprecated : boolean ;
33- directiveExportAs ?: string | null ;
34- directiveSelectors ?: string [ ] ;
35- extendedDoc : ClassLikeExportDoc | null ;
36- }
37-
38- export interface CategorizedPropertyMemberDoc extends PropertyMemberDoc {
39- description : string ;
40- isDeprecated : boolean ;
41- isDirectiveInput : boolean ;
42- isDirectiveOutput : boolean ;
43- directiveInputAlias : string ;
44- directiveOutputAlias : string ;
45- }
46-
47- export interface CategorizedMethodMemberDoc extends NormalizedMethodMemberDoc {
48- showReturns : boolean ;
49- isDeprecated : boolean ;
50- }
5126
5227/**
5328 * Processor to add properties to docs objects.
@@ -62,34 +37,47 @@ export class Categorizer implements Processor {
6237 $runBefore = [ 'docs-processed' ] ;
6338
6439 $process ( docs : DocCollection ) {
65- docs . filter ( doc => doc . docType === 'class' ) . forEach ( doc => this . decorateClassDoc ( doc ) ) ;
40+ docs
41+ . filter ( doc => doc . docType === 'class' || doc . docType === 'interface' )
42+ . forEach ( doc => this . decorateClassLikeDoc ( doc ) ) ;
6643 }
6744
6845 /**
69- * Decorates all class docs inside of the dgeni pipeline.
70- * - Methods and properties of a class-doc will be extracted into separate variables.
71- * - Identifies directives, services or NgModules and marks them them in class-doc.
46+ * Decorates all class and interface docs inside of the dgeni pipeline.
47+ * - Members of a class and interface document will be extracted into separate variables.
7248 */
73- private decorateClassDoc ( classDoc : CategorizedClassDoc ) {
49+ private decorateClassLikeDoc ( classLikeDoc : CategorizedClassLikeDoc ) {
7450 // Resolve all methods and properties from the classDoc.
75- classDoc . methods = classDoc . members
51+ classLikeDoc . methods = classLikeDoc . members
7652 . filter ( isMethod )
7753 . filter ( filterDuplicateMembers ) as CategorizedMethodMemberDoc [ ] ;
7854
79- classDoc . properties = classDoc . members
55+ classLikeDoc . properties = classLikeDoc . members
8056 . filter ( isProperty )
8157 . filter ( filterDuplicateMembers ) as CategorizedPropertyMemberDoc [ ] ;
8258
8359 // Call decorate hooks that can modify the method and property docs.
84- classDoc . methods . forEach ( doc => this . decorateMethodDoc ( doc ) ) ;
85- classDoc . properties . forEach ( doc => this . decoratePropertyDoc ( doc ) ) ;
60+ classLikeDoc . methods . forEach ( doc => this . decorateMethodDoc ( doc ) ) ;
61+ classLikeDoc . properties . forEach ( doc => this . decoratePropertyDoc ( doc ) ) ;
8662
87- decorateDeprecatedDoc ( classDoc ) ;
63+ decorateDeprecatedDoc ( classLikeDoc ) ;
8864
8965 // Sort members
90- classDoc . methods . sort ( sortCategorizedMembers ) ;
91- classDoc . properties . sort ( sortCategorizedMembers ) ;
66+ classLikeDoc . methods . sort ( sortCategorizedMembers ) ;
67+ 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+ }
73+ }
9274
75+ /**
76+ * Decorates all Dgeni class documents for a simpler use inside of the template.
77+ * - Identifies directives, services or NgModules and marks them them inside of the doc.
78+ * - Links the Dgeni document to the Dgeni document that the current class extends from.
79+ */
80+ private decorateClassDoc ( classDoc : CategorizedClassDoc ) {
9381 // Classes can only extend a single class. This means that there can't be multiple extend
9482 // clauses for the Dgeni document. To make the template syntax simpler and more readable,
9583 // store the extended class in a variable.
0 commit comments