| 
									
										
										
										
											2015-02-26 15:38:12 -08:00
										 |  |  | require('../../tools/transpiler/index.js').init(); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | var Package = require('dgeni').Package; | 
					
						
							|  |  |  | var jsdocPackage = require('dgeni-packages/jsdoc'); | 
					
						
							|  |  |  | var nunjucksPackage = require('dgeni-packages/nunjucks'); | 
					
						
							|  |  |  | 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
 | 
					
						
							|  |  |  | module.exports = new Package('angular', [jsdocPackage, nunjucksPackage]) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Register the services and file readers
 | 
					
						
							| 
									
										
										
										
											2015-03-17 16:41:54 +00:00
										 |  |  | .factory(require('./services/modules')) | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | .factory(require('./services/atParser')) | 
					
						
							|  |  |  | .factory(require('./services/getJSDocComment')) | 
					
						
							| 
									
										
										
										
											2014-12-06 11:25:17 +00:00
										 |  |  | .factory(require('./services/SourceFile')) | 
					
						
							|  |  |  | .factory(require('./services/TraceurParser')) | 
					
						
							|  |  |  | .factory(require('./services/traceurOptions')) | 
					
						
							|  |  |  | .factory(require('./services/ParseTreeVisitor')) | 
					
						
							|  |  |  | .factory(require('./services/AttachCommentTreeVisitor')) | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | .factory(require('./services/ExportTreeVisitor')) | 
					
						
							| 
									
										
										
										
											2014-12-06 11:25:17 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | .factory(require('./readers/atScript')) | 
					
						
							|  |  |  | .factory(require('./readers/ngdoc')) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-19 14:48:47 +00:00
										 |  |  | .factory('EXPORT_DOC_TYPES', function() { | 
					
						
							|  |  |  |   return [ | 
					
						
							|  |  |  |     'class', | 
					
						
							|  |  |  |     'function', | 
					
						
							|  |  |  |     'var', | 
					
						
							|  |  |  |     'const' | 
					
						
							|  |  |  |   ]; | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Register the processors
 | 
					
						
							| 
									
										
										
										
											2015-04-10 12:45:02 +02:00
										 |  |  | .processor(require('./processors/captureModuleExports')) | 
					
						
							|  |  |  | .processor(require('./processors/captureClassMembers')) | 
					
						
							|  |  |  | .processor(require('./processors/captureModuleDocs')) | 
					
						
							|  |  |  | .processor(require('./processors/attachModuleDocs')) | 
					
						
							|  |  |  | .processor(require('./processors/cloneExportedFromDocs')) | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | .processor(require('./processors/generateNavigationDoc')) | 
					
						
							| 
									
										
										
										
											2015-02-17 08:08:24 +00:00
										 |  |  | .processor(require('./processors/extractTitleFromGuides')) | 
					
						
							| 
									
										
										
										
											2015-03-31 22:12:34 +01:00
										 |  |  | .processor(require('./processors/createOverviewDump')) | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-10 12:45:02 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | // Configure the log service
 | 
					
						
							|  |  |  | .config(function(log) { | 
					
						
							| 
									
										
										
										
											2015-03-26 09:20:43 +01:00
										 |  |  |   log.level = 'warning'; | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | // Configure file reading
 | 
					
						
							|  |  |  | .config(function(readFilesProcessor, atScriptFileReader, ngdocFileReader) { | 
					
						
							|  |  |  |   readFilesProcessor.fileReaders = [atScriptFileReader, ngdocFileReader]; | 
					
						
							|  |  |  |   readFilesProcessor.basePath = path.resolve(__dirname, '../..'); | 
					
						
							|  |  |  |   readFilesProcessor.sourceFiles = [ | 
					
						
							| 
									
										
										
										
											2015-03-17 16:41:54 +00:00
										 |  |  |     { include: 'modules/*/*.js', basePath: 'modules' }, | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  |     { include: 'modules/*/src/**/*.js', basePath: 'modules' }, | 
					
						
							|  |  |  |     { include: 'modules/*/docs/**/*.md', basePath: 'modules' }, | 
					
						
							|  |  |  |     { include: 'docs/content/**/*.md', basePath: 'docs/content' } | 
					
						
							|  |  |  |   ]; | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-10 12:45:02 +02:00
										 |  |  | .config(function(parseTagsProcessor, getInjectables) { | 
					
						
							|  |  |  |   parseTagsProcessor.tagDefinitions.push(require('./tag-defs/public')); | 
					
						
							| 
									
										
										
										
											2015-04-14 20:24:07 +01:00
										 |  |  |   parseTagsProcessor.tagDefinitions.push(require('./tag-defs/private')); | 
					
						
							| 
									
										
										
										
											2015-04-10 12:45:02 +02:00
										 |  |  |   parseTagsProcessor.tagDefinitions.push(require('./tag-defs/exportedAs')); | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | // Configure file writing
 | 
					
						
							|  |  |  | .config(function(writeFilesProcessor) { | 
					
						
							| 
									
										
										
										
											2014-12-05 16:26:30 -08:00
										 |  |  |   writeFilesProcessor.outputFolder  = 'dist/docs'; | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00: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 14:48:47 +00:00
										 |  |  | .config(function(computeIdsProcessor, computePathsProcessor, EXPORT_DOC_TYPES) { | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  |   computeIdsProcessor.idTemplates.push({ | 
					
						
							| 
									
										
										
										
											2015-03-19 14:48:47 +00:00
										 |  |  |     docTypes: EXPORT_DOC_TYPES, | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  |     idTemplate: '${moduleDoc.id}.${name}', | 
					
						
							| 
									
										
										
										
											2015-04-17 13:50:04 +01:00
										 |  |  |     getAliases: function(doc) { return [doc.id, doc.name]; } | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00: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'], | 
					
						
							|  |  |  |     pathTemplate: '${id}', | 
					
						
							|  |  |  |     outputPathTemplate: MODULES_DOCS_PATH + '/${id}/index.html' | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   computePathsProcessor.pathTemplates.push({ | 
					
						
							| 
									
										
										
										
											2015-03-19 14:48:47 +00:00
										 |  |  |     docTypes: EXPORT_DOC_TYPES, | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00: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'], | 
					
						
							|  |  |  |     pathTemplate: '${id}', | 
					
						
							|  |  |  |     outputPathTemplate: GUIDES_PATH + '/${id}.html' | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-03-26 09:20:43 +01:00
										 |  |  | }); |