2015-02-26 18:38:12 -05:00
|
|
|
require('../../tools/transpiler/index.js').init();
|
|
|
|
|
2015-05-19 17:29:34 -04:00
|
|
|
var versionInfo = require('./versionInfo');
|
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-05-15 08:57:38 -04:00
|
|
|
var linksPackage = require('../links-package');
|
2014-12-04 09:02:03 -05:00
|
|
|
var path = require('canonical-path');
|
|
|
|
|
|
|
|
var PARTIAL_PATH = 'partials';
|
|
|
|
var MODULES_DOCS_PATH = PARTIAL_PATH + '/modules';
|
|
|
|
var GUIDES_PATH = PARTIAL_PATH + '/guides';
|
|
|
|
|
|
|
|
// Define the dgeni package for generating the docs
|
2015-05-15 08:57:38 -04:00
|
|
|
module.exports = new Package('angular', [jsdocPackage, nunjucksPackage, linksPackage])
|
2014-12-04 09:02:03 -05:00
|
|
|
|
|
|
|
// Register the services and file readers
|
2015-03-17 12:41:54 -04:00
|
|
|
.factory(require('./services/modules'))
|
2015-05-15 08:57:38 -04:00
|
|
|
.factory(require('./services/tsParser'))
|
|
|
|
.factory(require('./services/tsParser/createCompilerHost'))
|
|
|
|
.factory(require('./services/tsParser/getFileInfo'))
|
|
|
|
.factory(require('./services/tsParser/getExportDocType'))
|
|
|
|
.factory(require('./services/tsParser/getContent'))
|
2014-12-04 09:02:03 -05:00
|
|
|
.factory(require('./readers/ngdoc'))
|
|
|
|
|
2015-03-19 10:48:47 -04:00
|
|
|
.factory('EXPORT_DOC_TYPES', function() {
|
|
|
|
return [
|
|
|
|
'class',
|
2015-05-19 07:54:01 -04:00
|
|
|
'interface',
|
2015-03-19 10:48:47 -04:00
|
|
|
'function',
|
|
|
|
'var',
|
|
|
|
'const'
|
|
|
|
];
|
|
|
|
})
|
|
|
|
|
2014-12-04 09:02:03 -05:00
|
|
|
|
|
|
|
// Register the processors
|
2015-05-15 08:57:38 -04:00
|
|
|
.processor(require('./processors/readTypeScriptModules'))
|
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-05-20 07:20:15 -04:00
|
|
|
.processor(require('./processors/createTypeDefinitionFile'))
|
2014-12-04 09:02:03 -05:00
|
|
|
|
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-05-19 17:29:34 -04:00
|
|
|
.config(function(renderDocsProcessor) {
|
|
|
|
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
|
|
|
];
|
|
|
|
readTypeScriptModules.basePath = 'modules';
|
2014-12-04 09:02:03 -05:00
|
|
|
})
|
|
|
|
|
|
|
|
|
2015-04-10 06:45:02 -04:00
|
|
|
.config(function(parseTagsProcessor, getInjectables) {
|
|
|
|
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/public'));
|
2015-04-14 15:24:07 -04:00
|
|
|
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/private'));
|
2015-04-10 06:45:02 -04:00
|
|
|
parseTagsProcessor.tagDefinitions.push(require('./tag-defs/exportedAs'));
|
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') {
|
|
|
|
tagDef.ignore = true;
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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-03-19 10:48:47 -04:00
|
|
|
.config(function(computeIdsProcessor, computePathsProcessor, EXPORT_DOC_TYPES) {
|
2014-12-04 09:02:03 -05:00
|
|
|
|
|
|
|
computeIdsProcessor.idTemplates.push({
|
|
|
|
docTypes: ['member'],
|
|
|
|
idTemplate: '${classDoc.id}.${name}',
|
|
|
|
getAliases: function(doc) { return [doc.id]; }
|
|
|
|
});
|
|
|
|
|
|
|
|
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: ['module'],
|
2015-05-15 08:57:38 -04:00
|
|
|
pathTemplate: '/${id}',
|
2014-12-04 09:02:03 -05:00
|
|
|
outputPathTemplate: MODULES_DOCS_PATH + '/${id}/index.html'
|
|
|
|
});
|
|
|
|
|
|
|
|
computePathsProcessor.pathTemplates.push({
|
2015-03-19 10:48:47 -04:00
|
|
|
docTypes: EXPORT_DOC_TYPES,
|
2014-12-04 09:02:03 -05:00
|
|
|
pathTemplate: '${moduleDoc.path}/${name}',
|
|
|
|
outputPathTemplate: MODULES_DOCS_PATH + '/${path}/index.html'
|
|
|
|
});
|
|
|
|
|
|
|
|
computePathsProcessor.pathTemplates.push({
|
|
|
|
docTypes: ['member'],
|
|
|
|
pathTemplate: '${classDoc.path}/${name}',
|
|
|
|
getOutputPath: function() {} // These docs are not written to their own file, instead they are part of their class doc
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
computePathsProcessor.pathTemplates.push({
|
|
|
|
docTypes: ['guide'],
|
2015-05-15 08:57:38 -04:00
|
|
|
pathTemplate: '/${id}',
|
2014-12-04 09:02:03 -05:00
|
|
|
outputPathTemplate: GUIDES_PATH + '/${id}.html'
|
|
|
|
});
|
2015-03-26 04:20:43 -04:00
|
|
|
});
|