| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  | /** | 
					
						
							|  |  |  |  * @license | 
					
						
							|  |  |  |  * Copyright Google Inc. All Rights Reserved. | 
					
						
							|  |  |  |  * | 
					
						
							|  |  |  |  * Use of this source code is governed by an MIT-style license that can be | 
					
						
							|  |  |  |  * found in the LICENSE file at https://angular.io/license
 | 
					
						
							|  |  |  |  */ | 
					
						
							|  |  |  | /* eslint no-console: "off" */ | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | function createPackage(changedFile) { | 
					
						
							| 
									
										
										
										
											2018-05-04 08:31:46 +01:00
										 |  |  |   const marketingMatch = /^aio\/content\/(?:marketing\/|navigation\.json)/.exec(changedFile); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |   if (marketingMatch) { | 
					
						
							|  |  |  |     console.log('Building marketing docs'); | 
					
						
							|  |  |  |     return require('./marketing-package').createPackage(); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 13:10:52 +01:00
										 |  |  |   const tutorialMatch = /^aio\/content\/tutorial\/([^.]+)\.md/.exec(changedFile); | 
					
						
							|  |  |  |   const tutorialExampleMatch = /^aio\/content\/examples\/(toh-[^\/]+)\//.exec(changedFile); | 
					
						
							|  |  |  |   if (tutorialMatch || tutorialExampleMatch) { | 
					
						
							|  |  |  |     const tutorialName = tutorialMatch && tutorialMatch[1] || tutorialExampleMatch[1]; | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     console.log('Building tutorial docs'); | 
					
						
							| 
									
										
										
										
											2017-04-21 13:10:52 +01:00
										 |  |  |     return require('./tutorial-package').createPackage(tutorialName); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2019-03-20 15:10:47 +00:00
										 |  |  |   const gettingStartedMatch = /^aio\/content\/getting-started\/([^.]+)\.md/.exec(changedFile); | 
					
						
							|  |  |  |   const gettingStartedExampleMatch = /^aio\/content\/examples\/getting-started\/([^\/]+)\//.exec(changedFile); | 
					
						
							|  |  |  |   if (gettingStartedMatch || gettingStartedExampleMatch) { | 
					
						
							|  |  |  |     const gettingStartedName = gettingStartedMatch && gettingStartedMatch[1] || 'index'; | 
					
						
							|  |  |  |     console.log('Building getting started docs'); | 
					
						
							|  |  |  |     return require('./getting-started-package').createPackage(gettingStartedName); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2017-04-21 13:10:52 +01:00
										 |  |  |   const guideMatch = /^aio\/content\/guide\/([^.]+)\.md/.exec(changedFile); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |   const exampleMatch = /^aio\/content\/examples\/(?:cb-)?([^\/]+)\//.exec(changedFile); | 
					
						
							|  |  |  |   if (guideMatch || exampleMatch) { | 
					
						
							| 
									
										
										
										
											2017-04-21 13:10:52 +01:00
										 |  |  |     const guideName = guideMatch && guideMatch[1] || exampleMatch[1]; | 
					
						
							|  |  |  |     console.log(`Building guide doc: ${guideName}.md`); | 
					
						
							|  |  |  |     return require('./guide-package').createPackage(guideName); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |   } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |   const apiExamplesMatch = /^packages\/examples\/([^\/]+)\//.exec(changedFile); | 
					
						
							|  |  |  |   const apiMatch = /^packages\/([^\/]+)\//.exec(changedFile); | 
					
						
							|  |  |  |   if (apiExamplesMatch || apiMatch) { | 
					
						
							|  |  |  |     const packageName = apiExamplesMatch && apiExamplesMatch[1] || apiMatch[1]; | 
					
						
							|  |  |  |     console.log('Building API docs for', packageName); | 
					
						
							|  |  |  |     return require('./api-package').createPackage(packageName); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | } | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | module.exports = { | 
					
						
							| 
									
										
										
										
											2017-04-21 13:10:52 +01:00
										 |  |  |   generateDocs: function(changedFile, options = {}) { | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     const {Dgeni} = require('dgeni'); | 
					
						
							| 
									
										
										
										
											2017-04-21 13:10:52 +01:00
										 |  |  |     const package = createPackage(changedFile); | 
					
						
							|  |  |  |     if (options.silent) { | 
					
						
							|  |  |  |       package.config(function(log) { log.level = 'error'; }); | 
					
						
							|  |  |  |     } | 
					
						
							|  |  |  |     var dgeni = new Dgeni([package]); | 
					
						
							| 
									
										
										
										
											2017-04-16 20:48:22 +01:00
										 |  |  |     const start = Date.now(); | 
					
						
							|  |  |  |     return dgeni.generate() | 
					
						
							|  |  |  |       .then( | 
					
						
							|  |  |  |         () => console.log('Generated docs in ' + (Date.now() - start)/1000 + ' secs'), | 
					
						
							|  |  |  |         err => console.log('Error generating docs', err)); | 
					
						
							|  |  |  |   } | 
					
						
							|  |  |  | }; |