parent
04d5337b75
commit
818c82c2a2
|
@ -0,0 +1,2 @@
|
|||
### Angular 2 Documentation Example
|
||||
|
|
@ -10,10 +10,10 @@ var mkdirp = require('mkdirp');
|
|||
var indexHtmlTranslator = require('./indexHtmlTranslator');
|
||||
var regionExtractor = require('../doc-shredder/regionExtractor');
|
||||
var COPYRIGHT, COPYRIGHT_JS_CSS, COPYRIGHT_HTML;
|
||||
var README; // content of plunker.README.md for plunkers
|
||||
var SYSTEMJS_CONFIG; // content of systemjs.config.js for plunkers that use systemjs
|
||||
var TSCONFIG; // content of tsconfig.json for plunkers that use systemjs
|
||||
|
||||
|
||||
module.exports = {
|
||||
buildPlunkers: buildPlunkers
|
||||
};
|
||||
|
@ -30,7 +30,7 @@ function buildCopyrightStrings() {
|
|||
}
|
||||
|
||||
function buildPlunkers(basePath, destPath, options) {
|
||||
getSystemJsConfigPlunker(basePath);
|
||||
getPlunkerFiles(basePath);
|
||||
var errFn = options.errFn || function(e) { console.log(e); };
|
||||
var plunkerPaths = path.join(basePath, '**/*plnkr.json');
|
||||
var fileNames = globby.sync(plunkerPaths, { ignore: "**/node_modules/**"});
|
||||
|
@ -59,7 +59,7 @@ function buildPlunkerFrom(configFileName, basePath, destPath) {
|
|||
try {
|
||||
var config = initConfigAndCollectFileNames(configFileName);
|
||||
var postData = createPostData(config);
|
||||
addSystemJsConfig(config, postData);
|
||||
addPlunkerFiles(config, postData);
|
||||
var html = createPlunkerHtml(postData);
|
||||
fs.writeFileSync(outputFileName, html, 'utf-8');
|
||||
if (altFileName) {
|
||||
|
@ -81,10 +81,8 @@ function buildPlunkerFrom(configFileName, basePath, destPath) {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Add plunker versions of systemjs.config and tsconfig.json
|
||||
*/
|
||||
function addSystemJsConfig(config, postData){
|
||||
function addPlunkerFiles(config, postData) {
|
||||
addReadme(config, postData);
|
||||
if (config.basePath.indexOf('/ts') > -1) {
|
||||
// uses systemjs.config.js so add plunker version
|
||||
postData['files[systemjs.config.js]'] = SYSTEMJS_CONFIG;
|
||||
|
@ -92,8 +90,20 @@ function addSystemJsConfig(config, postData){
|
|||
}
|
||||
}
|
||||
|
||||
function getSystemJsConfigPlunker(basePath) {
|
||||
function addReadme(config, postData) {
|
||||
var existingFiles = config.fileNames.map(function(file) {
|
||||
return file.substr(file.lastIndexOf('/') + 1);
|
||||
});
|
||||
|
||||
if (existingFiles.indexOf('README.md') === -1) {
|
||||
var plunkerReadme = README + config.description;
|
||||
postData['files[README.md]'] = plunkerReadme;
|
||||
}
|
||||
}
|
||||
|
||||
function getPlunkerFiles(basePath) {
|
||||
// Assume plunker version is sibling of node_modules version
|
||||
README = fs.readFileSync(basePath + '/plunker.README.md', 'utf-8');
|
||||
SYSTEMJS_CONFIG = fs.readFileSync(basePath + '/systemjs.config.plunker.js', 'utf-8');
|
||||
SYSTEMJS_CONFIG += COPYRIGHT_JS_CSS;
|
||||
TSCONFIG = fs.readFileSync(basePath + '/tsconfig.json', 'utf-8');
|
||||
|
|
Loading…
Reference in New Issue