| 
									
										
										
										
											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'); | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01:00
										 |  |  | var linksPackage = require('../links-package'); | 
					
						
							| 
									
										
										
										
											2015-06-09 12:07:09 -07:00
										 |  |  | var gitPackage = require('dgeni-packages/git'); | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00: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-06-09 12:07:09 -07:00
										 |  |  | module.exports = new Package('angular', [jsdocPackage, nunjucksPackage, linksPackage, gitPackage]) | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Register the services and file readers
 | 
					
						
							| 
									
										
										
										
											2015-03-17 16:41:54 +00:00
										 |  |  | .factory(require('./services/modules')) | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01: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 14:02:03 +00:00
										 |  |  | .factory(require('./readers/ngdoc')) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-03-19 14:48:47 +00:00
										 |  |  | .factory('EXPORT_DOC_TYPES', function() { | 
					
						
							|  |  |  |   return [ | 
					
						
							|  |  |  |     'class', | 
					
						
							| 
									
										
										
										
											2015-05-19 12:54:01 +01:00
										 |  |  |     'interface', | 
					
						
							| 
									
										
										
										
											2015-03-19 14:48:47 +00:00
										 |  |  |     'function', | 
					
						
							|  |  |  |     'var', | 
					
						
							| 
									
										
										
										
											2015-06-12 20:59:27 +01:00
										 |  |  |     'const', | 
					
						
							| 
									
										
										
										
											2015-06-30 18:10:14 -07:00
										 |  |  |     'enum', | 
					
						
							|  |  |  |     'type-alias' | 
					
						
							| 
									
										
										
										
											2015-03-19 14:48:47 +00:00
										 |  |  |   ]; | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | 
 | 
					
						
							|  |  |  | // Register the processors
 | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01:00
										 |  |  | .processor(require('./processors/readTypeScriptModules')) | 
					
						
							| 
									
										
										
										
											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')) | 
					
						
							| 
									
										
										
										
											2015-05-20 12:20:15 +01:00
										 |  |  | .processor(require('./processors/createTypeDefinitionFile')) | 
					
						
							| 
									
										
										
										
											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-05-07 10:26:23 +01:00
										 |  |  |   log.level = 'warn'; | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-06-09 12:07:09 -07:00
										 |  |  | .config(function(renderDocsProcessor, versionInfo) { | 
					
						
							| 
									
										
										
										
											2015-05-19 22:29:34 +01:00
										 |  |  |   renderDocsProcessor.extraData.versionInfo = versionInfo; | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | // Configure file reading
 | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01:00
										 |  |  | .config(function(readFilesProcessor, ngdocFileReader, readTypeScriptModules) { | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01:00
										 |  |  |   readFilesProcessor.fileReaders = [ngdocFileReader]; | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  |   readFilesProcessor.basePath = path.resolve(__dirname, '../..'); | 
					
						
							|  |  |  |   readFilesProcessor.sourceFiles = [ | 
					
						
							|  |  |  |     { include: 'modules/*/docs/**/*.md', basePath: 'modules' }, | 
					
						
							|  |  |  |     { include: 'docs/content/**/*.md', basePath: 'docs/content' } | 
					
						
							|  |  |  |   ]; | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01:00
										 |  |  | 
 | 
					
						
							|  |  |  |   readTypeScriptModules.sourceFiles = [ | 
					
						
							| 
									
										
										
										
											2015-05-29 17:13:01 -07:00
										 |  |  |     '*/*.@(js|es6|ts)', | 
					
						
							| 
									
										
										
										
											2015-05-15 16:47:05 +01:00
										 |  |  |     '*/src/**/*.@(js|es6|ts)' | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01:00
										 |  |  |   ]; | 
					
						
							|  |  |  |   readTypeScriptModules.basePath = 'modules'; | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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')); | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01: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 13:56:49 +01:00
										 |  |  |       tagDef.docProperty = 'paramData'; | 
					
						
							|  |  |  |       tagDef.transforms = []; | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01:00
										 |  |  |     } | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-04-10 12:45:02 +02:00
										 |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01:00
										 |  |  | // Configure links
 | 
					
						
							|  |  |  | .config(function(getLinkInfo) { | 
					
						
							|  |  |  |   getLinkInfo.useFirstAmbiguousLink = true; | 
					
						
							|  |  |  | }) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											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({ | 
					
						
							|  |  |  |     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 13:57:38 +01:00
										 |  |  |     pathTemplate: '/${id}', | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  |     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'], | 
					
						
							| 
									
										
										
										
											2015-05-15 13:57:38 +01:00
										 |  |  |     pathTemplate: '/${id}', | 
					
						
							| 
									
										
										
										
											2014-12-04 14:02:03 +00:00
										 |  |  |     outputPathTemplate: GUIDES_PATH + '/${id}.html' | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-03-26 09:20:43 +01:00
										 |  |  | }); |