2015-09-16 02:21:55 -04:00
|
|
|
var Package = require('dgeni').Package;
|
|
|
|
var jsdocPackage = require('dgeni-packages/jsdoc');
|
|
|
|
var nunjucksPackage = require('dgeni-packages/nunjucks');
|
|
|
|
var typescriptPackage = require('../typescript-package');
|
|
|
|
var linksPackage = require('../links-package');
|
|
|
|
var gitPackage = require('dgeni-packages/git');
|
|
|
|
var path = require('canonical-path');
|
|
|
|
var fs = require('fs');
|
|
|
|
|
|
|
|
// Define the dgeni package for generating the docs
|
|
|
|
module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage, gitPackage])
|
|
|
|
|
|
|
|
// Register the processors
|
|
|
|
.processor(require('./processors/convertPrivateClassesToInterfaces'))
|
2015-09-30 04:13:23 -04:00
|
|
|
.processor(require('./processors/extractDirectiveClasses'))
|
2015-09-16 02:21:55 -04:00
|
|
|
.processor(require('./processors/generateNavigationDoc'))
|
|
|
|
.processor(require('./processors/extractTitleFromGuides'))
|
|
|
|
.processor(require('./processors/createOverviewDump'))
|
|
|
|
.processor(require('./processors/checkUnbalancedBackTicks'))
|
2015-10-29 03:23:21 -04:00
|
|
|
.processor(require('./processors/convertBackticksToCodeBlocks'))
|
2015-11-13 11:34:57 -05:00
|
|
|
.processor(require('./processors/addNotYetDocumentedProperty'))
|
2015-09-16 02:21:55 -04:00
|
|
|
|
|
|
|
// Configure the log service
|
|
|
|
.config(function(log) {
|
|
|
|
log.level = 'info';
|
|
|
|
})
|
|
|
|
|
2015-10-02 17:44:57 -04:00
|
|
|
.config(function(parseTagsProcessor) {
|
|
|
|
parseTagsProcessor.tagDefinitions.push({ name: 'internal', transforms: function() { return true; } });
|
2015-11-13 04:47:38 -05:00
|
|
|
parseTagsProcessor.tagDefinitions.push({ name: 'syntax' });
|
2015-11-13 07:45:00 -05:00
|
|
|
parseTagsProcessor.tagDefinitions.push({ name: 'noDescription', transforms: function() { return true; } });
|
2015-10-02 17:44:57 -04:00
|
|
|
})
|
2015-09-16 02:21:55 -04:00
|
|
|
|
|
|
|
.config(function(renderDocsProcessor, versionInfo) {
|
|
|
|
renderDocsProcessor.extraData.versionInfo = versionInfo;
|
|
|
|
})
|
|
|
|
|
|
|
|
// Configure file reading
|
2015-11-05 07:32:45 -05:00
|
|
|
.config(function(readTypeScriptModules) {
|
|
|
|
|
2015-09-16 02:21:55 -04:00
|
|
|
var angular_repo_path = path.resolve(__dirname, '../../../../angular');
|
2015-09-18 22:51:10 -04:00
|
|
|
// confirm that the angular repo is actually there.
|
2015-09-16 02:21:55 -04:00
|
|
|
if (!fs.existsSync(angular_repo_path)) {
|
|
|
|
throw new Error('build-api-docs task requires the angular2 repo to be at ' + angular_repo_path);
|
|
|
|
}
|
|
|
|
readTypeScriptModules.sourceFiles = [
|
|
|
|
'*/*.@(js|es6|ts)',
|
|
|
|
'*/src/**/*.@(js|es6|ts)'
|
|
|
|
];
|
2015-11-03 06:30:46 -05:00
|
|
|
readTypeScriptModules.basePath = path.resolve(angular_repo_path, 'modules');
|
2015-09-16 02:21:55 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
.config(function(parseTagsProcessor, getInjectables) {
|
|
|
|
// We actually don't want to parse param docs in this package as we are getting the data out using TS
|
2015-11-05 07:32:45 -05:00
|
|
|
// TODO: rewire the param docs to the params extracted from TS
|
2015-09-16 02:21:55 -04:00
|
|
|
parseTagsProcessor.tagDefinitions.forEach(function(tagDef) {
|
|
|
|
if (tagDef.name === 'param') {
|
|
|
|
tagDef.docProperty = 'paramData';
|
|
|
|
tagDef.transforms = [];
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Configure links
|
|
|
|
.config(function(getLinkInfo) {
|
|
|
|
getLinkInfo.useFirstAmbiguousLink = true;
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Configure file writing
|
|
|
|
.config(function(writeFilesProcessor) {
|
|
|
|
writeFilesProcessor.outputFolder = 'dist/docs';
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Configure rendering
|
|
|
|
.config(function(templateFinder, templateEngine) {
|
|
|
|
|
|
|
|
// Nunjucks and Angular conflict in their template bindings so change Nunjucks
|
|
|
|
templateEngine.config.tags = {
|
|
|
|
variableStart: '{$',
|
|
|
|
variableEnd: '$}'
|
|
|
|
};
|
|
|
|
|
|
|
|
templateFinder.templatePatterns = [
|
|
|
|
'${ doc.template }',
|
|
|
|
'${ doc.id }.${ doc.docType }.template.html',
|
|
|
|
'${ doc.id }.template.html',
|
|
|
|
'${ doc.docType }.template.html',
|
|
|
|
'common.template.html'
|
|
|
|
];
|
2015-11-05 07:32:45 -05:00
|
|
|
});
|