2017-04-21 08:10:52 -04:00
|
|
|
/**
|
|
|
|
* @license
|
|
|
|
* Copyright Google Inc. All Rights Reserved.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
const Package = require('dgeni').Package;
|
|
|
|
|
|
|
|
const basePackage = require('../angular-base-package');
|
|
|
|
const typeScriptPackage = require('dgeni-packages/typescript');
|
2017-05-02 09:12:21 -04:00
|
|
|
const { API_SOURCE_PATH, API_TEMPLATES_PATH, requireFolder } = require('../config');
|
2017-04-21 08:10:52 -04:00
|
|
|
|
|
|
|
module.exports = new Package('angular-api', [basePackage, typeScriptPackage])
|
|
|
|
|
|
|
|
// Register the processors
|
|
|
|
.processor(require('./processors/convertPrivateClassesToInterfaces'))
|
|
|
|
.processor(require('./processors/generateApiListDoc'))
|
|
|
|
.processor(require('./processors/addNotYetDocumentedProperty'))
|
|
|
|
.processor(require('./processors/mergeDecoratorDocs'))
|
|
|
|
.processor(require('./processors/extractDecoratedClasses'))
|
|
|
|
.processor(require('./processors/matchUpDirectiveDecorators'))
|
2017-09-25 15:00:05 -04:00
|
|
|
.processor(require('./processors/addMetadataAliases'))
|
2017-06-29 08:47:58 -04:00
|
|
|
.processor(require('./processors/filterContainedDocs'))
|
2017-04-21 08:10:52 -04:00
|
|
|
.processor(require('./processors/markBarredODocsAsPrivate'))
|
|
|
|
.processor(require('./processors/filterPrivateDocs'))
|
2017-05-03 16:44:30 -04:00
|
|
|
.processor(require('./processors/computeSearchTitle'))
|
2017-07-13 12:07:49 -04:00
|
|
|
.processor(require('./processors/simplifyMemberAnchors'))
|
2017-04-21 08:10:52 -04:00
|
|
|
|
|
|
|
// Where do we get the source files?
|
2017-08-21 14:32:22 -04:00
|
|
|
.config(function(readTypeScriptModules, readFilesProcessor, collectExamples, tsParser) {
|
|
|
|
|
|
|
|
// Tell TypeScript how to load modules that start with with `@angular`
|
|
|
|
tsParser.options.paths = { '@angular/*': [API_SOURCE_PATH + '/*'] };
|
|
|
|
tsParser.options.baseUrl = '.';
|
2017-04-21 08:10:52 -04:00
|
|
|
|
|
|
|
// API files are typescript
|
|
|
|
readTypeScriptModules.basePath = API_SOURCE_PATH;
|
2017-04-24 16:53:36 -04:00
|
|
|
readTypeScriptModules.ignoreExportsMatching = [/^[_ɵ]|^VERSION$/];
|
2017-04-21 08:10:52 -04:00
|
|
|
readTypeScriptModules.hidePrivateMembers = true;
|
2017-12-15 12:58:42 -05:00
|
|
|
|
|
|
|
// NOTE: This list shold be in sync with tools/gulp-tasks/public-api.js
|
2017-04-21 08:10:52 -04:00
|
|
|
readTypeScriptModules.sourceFiles = [
|
2017-04-24 12:23:37 -04:00
|
|
|
'animations/index.ts',
|
|
|
|
'animations/browser/index.ts',
|
|
|
|
'animations/browser/testing/index.ts',
|
2017-07-08 02:23:02 -04:00
|
|
|
'common/http/index.ts',
|
|
|
|
'common/http/testing/index.ts',
|
2017-04-21 08:10:52 -04:00
|
|
|
'common/index.ts',
|
|
|
|
'common/testing/index.ts',
|
|
|
|
'core/index.ts',
|
|
|
|
'core/testing/index.ts',
|
|
|
|
'forms/index.ts',
|
|
|
|
'http/index.ts',
|
|
|
|
'http/testing/index.ts',
|
|
|
|
'platform-browser/index.ts',
|
2017-04-24 12:23:37 -04:00
|
|
|
'platform-browser/animations/index.ts',
|
2017-04-21 08:10:52 -04:00
|
|
|
'platform-browser/testing/index.ts',
|
|
|
|
'platform-browser-dynamic/index.ts',
|
|
|
|
'platform-browser-dynamic/testing/index.ts',
|
|
|
|
'platform-server/index.ts',
|
|
|
|
'platform-server/testing/index.ts',
|
|
|
|
'platform-webworker/index.ts',
|
|
|
|
'platform-webworker-dynamic/index.ts',
|
|
|
|
'router/index.ts',
|
|
|
|
'router/testing/index.ts',
|
2017-04-24 12:23:37 -04:00
|
|
|
'router/upgrade/index.ts',
|
2017-10-23 12:47:49 -04:00
|
|
|
'service-worker/index.ts',
|
2017-04-21 08:10:52 -04:00
|
|
|
'upgrade/index.ts',
|
2017-04-24 12:23:37 -04:00
|
|
|
'upgrade/static/index.ts',
|
2017-04-21 08:10:52 -04:00
|
|
|
];
|
|
|
|
|
|
|
|
// API Examples
|
|
|
|
readFilesProcessor.sourceFiles = [
|
|
|
|
{
|
|
|
|
basePath: API_SOURCE_PATH,
|
|
|
|
include: API_SOURCE_PATH + '/examples/**/*',
|
|
|
|
fileReader: 'exampleFileReader'
|
|
|
|
}
|
|
|
|
];
|
|
|
|
collectExamples.exampleFolders.push('examples');
|
|
|
|
})
|
|
|
|
|
|
|
|
// Configure jsdoc-style tag parsing
|
|
|
|
.config(function(parseTagsProcessor, getInjectables) {
|
|
|
|
// Load up all the tag definitions in the tag-defs folder
|
|
|
|
parseTagsProcessor.tagDefinitions =
|
|
|
|
parseTagsProcessor.tagDefinitions.concat(getInjectables(requireFolder(__dirname, './tag-defs')));
|
|
|
|
|
|
|
|
// We actually don't want to parse param docs in this package as we are getting the data out using TS
|
|
|
|
// TODO: rewire the param docs to the params extracted from TS
|
|
|
|
parseTagsProcessor.tagDefinitions.forEach(function(tagDef) {
|
|
|
|
if (tagDef.name === 'param') {
|
|
|
|
tagDef.docProperty = 'paramData';
|
|
|
|
tagDef.transforms = [];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
.config(function(computePathsProcessor, EXPORT_DOC_TYPES, generateApiListDoc) {
|
|
|
|
|
|
|
|
const API_SEGMENT = 'api';
|
|
|
|
|
|
|
|
generateApiListDoc.outputFolder = API_SEGMENT;
|
|
|
|
|
|
|
|
computePathsProcessor.pathTemplates.push({
|
|
|
|
docTypes: ['module'],
|
|
|
|
getPath: function computeModulePath(doc) {
|
|
|
|
doc.moduleFolder = `${API_SEGMENT}/${doc.id.replace(/\/index$/, '')}`;
|
|
|
|
return doc.moduleFolder;
|
|
|
|
},
|
|
|
|
outputPathTemplate: '${moduleFolder}.json'
|
|
|
|
});
|
|
|
|
computePathsProcessor.pathTemplates.push({
|
|
|
|
docTypes: EXPORT_DOC_TYPES.concat(['decorator', 'directive', 'pipe']),
|
|
|
|
pathTemplate: '${moduleDoc.moduleFolder}/${name}',
|
|
|
|
outputPathTemplate: '${moduleDoc.moduleFolder}/${name}.json',
|
|
|
|
});
|
|
|
|
})
|
|
|
|
|
2017-05-02 09:12:21 -04:00
|
|
|
.config(function(templateFinder) {
|
|
|
|
// Where to find the templates for the API doc rendering
|
|
|
|
templateFinder.templateFolders.unshift(API_TEMPLATES_PATH);
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2017-05-10 13:34:19 -04:00
|
|
|
.config(function(convertToJsonProcessor, postProcessHtml, EXPORT_DOC_TYPES, autoLinkCode) {
|
2017-04-21 08:10:52 -04:00
|
|
|
const DOCS_TO_CONVERT = EXPORT_DOC_TYPES.concat([
|
|
|
|
'decorator', 'directive', 'pipe', 'module'
|
|
|
|
]);
|
|
|
|
convertToJsonProcessor.docTypes = convertToJsonProcessor.docTypes.concat(DOCS_TO_CONVERT);
|
2017-04-27 09:04:51 -04:00
|
|
|
postProcessHtml.docTypes = convertToJsonProcessor.docTypes.concat(DOCS_TO_CONVERT);
|
2017-05-10 13:34:19 -04:00
|
|
|
autoLinkCode.docTypes = DOCS_TO_CONVERT;
|
2017-09-09 04:15:08 -04:00
|
|
|
autoLinkCode.codeElements = ['code', 'code-example', 'code-pane'];
|
2017-04-21 08:10:52 -04:00
|
|
|
});
|