@@ -4,8 +4,18 @@ import {FunctionExportDoc} from 'dgeni-packages/typescript/api-doc-types/Functio
4
4
import { InterfaceExportDoc } from 'dgeni-packages/typescript/api-doc-types/InterfaceExportDoc' ;
5
5
import { TypeAliasExportDoc } from 'dgeni-packages/typescript/api-doc-types/TypeAliasExportDoc' ;
6
6
import * as path from 'path' ;
7
+ import { computeApiDocumentUrl } from '../common/compute-api-url' ;
7
8
import { CategorizedClassDoc } from '../common/dgeni-definitions' ;
8
9
10
+ export interface ModuleInfo {
11
+ /** Name of the module (e.g. toolbar, drag-drop, ripple) */
12
+ name : string ;
13
+ /** Name of the package that contains this entry point. */
14
+ packageName : string ;
15
+ /** Name of the entry-point that contains this module. */
16
+ entryPointName : string ;
17
+ }
18
+
9
19
/** Document type for an entry-point. */
10
20
export class EntryPointDoc {
11
21
@@ -75,13 +85,17 @@ export class EntryPointGrouper implements Processor {
75
85
const entryPoints = new Map < string , EntryPointDoc > ( ) ;
76
86
77
87
docs . forEach ( doc => {
78
- const documentInfo = getDocumentPackageInfo ( doc ) ;
88
+ const moduleInfo = getModulePackageInfo ( doc ) ;
89
+
90
+ const packageName = moduleInfo . packageName ;
91
+ const packageDisplayName = packageName === 'cdk' ? 'CDK' : 'Material' ;
79
92
80
- const packageName = documentInfo . packageName ;
81
- const packageDisplayName = documentInfo . packageName === 'cdk' ? 'CDK' : 'Material' ;
93
+ const moduleImportPath = `@angular/ ${ packageName } / ${ moduleInfo . entryPointName } ` ;
94
+ const entryPointName = packageName + '-' + moduleInfo . name ;
82
95
83
- const moduleImportPath = `@angular/${ packageName } /${ documentInfo . entryPointName } ` ;
84
- const entryPointName = packageName + '-' + documentInfo . name ;
96
+ // Compute a public URL that refers to the document. This is helpful if we want to
97
+ // make references to other API documents. e.g. showing the extended class.
98
+ doc . publicUrl = computeApiDocumentUrl ( doc , moduleInfo ) ;
85
99
86
100
// Get the entry-point for this doc, or, if one does not exist, create it.
87
101
let entryPoint ;
@@ -92,7 +106,7 @@ export class EntryPointGrouper implements Processor {
92
106
entryPoints . set ( entryPointName , entryPoint ) ;
93
107
}
94
108
95
- entryPoint . displayName = documentInfo . name ;
109
+ entryPoint . displayName = moduleInfo . name ;
96
110
entryPoint . moduleImportPath = moduleImportPath ;
97
111
entryPoint . packageName = packageName ;
98
112
entryPoint . packageDisplayName = packageDisplayName ;
@@ -121,26 +135,29 @@ export class EntryPointGrouper implements Processor {
121
135
}
122
136
}
123
137
124
- /** Resolves package information for the given Dgeni document. */
125
- function getDocumentPackageInfo ( doc : Document ) {
138
+ /** Resolves module package information of the given Dgeni document. */
139
+ function getModulePackageInfo ( doc : Document ) : ModuleInfo {
126
140
// Full path to the file for this doc.
127
141
const basePath = doc . fileInfo . basePath ;
128
142
const filePath = doc . fileInfo . filePath ;
129
143
130
144
// All of the component documentation is under either `src/lib` or `src/cdk`.
131
145
// We group the docs up by the directory immediately under that root.
132
146
const pathSegments = path . relative ( basePath , filePath ) . split ( path . sep ) ;
133
- let groupName = pathSegments [ 1 ] ;
147
+
148
+ // The module name is usually the entry-point (e.g. slide-toggle, toolbar), but this is not
149
+ // guaranteed because we can also export a module from lib/core. e.g. the ripple module.
150
+ let moduleName = pathSegments [ 1 ] ;
134
151
135
152
// The ripples are technically part of the `@angular/material/core` entry-point, but we
136
153
// want to show the ripple API separately in the docs. In order to archive this, we treat
137
- // the ripple folder as its own entry-point .
154
+ // the ripple folder as its own module .
138
155
if ( pathSegments [ 1 ] === 'core' && pathSegments [ 2 ] === 'ripple' ) {
139
- groupName = 'ripple' ;
156
+ moduleName = 'ripple' ;
140
157
}
141
158
142
159
return {
143
- name : groupName ,
160
+ name : moduleName ,
144
161
packageName : pathSegments [ 0 ] === 'lib' ? 'material' : pathSegments [ 0 ] ,
145
162
entryPointName : pathSegments [ 1 ] ,
146
163
} ;
0 commit comments