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