1
1
import { DocCollection , Document , Processor } from 'dgeni' ;
2
+ import { FunctionExportDoc } from 'dgeni-packages/typescript/api-doc-types/FunctionExportDoc' ;
2
3
import { InterfaceExportDoc } from 'dgeni-packages/typescript/api-doc-types/InterfaceExportDoc' ;
3
4
import { TypeAliasExportDoc } from 'dgeni-packages/typescript/api-doc-types/TypeAliasExportDoc' ;
4
- import { FunctionExportDoc } from 'dgeni-packages/typescript/api-doc-types/FunctionExportDoc' ;
5
- import { CategorizedClassDoc } from '../common/dgeni-definitions' ;
6
5
import * as path from 'path' ;
6
+ import { CategorizedClassDoc } from '../common/dgeni-definitions' ;
7
7
8
- /** Component group data structure . */
9
- export class ComponentGroup {
8
+ /** Document type for an entry-point . */
9
+ export class EntryPointDoc {
10
10
11
11
/** Unique document type for Dgeni. */
12
- docType = 'componentGroup ' ;
12
+ docType = 'entry-point ' ;
13
13
14
14
/** Name of the component group. */
15
15
name : string ;
16
16
17
- /** Display name of the component group */
17
+ /** Display name of the entry-point. */
18
18
displayName : string ;
19
19
20
- /** Module import path for the component group . */
20
+ /** Module import path for the entry-point . */
21
21
moduleImportPath : string ;
22
22
23
23
/** Name of the package, either material or cdk */
@@ -26,10 +26,10 @@ export class ComponentGroup {
26
26
/** Display name of the package. */
27
27
packageDisplayName : string ;
28
28
29
- /** Unique id for the component group . */
29
+ /** Unique id for the entry-point . */
30
30
id : string ;
31
31
32
- /** Known aliases for the component group . */
32
+ /** Known aliases for the entry-point. This is only needed for the `computeIdsProcessor` . */
33
33
aliases : string [ ] = [ ] ;
34
34
35
35
/** List of categorized class docs that are defining a directive. */
@@ -38,38 +38,37 @@ export class ComponentGroup {
38
38
/** List of categorized class docs that are defining a service. */
39
39
services : CategorizedClassDoc [ ] = [ ] ;
40
40
41
- /** Additional classes that belong to the component group . */
42
- additionalClasses : CategorizedClassDoc [ ] = [ ] ;
41
+ /** Classes that belong to the entry-point . */
42
+ classes : CategorizedClassDoc [ ] = [ ] ;
43
43
44
- /** Additional interfaces that belong to the component group . */
45
- additionalInterfaces : InterfaceExportDoc [ ] = [ ] ;
44
+ /** Interfaces that belong to the entry-point . */
45
+ interfaces : InterfaceExportDoc [ ] = [ ] ;
46
46
47
- /** Additional type aliases that belong to the component group . */
48
- additionalTypeAliases : TypeAliasExportDoc [ ] = [ ] ;
47
+ /** Type aliases that belong to the entry-point . */
48
+ typeAliases : TypeAliasExportDoc [ ] = [ ] ;
49
49
50
- /** Additional functions that belong to the component group . */
51
- additionalFunctions : FunctionExportDoc [ ] = [ ] ;
50
+ /** Functions that belong to the entry-point . */
51
+ functions : FunctionExportDoc [ ] = [ ] ;
52
52
53
- /** NgModule that defines the current component group . */
53
+ /** NgModule that defines the current entry-point . */
54
54
ngModule : CategorizedClassDoc | null = null ;
55
55
56
56
constructor ( name : string ) {
57
57
this . name = name ;
58
- this . id = `component-group -${ name } ` ;
58
+ this . id = `entry-point -${ name } ` ;
59
59
}
60
60
}
61
61
62
62
/**
63
- * Processor to group docs into top-level "Components" WRT material design, e.g., "Button", "Tabs" ,
64
- * where each group may conists of several directives and services .
63
+ * Processor to group docs into entry-points that consist of directives, component, classes ,
64
+ * interfaces, functions or type aliases .
65
65
*/
66
- export class ComponentGrouper implements Processor {
67
- name = 'component -grouper' ;
66
+ export class EntryPointGrouper implements Processor {
67
+ name = 'entry-point -grouper' ;
68
68
$runBefore = [ 'docs-processed' ] ;
69
69
70
70
$process ( docs : DocCollection ) {
71
- // Map of group name to group instance.
72
- const groups = new Map < string , ComponentGroup > ( ) ;
71
+ const entryPoints = new Map < string , EntryPointDoc > ( ) ;
73
72
74
73
docs . forEach ( doc => {
75
74
const documentInfo = getDocumentPackageInfo ( doc ) ;
@@ -78,41 +77,41 @@ export class ComponentGrouper implements Processor {
78
77
const packageDisplayName = documentInfo . packageName === 'cdk' ? 'CDK' : 'Material' ;
79
78
80
79
const moduleImportPath = `@angular/${ packageName } /${ documentInfo . entryPointName } ` ;
81
- const groupName = packageName + '-' + documentInfo . name ;
80
+ const entryPointName = packageName + '-' + documentInfo . name ;
82
81
83
- // Get the group for this doc, or, if one does not exist, create it.
84
- let group ;
85
- if ( groups . has ( groupName ) ) {
86
- group = groups . get ( groupName ) ! ;
82
+ // Get the entry-point for this doc, or, if one does not exist, create it.
83
+ let entryPoint ;
84
+ if ( entryPoints . has ( entryPointName ) ) {
85
+ entryPoint = entryPoints . get ( entryPointName ) ! ;
87
86
} else {
88
- group = new ComponentGroup ( groupName ) ;
89
- groups . set ( groupName , group ) ;
87
+ entryPoint = new EntryPointDoc ( entryPointName ) ;
88
+ entryPoints . set ( entryPointName , entryPoint ) ;
90
89
}
91
90
92
- group . displayName = documentInfo . name ;
93
- group . moduleImportPath = moduleImportPath ;
94
- group . packageName = packageName ;
95
- group . packageDisplayName = packageDisplayName ;
91
+ entryPoint . displayName = documentInfo . name ;
92
+ entryPoint . moduleImportPath = moduleImportPath ;
93
+ entryPoint . packageName = packageName ;
94
+ entryPoint . packageDisplayName = packageDisplayName ;
96
95
97
- // Put this doc into the appropriate list in this group .
96
+ // Put this doc into the appropriate list in the entry-point doc .
98
97
if ( doc . isDirective ) {
99
- group . directives . push ( doc ) ;
98
+ entryPoint . directives . push ( doc ) ;
100
99
} else if ( doc . isService ) {
101
- group . services . push ( doc ) ;
100
+ entryPoint . services . push ( doc ) ;
102
101
} else if ( doc . isNgModule ) {
103
- group . ngModule = doc ;
102
+ entryPoint . ngModule = doc ;
104
103
} else if ( doc . docType === 'class' ) {
105
- group . additionalClasses . push ( doc ) ;
104
+ entryPoint . classes . push ( doc ) ;
106
105
} else if ( doc . docType === 'interface' ) {
107
- group . additionalInterfaces . push ( doc ) ;
106
+ entryPoint . interfaces . push ( doc ) ;
108
107
} else if ( doc . docType === 'type-alias' ) {
109
- group . additionalTypeAliases . push ( doc ) ;
108
+ entryPoint . typeAliases . push ( doc ) ;
110
109
} else if ( doc . docType === 'function' ) {
111
- group . additionalFunctions . push ( doc ) ;
110
+ entryPoint . functions . push ( doc ) ;
112
111
}
113
112
} ) ;
114
113
115
- return Array . from ( groups . values ( ) ) ;
114
+ return Array . from ( entryPoints . values ( ) ) ;
116
115
}
117
116
}
118
117
@@ -127,8 +126,9 @@ function getDocumentPackageInfo(doc: Document) {
127
126
const pathSegments = path . relative ( basePath , filePath ) . split ( path . sep ) ;
128
127
let groupName = pathSegments [ 1 ] ;
129
128
130
- // For the ripples there should be a component group in the docs. Even it's not a
131
- // secondary-entry point it can be still documented with its own `material-ripple.html` file.
129
+ // The ripples are technically part of the `@angular/material/core` entry-point, but we
130
+ // want to show the ripple API separately in the docs. In order to archive this, we treat
131
+ // the ripple folder as its own entry-point.
132
132
if ( pathSegments [ 1 ] === 'core' && pathSegments [ 2 ] === 'ripple' ) {
133
133
groupName = 'ripple' ;
134
134
}
0 commit comments