Skip to content

Commit bffe5f5

Browse files
devversionmmalerba
authored andcommitted
docs: proper module import name (#8105)
* No longer shows import paths for the CDK without the secondary-entry point. Those imports are not valid and for the CDK its required to specify a secondary-entry point.
1 parent 8d74d67 commit bffe5f5

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

tools/dgeni/processors/component-grouper.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ export class ComponentGroup {
1111
/** Display name of the component group */
1212
displayName: string;
1313

14+
/** Module import path for the component group. */
15+
moduleImportPath: string;
16+
1417
/** Name of the package, either material or cdk */
1518
packageName: string;
1619

@@ -60,7 +63,7 @@ export class ComponentGrouper implements Processor {
6063

6164
$process(docs: DocCollection) {
6265
// Map of group name to group instance.
63-
const groups = new Map();
66+
const groups = new Map<string, ComponentGroup>();
6467

6568
docs.forEach(doc => {
6669
// Full path to the file for this doc.
@@ -79,20 +82,23 @@ export class ComponentGrouper implements Processor {
7982
}
8083

8184
const displayName = path.relative(basePath, filePath).split(path.sep)[1];
85+
const moduleImportPath = `@angular/${packageName}/${displayName}`;
8286
const groupName = packageName + '-' + displayName;
8387

8488
// Get the group for this doc, or, if one does not exist, create it.
8589
let group;
8690
if (groups.has(groupName)) {
87-
group = groups.get(groupName);
91+
group = groups.get(groupName)!;
8892
} else {
8993
group = new ComponentGroup(groupName);
9094
groups.set(groupName, group);
9195
}
9296

97+
group.displayName = displayName;
98+
group.moduleImportPath = moduleImportPath;
99+
93100
group.packageName = packageName;
94101
group.packageDisplayName = packageDisplayName;
95-
group.displayName = displayName;
96102

97103
// Put this doc into the appropriate list in this group.
98104
if (doc.isDirective) {

tools/dgeni/templates/componentGroup.template.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ <h2>
2626

2727
<p class="docs-api-module-import">
2828
<code>
29-
import {{$ doc.ngModule.name $}} from '@angular/{$ doc.packageName $}';
29+
import {{$ doc.ngModule.name $}} from '{$ doc.moduleImportPath $}';
3030
</code>
3131
</p>
3232

0 commit comments

Comments
 (0)