Skip to content

docs: create ripples api document #8147

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
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
52 changes: 32 additions & 20 deletions tools/dgeni/processors/component-grouper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {CategorizedClassDoc} from './categorizer';
import {DocCollection, Processor} from 'dgeni';
import {DocCollection, Document, Processor} from 'dgeni';
import * as path from 'path';

/** Component group data structure. */
Expand Down Expand Up @@ -66,24 +66,13 @@ export class ComponentGrouper implements Processor {
const groups = new Map<string, ComponentGroup>();

docs.forEach(doc => {
// Full path to the file for this doc.
const basePath = doc.fileInfo.basePath;
const filePath = doc.fileInfo.filePath;

// All of the component documentation is under either `src/lib` or `src/cdk`.
// We group the docs up by the directory immediately under that root.
let packageName, packageDisplayName;
if (filePath.includes('cdk')) {
packageName = 'cdk';
packageDisplayName = 'CDK';
} else {
packageName = 'material';
packageDisplayName = 'Material';
}
const documentInfo = getDocumentPackageInfo(doc);

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

const moduleImportPath = `@angular/${packageName}/${documentInfo.entryPointName}`;
const groupName = packageName + '-' + documentInfo.name;

// Get the group for this doc, or, if one does not exist, create it.
let group;
Expand All @@ -94,9 +83,8 @@ export class ComponentGrouper implements Processor {
groups.set(groupName, group);
}

group.displayName = displayName;
group.displayName = documentInfo.name;
group.moduleImportPath = moduleImportPath;

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

Expand All @@ -115,3 +103,27 @@ export class ComponentGrouper implements Processor {
return Array.from(groups.values());
}
}

/** Resolves package information for the given Dgeni document. */
function getDocumentPackageInfo(doc: Document) {
// Full path to the file for this doc.
const basePath = doc.fileInfo.basePath;
const filePath = doc.fileInfo.filePath;

// All of the component documentation is under either `src/lib` or `src/cdk`.
// We group the docs up by the directory immediately under that root.
const pathSegments = path.relative(basePath, filePath).split(path.sep);
let groupName = pathSegments[1];

// For the ripples there should be a component group in the docs. Even it's not a
// secondary-entry point it can be still documented with its own `material-ripple.html` file.
if (pathSegments[1] === 'core' && pathSegments[2] === 'ripple') {
groupName = 'ripple';
}

return {
name: groupName,
packageName: pathSegments[0] === 'lib' ? 'material' : pathSegments[0],
entryPointName: pathSegments[1],
};
}