Skip to content

docs: proper module import name #8105

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Oct 30, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions tools/dgeni/processors/component-grouper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ export class ComponentGroup {
/** Display name of the component group */
displayName: string;

/** Module import path for the component group. */
moduleImportPath: string;

/** Name of the package, either material or cdk */
packageName: string;

Expand Down Expand Up @@ -60,7 +63,7 @@ export class ComponentGrouper implements Processor {

$process(docs: DocCollection) {
// Map of group name to group instance.
const groups = new Map();
const groups = new Map<string, ComponentGroup>();

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

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

// Get the group for this doc, or, if one does not exist, create it.
let group;
if (groups.has(groupName)) {
group = groups.get(groupName);
group = groups.get(groupName)!;
} else {
group = new ComponentGroup(groupName);
groups.set(groupName, group);
}

group.displayName = displayName;
group.moduleImportPath = moduleImportPath;

group.packageName = packageName;
group.packageDisplayName = packageDisplayName;
group.displayName = displayName;

// Put this doc into the appropriate list in this group.
if (doc.isDirective) {
Expand Down
2 changes: 1 addition & 1 deletion tools/dgeni/templates/componentGroup.template.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ <h2>

<p class="docs-api-module-import">
<code>
import {{$ doc.ngModule.name $}} from '@angular/{$ doc.packageName $}';
import {{$ doc.ngModule.name $}} from '{$ doc.moduleImportPath $}';
</code>
</p>

Expand Down