1
1
import { CategorizedClassDoc } from './categorizer' ;
2
- import { DocCollection , Processor } from 'dgeni' ;
2
+ import { DocCollection , Document , Processor } from 'dgeni' ;
3
3
import * as path from 'path' ;
4
4
5
5
/** Component group data structure. */
@@ -66,24 +66,13 @@ export class ComponentGrouper implements Processor {
66
66
const groups = new Map < string , ComponentGroup > ( ) ;
67
67
68
68
docs . forEach ( doc => {
69
- // Full path to the file for this doc.
70
- const basePath = doc . fileInfo . basePath ;
71
- const filePath = doc . fileInfo . filePath ;
72
-
73
- // All of the component documentation is under either `src/lib` or `src/cdk`.
74
- // We group the docs up by the directory immediately under that root.
75
- let packageName , packageDisplayName ;
76
- if ( filePath . includes ( 'cdk' ) ) {
77
- packageName = 'cdk' ;
78
- packageDisplayName = 'CDK' ;
79
- } else {
80
- packageName = 'material' ;
81
- packageDisplayName = 'Material' ;
82
- }
69
+ const documentInfo = getDocumentPackageInfo ( doc ) ;
83
70
84
- const displayName = path . relative ( basePath , filePath ) . split ( path . sep ) [ 1 ] ;
85
- const moduleImportPath = `@angular/${ packageName } /${ displayName } ` ;
86
- const groupName = packageName + '-' + displayName ;
71
+ const packageName = documentInfo . packageName ;
72
+ const packageDisplayName = documentInfo . packageName === 'cdk' ? 'CDK' : 'Material' ;
73
+
74
+ const moduleImportPath = `@angular/${ packageName } /${ documentInfo . entryPointName } ` ;
75
+ const groupName = packageName + '-' + documentInfo . name ;
87
76
88
77
// Get the group for this doc, or, if one does not exist, create it.
89
78
let group ;
@@ -94,9 +83,8 @@ export class ComponentGrouper implements Processor {
94
83
groups . set ( groupName , group ) ;
95
84
}
96
85
97
- group . displayName = displayName ;
86
+ group . displayName = documentInfo . name ;
98
87
group . moduleImportPath = moduleImportPath ;
99
-
100
88
group . packageName = packageName ;
101
89
group . packageDisplayName = packageDisplayName ;
102
90
@@ -115,3 +103,27 @@ export class ComponentGrouper implements Processor {
115
103
return Array . from ( groups . values ( ) ) ;
116
104
}
117
105
}
106
+
107
+ /** Resolves package information for the given Dgeni document. */
108
+ function getDocumentPackageInfo ( doc : Document ) {
109
+ // Full path to the file for this doc.
110
+ const basePath = doc . fileInfo . basePath ;
111
+ const filePath = doc . fileInfo . filePath ;
112
+
113
+ // All of the component documentation is under either `src/lib` or `src/cdk`.
114
+ // We group the docs up by the directory immediately under that root.
115
+ const pathSegments = path . relative ( basePath , filePath ) . split ( path . sep ) ;
116
+ let groupName = pathSegments [ 1 ] ;
117
+
118
+ // For the ripples there should be a component group in the docs. Even it's not a
119
+ // secondary-entry point it can be still documented with its own `material-ripple.html` file.
120
+ if ( pathSegments [ 1 ] === 'core' && pathSegments [ 2 ] === 'ripple' ) {
121
+ groupName = 'ripple' ;
122
+ }
123
+
124
+ return {
125
+ name : groupName ,
126
+ packageName : pathSegments [ 0 ] === 'lib' ? 'material' : pathSegments [ 0 ] ,
127
+ entryPointName : pathSegments [ 1 ] ,
128
+ } ;
129
+ }
0 commit comments