| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | // Canonical path provides a consistent path (i.e. always forward slashes) across different OSes
 | 
					
						
							|  |  |  | var path = require('canonical-path'); | 
					
						
							| 
									
										
										
										
											2015-08-08 13:55:53 -07:00
										 |  |  | var Q = require('q'); | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | var del = require('del'); | 
					
						
							| 
									
										
										
										
											2015-08-08 13:55:53 -07:00
										 |  |  | // delPromise is a 'promise' version of del
 | 
					
						
							|  |  |  | var delPromise =  Q.denodeify(del); | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | var Dgeni = require('dgeni'); | 
					
						
							|  |  |  | var _ = require('lodash'); | 
					
						
							| 
									
										
										
										
											2015-12-09 23:56:24 -08:00
										 |  |  | var globby = require('globby'); | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | var shred = function(shredOptions) { | 
					
						
							|  |  |  |   try { | 
					
						
							| 
									
										
										
										
											2016-01-19 02:11:58 -08:00
										 |  |  |     var pkg; | 
					
						
							|  |  |  |     if (shredOptions.jadeDir) { | 
					
						
							|  |  |  |       pkg = createShredJadePackage(shredOptions); | 
					
						
							|  |  |  |     } else { | 
					
						
							|  |  |  |       pkg = createShredExamplePackage(shredOptions); | 
					
						
							|  |  |  |     } | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |     var dgeni = new Dgeni([ pkg]); | 
					
						
							|  |  |  |     return dgeni.generate(); | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  |   } catch(err) { | 
					
						
							|  |  |  |     console.log(err); | 
					
						
							|  |  |  |     console.log(err.stack); | 
					
						
							|  |  |  |     throw err; | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | var shredSingleDir = function(shredOptions, filePath) { | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |   shredOptions = resolveShredOptions(shredOptions); | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |   var fileDir = path.dirname(filePath); | 
					
						
							| 
									
										
										
										
											2015-09-18 07:20:02 -07:00
										 |  |  |   var relativePath = path.relative(shredOptions.examplesDir, fileDir); | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |   var examplesDir = path.join(shredOptions.examplesDir, relativePath); | 
					
						
							|  |  |  |   var fragmentsDir = path.join(shredOptions.fragmentsDir, relativePath); | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |   var options = { | 
					
						
							|  |  |  |     includeSubdirs: false, | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |     examplesDir: examplesDir, | 
					
						
							|  |  |  |     fragmentsDir: fragmentsDir | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |   } | 
					
						
							| 
									
										
										
										
											2015-09-18 07:20:02 -07:00
										 |  |  |   var cleanPath = path.join(fragmentsDir, '*.*') | 
					
						
							| 
									
										
										
										
											2015-08-08 13:55:53 -07:00
										 |  |  |   return delPromise([ cleanPath, '!**/*.ovr.*']).then(function(paths) { | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |     // console.log('Deleted files/folders:\n', paths.join('\n'));
 | 
					
						
							|  |  |  |     return shred(options); | 
					
						
							|  |  |  |   }); | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-19 02:11:58 -08:00
										 |  |  | var shredSingleJadeDir = function(shredOptions, filePath) { | 
					
						
							|  |  |  |   shredOptions = resolveShredOptions(shredOptions); | 
					
						
							|  |  |  |   var fileDir = path.dirname(filePath); | 
					
						
							|  |  |  |   var relativePath = path.relative(shredOptions.jadeDir, fileDir); | 
					
						
							|  |  |  |   var jadeDir = path.join(shredOptions.jadeDir, relativePath); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   var options = { | 
					
						
							|  |  |  |     includeSubdirs: false, | 
					
						
							|  |  |  |     jadeDir: jadeDir | 
					
						
							|  |  |  |   } | 
					
						
							| 
									
										
										
										
											2016-01-20 11:59:40 -08:00
										 |  |  |   // var cleanPath = path.join(jadeDir, '_.*.jade')
 | 
					
						
							|  |  |  |   //return delPromise([ cleanPath]).then(function(paths) {
 | 
					
						
							|  |  |  |   //  console.log('Deleted files/folders:\n', paths.join('\n'));
 | 
					
						
							|  |  |  |   //  return shred(options);
 | 
					
						
							|  |  |  |   //});
 | 
					
						
							|  |  |  |   return shred(options); | 
					
						
							| 
									
										
										
										
											2016-01-19 02:11:58 -08:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  | var buildShredMap = function(shredMapOptions) { | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |   try { | 
					
						
							|  |  |  |     var pkg = createShredMapPackage(shredMapOptions); | 
					
						
							|  |  |  |     var dgeni = new Dgeni([ pkg]); | 
					
						
							|  |  |  |     return dgeni.generate(); | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  |   } catch(err) { | 
					
						
							|  |  |  |     console.log(err); | 
					
						
							|  |  |  |     console.log(err.stack); | 
					
						
							|  |  |  |     throw err; | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | module.exports = { | 
					
						
							|  |  |  |   shred: shred, | 
					
						
							|  |  |  |   shredSingleDir: shredSingleDir, | 
					
						
							| 
									
										
										
										
											2016-01-19 02:11:58 -08:00
										 |  |  |   shredSingleJadeDir: shredSingleJadeDir, | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |   buildShredMap: buildShredMap | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | }; | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-19 02:11:58 -08:00
										 |  |  | function createShredExamplePackage(shredOptions) { | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |   var pkg = new Dgeni.Package('doc-shredder', [ | 
					
						
							|  |  |  |     // require('dgeni-packages/base') - doesn't work
 | 
					
						
							|  |  |  |   ]); | 
					
						
							|  |  |  |   var options = resolveShredOptions(shredOptions); | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |   initializePackage(pkg) | 
					
						
							| 
									
										
										
										
											2015-11-04 10:47:05 +00:00
										 |  |  |     .factory(require('./fileReaders/regionFileReader')) | 
					
						
							|  |  |  |     .processor(require('./processors/renderAsMarkdownProcessor')) | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-11-04 10:47:05 +00:00
										 |  |  |     .config(function(readFilesProcessor, regionFileReader) { | 
					
						
							|  |  |  |       readFilesProcessor.fileReaders = [regionFileReader]; | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2015-12-01 23:30:57 -08:00
										 |  |  |     // default configs - may be overridden
 | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |     .config(function(readFilesProcessor) { | 
					
						
							|  |  |  |       // Specify the base path used when resolving relative paths to source and output files
 | 
					
						
							| 
									
										
										
										
											2015-09-18 07:20:02 -07:00
										 |  |  |       readFilesProcessor.basePath = "/"; | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // Specify collections of source files that should contain the documentation to extract
 | 
					
						
							| 
									
										
										
										
											2015-12-09 23:56:24 -08:00
										 |  |  |       var extns = ['*.ts', '*.html', '*.js', '*.css', '*.json', '*.dart', '*.yaml' ]; | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |       var includeFiles = extns.map(function(extn) { | 
					
						
							|  |  |  |         if (options.includeSubdirs) { | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |           return path.join(options.examplesDir, '**', extn); | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |           return path.join(options.examplesDir, extn); | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |         } | 
					
						
							|  |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-12-09 23:56:24 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
 | 
					
						
							|  |  |  |       // this just uses globby to 'preglob' the include files ( and  exclude the node_modules).
 | 
					
						
							|  |  |  |       var nmPattern = '**/node_modules/**'; | 
					
						
							|  |  |  |       var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } ); | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |       readFilesProcessor.sourceFiles = [ { | 
					
						
							|  |  |  |         // Process all candidate files in `src` and its subfolders ...
 | 
					
						
							| 
									
										
										
										
											2015-12-09 23:56:24 -08:00
										 |  |  |         include: includeFiles , | 
					
						
							|  |  |  |         exclude: [ '**/node_modules/**', '**/typings/**', '**/packages/**', '**/build/**'], | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |         // When calculating the relative path to these files use this as the base path.
 | 
					
						
							|  |  |  |         // So `src/foo/bar.js` will have relative path of `foo/bar.js`
 | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |         basePath: options.examplesDir | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |       } ]; | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .config(function(writeFilesProcessor) { | 
					
						
							|  |  |  |       // Specify where the writeFilesProcessor will write our generated doc files
 | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  |       writeFilesProcessor.outputFolder  = path.resolve(options.fragmentsDir); | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |     }); | 
					
						
							|  |  |  |   return pkg; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2016-01-19 02:11:58 -08:00
										 |  |  | function createShredJadePackage(shredOptions) { | 
					
						
							|  |  |  |   var pkg = new Dgeni.Package('jade-doc-shredder', [ | 
					
						
							|  |  |  |     // require('dgeni-packages/base') - doesn't work
 | 
					
						
							|  |  |  |   ]); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   var options = shredOptions; | 
					
						
							|  |  |  |   options.jadeDir = path.resolve(options.jadeDir); | 
					
						
							|  |  |  |   options.includeSubdirs = options.includeSubdirs == null ? true : options.includeSubdirs; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   initializePackage(pkg) | 
					
						
							|  |  |  |     .factory(require('./fileReaders/regionFileReader')) | 
					
						
							|  |  |  |     .processor(require('./processors/renderAsJadeProcessor')) | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |     .config(function(readFilesProcessor, regionFileReader) { | 
					
						
							|  |  |  |       readFilesProcessor.fileReaders = [regionFileReader]; | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     // default configs - may be overridden
 | 
					
						
							|  |  |  |     .config(function(readFilesProcessor) { | 
					
						
							|  |  |  |       // Specify the base path used when resolving relative paths to source and output files
 | 
					
						
							|  |  |  |       readFilesProcessor.basePath = "/"; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Specify collections of source files that should contain the documentation to extract
 | 
					
						
							|  |  |  |       var extns = ['*.jade' ]; | 
					
						
							|  |  |  |       var includeFiles = extns.map(function(extn) { | 
					
						
							|  |  |  |         if (options.includeSubdirs) { | 
					
						
							|  |  |  |           return path.join(options.jadeDir, '**', extn); | 
					
						
							|  |  |  |         } else { | 
					
						
							|  |  |  |           return path.join(options.jadeDir, extn); | 
					
						
							|  |  |  |         } | 
					
						
							|  |  |  |       }); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
 | 
					
						
							|  |  |  |       // this just uses globby to 'preglob' the include files ( and  exclude the node_modules).
 | 
					
						
							|  |  |  |       var nmPattern = '**/node_modules/**'; | 
					
						
							|  |  |  |       var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       readFilesProcessor.sourceFiles = [ { | 
					
						
							|  |  |  |         // Process all candidate files in `src` and its subfolders ...
 | 
					
						
							|  |  |  |         include: includeFiles , | 
					
						
							|  |  |  |         exclude: [ '**/node_modules/**', '**/typings/**', '**/packages/**', '**/build/**', '**/_code-examples.jade'], | 
					
						
							|  |  |  |         // When calculating the relative path to these files use this as the base path.
 | 
					
						
							|  |  |  |         // So `src/foo/bar.js` will have relative path of `foo/bar.js`
 | 
					
						
							|  |  |  |         basePath: options.jadeDir | 
					
						
							|  |  |  |       } ]; | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .config(function(writeFilesProcessor) { | 
					
						
							|  |  |  |       // Specify where the writeFilesProcessor will write our generated doc files
 | 
					
						
							|  |  |  |       writeFilesProcessor.outputFolder  = '.'; | 
					
						
							|  |  |  |     }); | 
					
						
							|  |  |  |   return pkg; | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  | var createShredMapPackage = function(mapOptions) { | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |   var pkg = new Dgeni.Package('doc-shred-mapper', [ | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |     require('dgeni-packages/base'), | 
					
						
							|  |  |  |     require('dgeni-packages/nunjucks') | 
					
						
							|  |  |  |   ]); | 
					
						
							|  |  |  |   var options = resolveMapOptions(mapOptions); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   initializePackage(pkg) | 
					
						
							| 
									
										
										
										
											2015-11-04 10:47:05 +00:00
										 |  |  |     .factory(require('./fileReaders/extractPathsReader')) | 
					
						
							|  |  |  |     .processor(require('./processors/shredMapProcessor')) | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |     .config(function(shredMapProcessor) { | 
					
						
							|  |  |  |       shredMapProcessor.options = options; | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |     .config(function(readFilesProcessor, extractPathsReader ) { | 
					
						
							|  |  |  |       readFilesProcessor.fileReaders = [ extractPathsReader]; | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     // default configs - may be overriden
 | 
					
						
							|  |  |  |     .config(function(readFilesProcessor) { | 
					
						
							|  |  |  |       // Specify the base path used when resolving relative paths to source and output files
 | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  |       readFilesProcessor.basePath = '/'; | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // Specify collections of source files that should contain the documentation to extract
 | 
					
						
							|  |  |  |       var extns = ['*.jade' ]; | 
					
						
							|  |  |  |       var includeFiles = extns.map(function(extn) { | 
					
						
							|  |  |  |         if (options.includeSubdirs) { | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |           return path.join(options.jadeDir, '**', extn); | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |         } else { | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |           return path.join(options.jadeDir, extn); | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |         } | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |       }); | 
					
						
							| 
									
										
										
										
											2015-12-09 23:56:24 -08:00
										 |  |  | 
 | 
					
						
							|  |  |  |       // HACK ( next two lines) because the glob function that dgeni uses internally isn't good at removing 'node_modules' early
 | 
					
						
							|  |  |  |       // this just uses globby to 'preglob' the include files ( and  exclude the node_modules).
 | 
					
						
							|  |  |  |       var nmPattern = '**/node_modules/**'; | 
					
						
							|  |  |  |       var includeFiles = globby.sync( includeFiles, { ignore: [nmPattern] } ); | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |       readFilesProcessor.sourceFiles = [ { | 
					
						
							|  |  |  |         // Process all candidate files in `src` and its subfolders ...
 | 
					
						
							|  |  |  |         include: includeFiles, | 
					
						
							| 
									
										
										
										
											2015-12-09 23:56:24 -08:00
										 |  |  |         exclude: ['**/node_modules/**', '**/typings/**', '**/packages/**', '**/build/**'], | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |         // When calculating the relative path to these files use this as the base path.
 | 
					
						
							|  |  |  |         // So `src/foo/bar.js` will have relative path of `foo/bar.js`
 | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |         basePath: options.jadeDir | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |       } ]; | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |     }) | 
					
						
							| 
									
										
										
										
											2015-08-08 13:55:53 -07:00
										 |  |  |     .config(function(writeFilesProcessor, renderDocsProcessor, unescapeCommentsProcessor) { | 
					
						
							|  |  |  |       if (!mapOptions.writeFilesEnabled) { | 
					
						
							|  |  |  |         // dgeni hack to allow a geni task to simply return the results of the shredMapProcessor directly
 | 
					
						
							|  |  |  |         renderDocsProcessor.$enabled = false; | 
					
						
							|  |  |  |         writeFilesProcessor.$enabled = false; | 
					
						
							|  |  |  |         unescapeCommentsProcessor.$enabled = false; | 
					
						
							|  |  |  |       } else { | 
					
						
							|  |  |  |         // Specify where the writeFilesProcessor will write our generated doc files
 | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  |         writeFilesProcessor.outputFolder = path.resolve(options.outputDir); | 
					
						
							| 
									
										
										
										
											2015-08-08 13:55:53 -07:00
										 |  |  |       } | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |     }) | 
					
						
							|  |  |  |     .config(function(templateFinder) { | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |       // look for templates in this folder
 | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |       templateFinder.templateFolders = [ path.resolve(__dirname) ]; | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       // Specify how to match docs to templates.
 | 
					
						
							|  |  |  |       // In this case we just use the same static template for all docs
 | 
					
						
							|  |  |  |       templateFinder.templatePatterns = [ '${ doc.docType }.template' ]; | 
					
						
							|  |  |  |     }) | 
					
						
							|  |  |  |     .config(function(computePathsProcessor, computeIdsProcessor)  { | 
					
						
							|  |  |  |       computePathsProcessor.$enabled = false; | 
					
						
							|  |  |  |       computeIdsProcessor.$enabled = false; | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |       // Unused for now.
 | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |       //computePathsProcessor.pathTemplates.push({
 | 
					
						
							|  |  |  |       //  docTypes: ['foo'],
 | 
					
						
							|  |  |  |       //  pathTemplate: '',
 | 
					
						
							|  |  |  |       //  getOutputPath: function () {
 | 
					
						
							|  |  |  |       //  },
 | 
					
						
							|  |  |  |       //});
 | 
					
						
							|  |  |  |       //
 | 
					
						
							|  |  |  |       //computeIdsProcessor.idTemplates.push({
 | 
					
						
							|  |  |  |       //  docTypes: ['foo'],
 | 
					
						
							|  |  |  |       //  getAliases: function (doc) {
 | 
					
						
							|  |  |  |       //    return [doc.id];
 | 
					
						
							|  |  |  |       //  }
 | 
					
						
							|  |  |  |       //});
 | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  |     }); | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-08 13:55:53 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  |   return pkg; | 
					
						
							| 
									
										
										
										
											2015-08-03 17:45:58 -07:00
										 |  |  | } | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  | function resolveShredOptions(shredOptions) { | 
					
						
							| 
									
										
										
										
											2015-11-04 10:47:05 +00:00
										 |  |  |   var DOCS_FOLDER = '../../public/docs'; | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  |   var so =  _.defaults({}, shredOptions, { | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |     // read files from any subdir under here
 | 
					
						
							| 
									
										
										
										
											2015-11-04 10:47:05 +00:00
										 |  |  |     examplesDir: path.join(DOCS_FOLDER, "_examples"), | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |     // shredded files get copied here with same subdir structure.
 | 
					
						
							| 
									
										
										
										
											2015-11-04 10:47:05 +00:00
										 |  |  |     fragmentsDir: path.join(DOCS_FOLDER, "_fragments"), | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |     // whether to include subdirectories when shredding.
 | 
					
						
							|  |  |  |     includeSubdirs: true | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |   so.examplesDir = path.resolve(so.examplesDir); | 
					
						
							|  |  |  |   so.fragmentsDir = path.resolve(so.fragmentsDir); | 
					
						
							|  |  |  |   return so; | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function resolveMapOptions(mapOptions) { | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  |   var so =  _.defaults({}, mapOptions, { | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  |     includeSubdirs: true | 
					
						
							|  |  |  |   }); | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  |   so.jadeDir = path.resolve(so.jadeDir); | 
					
						
							| 
									
										
										
										
											2015-09-18 19:51:10 -07:00
										 |  |  |   so.devguideExamplesDir = path.resolve(so.devguideExamplesDir); | 
					
						
							|  |  |  |   so.apiExamplesDir = path.resolve(so.apiExamplesDir); | 
					
						
							| 
									
										
										
										
											2015-09-18 12:41:20 -07:00
										 |  |  |   so.fragmentsDir = path.resolve(so.fragmentsDir); | 
					
						
							|  |  |  |   return so; | 
					
						
							| 
									
										
										
										
											2015-08-11 00:27:09 -07:00
										 |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  | function initializePackage(pkg) { | 
					
						
							|  |  |  |   return pkg | 
					
						
							|  |  |  |     .processor(require('dgeni-packages/base/processors/read-files')) | 
					
						
							|  |  |  |     .processor(require('dgeni-packages/base/processors/write-files')) | 
					
						
							| 
									
										
										
										
											2015-10-29 15:23:21 +08:00
										 |  |  |     .factory(require('dgeni-packages/base/services/writeFile')) | 
					
						
							| 
									
										
										
										
											2015-08-10 11:17:02 -07:00
										 |  |  | 
 | 
					
						
							|  |  |  |     // Ugh... Boilerplate that dgeni needs to sequence operations
 | 
					
						
							|  |  |  |     .processor({ name: 'reading-files' }) | 
					
						
							|  |  |  |     .processor({ name: 'files-read', $runAfter: ['reading-files'] }) | 
					
						
							|  |  |  |     .processor({ name: 'processing-docs', $runAfter: ['files-read'] }) | 
					
						
							|  |  |  |     .processor({ name: 'docs-processed', $runAfter: ['processing-docs'] }) | 
					
						
							|  |  |  |     .processor({ name: 'adding-extra-docs', $runAfter: ['docs-processed'] }) | 
					
						
							|  |  |  |     .processor({ name: 'extra-docs-added', $runAfter: ['adding-extra-docs'] }) | 
					
						
							|  |  |  |     .processor({ name: 'computing-ids', $runAfter: ['extra-docs-added'] }) | 
					
						
							|  |  |  |     .processor({ name: 'ids-computed', $runAfter: ['computing-ids'] }) | 
					
						
							|  |  |  |     .processor({ name: 'computing-paths', $runAfter: ['ids-computed'] }) | 
					
						
							|  |  |  |     .processor({ name: 'paths-computed', $runAfter: ['computing-paths'] }) | 
					
						
							|  |  |  |     .processor({ name: 'rendering-docs', $runAfter: ['paths-computed'] }) | 
					
						
							|  |  |  |     .processor({ name: 'docs-rendered', $runAfter: ['rendering-docs'] }) | 
					
						
							|  |  |  |     .processor({ name: 'writing-files', $runAfter: ['docs-rendered'] }) | 
					
						
							|  |  |  |     .processor({ name: 'files-written', $runAfter: ['writing-files'] }) | 
					
						
							|  |  |  |     .config(function(log) { | 
					
						
							|  |  |  |       // Set logging level
 | 
					
						
							|  |  |  |       log.level = 'info'; | 
					
						
							|  |  |  |     }) | 
					
						
							| 
									
										
										
										
											2015-10-15 23:25:02 -07:00
										 |  |  | } |