2017-04-16 15:48:22 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2017-04-16 15:48:22 -04:00
|
|
|
*
|
|
|
|
* 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 03:31:46 -04:00
|
|
|
const marketingMatch = /^aio\/content\/(?:marketing\/|navigation\.json)/.exec(changedFile);
|
2017-04-16 15:48:22 -04:00
|
|
|
if (marketingMatch) {
|
|
|
|
console.log('Building marketing docs');
|
|
|
|
return require('./marketing-package').createPackage();
|
|
|
|
}
|
|
|
|
|
2017-04-21 08:10:52 -04: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 15:48:22 -04:00
|
|
|
console.log('Building tutorial docs');
|
2017-04-21 08:10:52 -04:00
|
|
|
return require('./tutorial-package').createPackage(tutorialName);
|
2017-04-16 15:48:22 -04:00
|
|
|
}
|
|
|
|
|
2019-04-02 02:12:55 -04:00
|
|
|
const gettingStartedMatch = /^aio\/content\/start\/([^.]+)\.md/.exec(changedFile);
|
2019-03-20 11:10:47 -04:00
|
|
|
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 08:10:52 -04:00
|
|
|
const guideMatch = /^aio\/content\/guide\/([^.]+)\.md/.exec(changedFile);
|
2017-04-16 15:48:22 -04:00
|
|
|
const exampleMatch = /^aio\/content\/examples\/(?:cb-)?([^\/]+)\//.exec(changedFile);
|
|
|
|
if (guideMatch || exampleMatch) {
|
2017-04-21 08:10:52 -04:00
|
|
|
const guideName = guideMatch && guideMatch[1] || exampleMatch[1];
|
|
|
|
console.log(`Building guide doc: ${guideName}.md`);
|
|
|
|
return require('./guide-package').createPackage(guideName);
|
2017-04-16 15:48:22 -04: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 08:10:52 -04:00
|
|
|
generateDocs: function(changedFile, options = {}) {
|
2017-04-16 15:48:22 -04:00
|
|
|
const {Dgeni} = require('dgeni');
|
2017-04-21 08:10:52 -04:00
|
|
|
const package = createPackage(changedFile);
|
|
|
|
if (options.silent) {
|
|
|
|
package.config(function(log) { log.level = 'error'; });
|
|
|
|
}
|
|
|
|
var dgeni = new Dgeni([package]);
|
2017-04-16 15:48:22 -04: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));
|
|
|
|
}
|
|
|
|
};
|