2014-12-04 09:02:03 -05:00
|
|
|
var Package = require('dgeni').Package;
|
|
|
|
var jsdocPackage = require('dgeni-packages/jsdoc');
|
|
|
|
var nunjucksPackage = require('dgeni-packages/nunjucks');
|
2015-07-11 02:21:21 -04:00
|
|
|
var typescriptPackage = require('../typescript-package');
|
2015-05-15 08:57:38 -04:00
|
|
|
var linksPackage = require('../links-package');
|
2015-06-09 15:07:09 -04:00
|
|
|
var gitPackage = require('dgeni-packages/git');
|
2014-12-04 09:02:03 -05:00
|
|
|
var path = require('canonical-path');
|
|
|
|
|
|
|
|
// Define the dgeni package for generating the docs
|
2015-07-11 02:21:21 -04:00
|
|
|
module.exports = new Package('angular-v2-docs', [jsdocPackage, nunjucksPackage, typescriptPackage, linksPackage, gitPackage])
|
2014-12-04 09:02:03 -05:00
|
|
|
|
|
|
|
// Register the services and file readers
|
|
|
|
.factory(require('./readers/ngdoc'))
|
|
|
|
|
|
|
|
// Register the processors
|
2015-09-04 14:01:26 -04:00
|
|
|
.processor(require('./processors/convertPrivateClassesToInterfaces'))
|
2014-12-04 09:02:03 -05:00
|
|
|
.processor(require('./processors/generateNavigationDoc'))
|
2015-02-17 03:08:24 -05:00
|
|
|
.processor(require('./processors/extractTitleFromGuides'))
|
2015-03-31 17:12:34 -04:00
|
|
|
.processor(require('./processors/createOverviewDump'))
|
2015-07-23 04:35:03 -04:00
|
|
|
.processor(require('./processors/checkUnbalancedBackTicks'))
|
2015-04-10 06:45:02 -04:00
|
|
|
|
2014-12-04 09:02:03 -05:00
|
|
|
// Configure the log service
|
|
|
|
.config(function(log) {
|
2015-05-07 05:26:23 -04:00
|
|
|
log.level = 'warn';
|
2014-12-04 09:02:03 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
|
2015-06-09 15:07:09 -04:00
|
|
|
.config(function(renderDocsProcessor, versionInfo) {
|
2015-05-19 17:29:34 -04:00
|
|
|
renderDocsProcessor.extraData.versionInfo = versionInfo;
|
|
|
|
})
|
|
|
|
|
2014-12-04 09:02:03 -05:00
|
|
|
// Configure file reading
|
2015-05-15 08:57:38 -04:00
|
|
|
.config(function(readFilesProcessor, ngdocFileReader, readTypeScriptModules) {
|
2015-05-15 08:57:38 -04:00
|
|
|
readFilesProcessor.fileReaders = [ngdocFileReader];
|
2014-12-04 09:02:03 -05:00
|
|
|
readFilesProcessor.basePath = path.resolve(__dirname, '../..');
|
|
|
|
readFilesProcessor.sourceFiles = [
|
|
|
|
{ include: 'modules/*/docs/**/*.md', basePath: 'modules' },
|
|
|
|
{ include: 'docs/content/**/*.md', basePath: 'docs/content' }
|
|
|
|
];
|
2015-05-15 08:57:38 -04:00
|
|
|
|
|
|
|
readTypeScriptModules.sourceFiles = [
|
2015-05-29 20:13:01 -04:00
|
|
|
'*/*.@(js|es6|ts)',
|
2015-05-15 11:47:05 -04:00
|
|
|
'*/src/**/*.@(js|es6|ts)'
|
2015-05-15 08:57:38 -04:00
|
|
|
];
|
2015-07-11 02:21:21 -04:00
|
|
|
readTypeScriptModules.basePath = path.resolve(readFilesProcessor.basePath, 'modules');
|
2014-12-04 09:02:03 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
|
2015-04-10 06:45:02 -04:00
|
|
|
.config(function(parseTagsProcessor, getInjectables) {
|
2015-05-15 08:57:38 -04:00
|
|
|
// We actually don't want to parse param docs in this package as we are getting the data out using TS
|
|
|
|
parseTagsProcessor.tagDefinitions.forEach(function(tagDef) {
|
|
|
|
if (tagDef.name === 'param') {
|
2015-06-19 08:56:49 -04:00
|
|
|
tagDef.docProperty = 'paramData';
|
|
|
|
tagDef.transforms = [];
|
2015-05-15 08:57:38 -04:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2015-04-10 06:45:02 -04:00
|
|
|
})
|
|
|
|
|
|
|
|
|
2015-05-15 08:57:38 -04:00
|
|
|
// Configure links
|
|
|
|
.config(function(getLinkInfo) {
|
|
|
|
getLinkInfo.useFirstAmbiguousLink = true;
|
|
|
|
})
|
|
|
|
|
|
|
|
|
2014-12-04 09:02:03 -05:00
|
|
|
// Configure file writing
|
|
|
|
.config(function(writeFilesProcessor) {
|
2014-12-05 19:26:30 -05:00
|
|
|
writeFilesProcessor.outputFolder = 'dist/docs';
|
2014-12-04 09:02:03 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Configure rendering
|
|
|
|
.config(function(templateFinder, templateEngine) {
|
|
|
|
|
|
|
|
// Nunjucks and Angular conflict in their template bindings so change Nunjucks
|
|
|
|
templateEngine.config.tags = {
|
|
|
|
variableStart: '{$',
|
|
|
|
variableEnd: '$}'
|
|
|
|
};
|
|
|
|
|
|
|
|
templateFinder.templateFolders
|
|
|
|
.unshift(path.resolve(__dirname, 'templates'));
|
|
|
|
|
|
|
|
templateFinder.templatePatterns = [
|
|
|
|
'${ doc.template }',
|
|
|
|
'${ doc.id }.${ doc.docType }.template.html',
|
|
|
|
'${ doc.id }.template.html',
|
|
|
|
'${ doc.docType }.template.html',
|
|
|
|
'common.template.html'
|
|
|
|
];
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
// Configure ids and paths
|
2015-07-11 02:21:21 -04:00
|
|
|
.config(function(computeIdsProcessor, computePathsProcessor) {
|
2014-12-04 09:02:03 -05:00
|
|
|
|
|
|
|
computeIdsProcessor.idTemplates.push({
|
|
|
|
docTypes: ['guide'],
|
|
|
|
getId: function(doc) {
|
|
|
|
return doc.fileInfo.relativePath
|
|
|
|
// path should be relative to `modules` folder
|
|
|
|
.replace(/.*\/?modules\//, '')
|
|
|
|
// path should not include `/docs/`
|
|
|
|
.replace(/\/docs\//, '/')
|
|
|
|
// path should not have a suffix
|
|
|
|
.replace(/\.\w*$/, '');
|
|
|
|
},
|
|
|
|
getAliases: function(doc) { return [doc.id]; }
|
|
|
|
});
|
|
|
|
|
|
|
|
computePathsProcessor.pathTemplates.push({
|
|
|
|
docTypes: ['guide'],
|
2015-05-15 08:57:38 -04:00
|
|
|
pathTemplate: '/${id}',
|
2015-07-11 02:21:21 -04:00
|
|
|
outputPathTemplate: 'partials/guides/${id}.html'
|
2014-12-04 09:02:03 -05:00
|
|
|
});
|
2015-03-26 04:20:43 -04:00
|
|
|
});
|