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' ;
8
3
import {
9
4
decorateDeprecatedDoc ,
10
5
getDirectiveInputAlias ,
@@ -19,35 +14,15 @@ import {
19
14
isProperty ,
20
15
isService
21
16
} 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' ;
24
24
import { sortCategorizedMembers } from '../common/sort-members' ;
25
25
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
- }
51
26
52
27
/**
53
28
* Processor to add properties to docs objects.
@@ -62,34 +37,47 @@ export class Categorizer implements Processor {
62
37
$runBefore = [ 'docs-processed' ] ;
63
38
64
39
$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 ) ) ;
66
43
}
67
44
68
45
/**
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.
72
48
*/
73
- private decorateClassDoc ( classDoc : CategorizedClassDoc ) {
49
+ private decorateClassLikeDoc ( classLikeDoc : CategorizedClassLikeDoc ) {
74
50
// Resolve all methods and properties from the classDoc.
75
- classDoc . methods = classDoc . members
51
+ classLikeDoc . methods = classLikeDoc . members
76
52
. filter ( isMethod )
77
53
. filter ( filterDuplicateMembers ) as CategorizedMethodMemberDoc [ ] ;
78
54
79
- classDoc . properties = classDoc . members
55
+ classLikeDoc . properties = classLikeDoc . members
80
56
. filter ( isProperty )
81
57
. filter ( filterDuplicateMembers ) as CategorizedPropertyMemberDoc [ ] ;
82
58
83
59
// 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 ) ) ;
86
62
87
- decorateDeprecatedDoc ( classDoc ) ;
63
+ decorateDeprecatedDoc ( classLikeDoc ) ;
88
64
89
65
// 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
+ }
92
74
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 ) {
93
81
// Classes can only extend a single class. This means that there can't be multiple extend
94
82
// clauses for the Dgeni document. To make the template syntax simpler and more readable,
95
83
// store the extended class in a variable.
0 commit comments