(fix) plunker generation fixes
closes #424 plnkr - change plnkr.config -> plnkr.json and change output paths and names update jade plunkers to new 'resources/live-examples' path + minor cleanup update gulpfile to run build-plunkers as part of build-docs.
This commit is contained in:
parent
f7b2913231
commit
b06f2dcec6
|
@ -17,5 +17,5 @@ pubspec.lock
|
||||||
public/docs/xref-*.*
|
public/docs/xref-*.*
|
||||||
_zip-output
|
_zip-output
|
||||||
www
|
www
|
||||||
*.plnkr.html
|
*plnkr.html
|
||||||
plnkr.html
|
*plnkr.no-link.html
|
10
gulpfile.js
10
gulpfile.js
|
@ -28,6 +28,7 @@ var DOCS_PATH = path.join(PUBLIC_PATH, 'docs');
|
||||||
var EXAMPLES_PATH = path.join(DOCS_PATH, '_examples');
|
var EXAMPLES_PATH = path.join(DOCS_PATH, '_examples');
|
||||||
var NOT_API_DOCS_GLOB = path.join(PUBLIC_PATH, './{docs/*/latest/!(api),!(docs)}/**/*');
|
var NOT_API_DOCS_GLOB = path.join(PUBLIC_PATH, './{docs/*/latest/!(api),!(docs)}/**/*');
|
||||||
var RESOURCES_PATH = path.join(PUBLIC_PATH, 'resources');
|
var RESOURCES_PATH = path.join(PUBLIC_PATH, 'resources');
|
||||||
|
var LIVE_EXAMPLES_PATH = path.join(RESOURCES_PATH, 'live-examples');
|
||||||
|
|
||||||
var docShredder = require(path.resolve(TOOLS_PATH, 'doc-shredder/doc-shredder'));
|
var docShredder = require(path.resolve(TOOLS_PATH, 'doc-shredder/doc-shredder'));
|
||||||
var exampleZipper = require(path.resolve(TOOLS_PATH, '_example-zipper/exampleZipper'));
|
var exampleZipper = require(path.resolve(TOOLS_PATH, '_example-zipper/exampleZipper'));
|
||||||
|
@ -51,9 +52,6 @@ var _excludeMatchers = _excludePatterns.map(function(excludePattern){
|
||||||
return new Minimatch(excludePattern)
|
return new Minimatch(excludePattern)
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build-plunkers', function() {
|
|
||||||
return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, gutil.log);
|
|
||||||
});
|
|
||||||
|
|
||||||
// Public tasks
|
// Public tasks
|
||||||
|
|
||||||
|
@ -83,7 +81,7 @@ gulp.task('build-and-serve', ['build-docs'], function (cb) {
|
||||||
watchAndSync({localFiles: true}, cb);
|
watchAndSync({localFiles: true}, cb);
|
||||||
});
|
});
|
||||||
|
|
||||||
gulp.task('build-docs', ['build-devguide-docs', 'build-api-docs', '_zip-examples']);
|
gulp.task('build-docs', ['build-devguide-docs', 'build-api-docs', 'build-plunkers', '_zip-examples']);
|
||||||
|
|
||||||
gulp.task('build-api-docs', ['build-js-api-docs', 'build-ts-api-docs']);
|
gulp.task('build-api-docs', ['build-js-api-docs', 'build-ts-api-docs']);
|
||||||
|
|
||||||
|
@ -99,6 +97,10 @@ gulp.task('build-js-api-docs', ['_shred-api-examples'], function() {
|
||||||
return buildApiDocs('js');
|
return buildApiDocs('js');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
gulp.task('build-plunkers', function() {
|
||||||
|
return plunkerBuilder.buildPlunkers(EXAMPLES_PATH, LIVE_EXAMPLES_PATH, { errFn: gutil.log });
|
||||||
|
});
|
||||||
|
|
||||||
gulp.task('git-changed-examples', ['_shred-devguide-examples'], function(){
|
gulp.task('git-changed-examples', ['_shred-devguide-examples'], function(){
|
||||||
var after, sha, messageSuffix;
|
var after, sha, messageSuffix;
|
||||||
if (argv.after) {
|
if (argv.after) {
|
||||||
|
|
|
@ -17,7 +17,7 @@ include ../../../../_includes/_util-fns
|
||||||
|
|
||||||
Welcome, Angular pipes, the simple display-value transformations that we can declare in our HTML!
|
Welcome, Angular pipes, the simple display-value transformations that we can declare in our HTML!
|
||||||
|
|
||||||
[Live Example](/docs/_examples/pipes/ts/src/plnkr.html)
|
[Live Example](/resources/live-examples/pipes/ts/src/plnkr.html)
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
:marked
|
:marked
|
||||||
|
|
|
@ -36,7 +36,7 @@ include ../../../../_includes/_util-fns
|
||||||
|
|
||||||
>[Template Expression Operators](#expression-operators)
|
>[Template Expression Operators](#expression-operators)
|
||||||
|
|
||||||
[Live Example](/docs/_examples/template-syntax/ts/src/plnkr.html)
|
[Live Example](/resources/live-examples/template-syntax/ts/src/plnkr.html)
|
||||||
|
|
||||||
.l-main-section
|
.l-main-section
|
||||||
:marked
|
:marked
|
||||||
|
|
|
@ -53,7 +53,7 @@ var _rxData = [
|
||||||
{
|
{
|
||||||
pattern: 'link',
|
pattern: 'link',
|
||||||
from: 'node_modules/bootstrap/dist/css/bootstrap.min.css',
|
from: 'node_modules/bootstrap/dist/css/bootstrap.min.css',
|
||||||
to: 'https://cdnjs.com/libraries/twitter-bootstrap/3.3.5'
|
to: 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap-theme.min.css'
|
||||||
// to: 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css'
|
// to: 'https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.3.5/css/bootstrap.min.css'
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|
|
@ -5,6 +5,7 @@ var _ = require('lodash');
|
||||||
var jsdom = require("jsdom");
|
var jsdom = require("jsdom");
|
||||||
var fs = require("fs");
|
var fs = require("fs");
|
||||||
var globule = require('globule');
|
var globule = require('globule');
|
||||||
|
var mkdirp = require('mkdirp');
|
||||||
|
|
||||||
var indexHtmlTranslator = require('./indexHtmlTranslator');
|
var indexHtmlTranslator = require('./indexHtmlTranslator');
|
||||||
var regionExtractor = require('../doc-shredder/regionExtractor');
|
var regionExtractor = require('../doc-shredder/regionExtractor');
|
||||||
|
@ -13,16 +14,16 @@ module.exports = {
|
||||||
buildPlunkers: buildPlunkers
|
buildPlunkers: buildPlunkers
|
||||||
};
|
};
|
||||||
|
|
||||||
function buildPlunkers(basePath, errFn) {
|
function buildPlunkers(basePath, destPath, options) {
|
||||||
errFn = errFn || function(e) { console.log(e); };
|
var errFn = options.errFn || function(e) { console.log(e); };
|
||||||
var configExtns = ['plnkr.config', '*.plnkr.config'];
|
var configExtns = ['plnkr.json', '*plnkr.json'];
|
||||||
var gpaths = configExtns.map(function(extn) {
|
var gpaths = configExtns.map(function(extn) {
|
||||||
return path.join(basePath, '**/' + extn);
|
return path.join(basePath, '**/' + extn);
|
||||||
});
|
});
|
||||||
var fileNames = globule.find(gpaths);
|
var fileNames = globule.find(gpaths);
|
||||||
fileNames.forEach(function(configFileName) {
|
fileNames.forEach(function(configFileName) {
|
||||||
try {
|
try {
|
||||||
buildPlunkerFrom(configFileName);
|
buildPlunkerFrom(configFileName, basePath, destPath);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
errFn(e);
|
errFn(e);
|
||||||
}
|
}
|
||||||
|
@ -34,19 +35,34 @@ function buildPlunkers(basePath, errFn) {
|
||||||
// description: optional string - description of this plunker - defaults to the title in the index.html page.
|
// description: optional string - description of this plunker - defaults to the title in the index.html page.
|
||||||
// tags: [] - optional array of strings
|
// tags: [] - optional array of strings
|
||||||
// main: string - filename of what will become index.html in the plunker - defaults to index.html
|
// main: string - filename of what will become index.html in the plunker - defaults to index.html
|
||||||
function buildPlunkerFrom(configFileName ) {
|
function buildPlunkerFrom(configFileName, basePath, destPath ) {
|
||||||
// replace ending 'plnkr.config' with 'plnkr.html' to create output file name;
|
// replace ending 'plnkr.json' with 'plnkr.no-link.html' to create output file name;
|
||||||
var outputFileName = configFileName.substr(0, configFileName.length - 'plnkr.config'.length) + 'plnkr.html';
|
var outputFileName = configFileName.substr(0, configFileName.length - 'plnkr.json'.length) + 'plnkr.no-link.html';
|
||||||
|
var altFileName;
|
||||||
|
if (destPath && destPath.length > 0) {
|
||||||
|
var partPath = path.dirname(path.relative(basePath, outputFileName));
|
||||||
|
var altFileName = path.join(destPath, partPath, path.basename(outputFileName)).replace('.no-link.', '.');
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
var config = initConfigAndCollectFileNames(configFileName);
|
var config = initConfigAndCollectFileNames(configFileName);
|
||||||
var postData = createPostData(config);
|
var postData = createPostData(config);
|
||||||
var html = createPlunkerHtml(postData);
|
var html = createPlunkerHtml(postData);
|
||||||
fs.writeFileSync(outputFileName, html, 'utf-8');
|
fs.writeFileSync(outputFileName, html, 'utf-8');
|
||||||
|
if (altFileName) {
|
||||||
|
var altDirName = path.dirname(altFileName);
|
||||||
|
if (!fs.existsSync(altDirName)) {
|
||||||
|
mkdirp.sync(altDirName);
|
||||||
|
}
|
||||||
|
fs.writeFileSync(altFileName, html, 'utf-8');
|
||||||
|
}
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
// if we fail delete the outputFile if it exists because it is an old one.
|
// if we fail delete the outputFile if it exists because it is an old one.
|
||||||
if (existsSync(outputFileName)) {
|
if (existsSync(outputFileName)) {
|
||||||
fs.unlinkSync(outputFileName);
|
fs.unlinkSync(outputFileName);
|
||||||
}
|
}
|
||||||
|
if (altFileName && existsSync(altFileName)) {
|
||||||
|
fs.unlinkSync(altFileName);
|
||||||
|
}
|
||||||
throw e;
|
throw e;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +94,7 @@ function initConfigAndCollectFileNames(configFileName) {
|
||||||
return path.join(basePath, fileName);
|
return path.join(basePath, fileName);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var defaultExcludes = [ '!**/node_modules/**','!**/typings/**','!**/tsconfig.json', '!**/plnkr.html', '!**/*.plnkr.html' ];
|
var defaultExcludes = [ '!**/node_modules/**','!**/typings/**','!**/tsconfig.json', '!**/*plnkr.json', '!**/*plnkr.html', '!**/*plnkr.no-link.html' ];
|
||||||
Array.prototype.push.apply(gpaths, defaultExcludes);
|
Array.prototype.push.apply(gpaths, defaultExcludes);
|
||||||
|
|
||||||
config.fileNames = globule.find(gpaths);
|
config.fileNames = globule.find(gpaths);
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
.l-main-section
|
.l-main-section
|
||||||
a(href='/docs/_examples/template-syntax/ts/src/plnkr.html') Live Example 0
|
a(href='/resources/live-examples/template-syntax/ts/src/plnkr.html') Live Example 0
|
||||||
|
|
||||||
:marked
|
:marked
|
||||||
[Live Example 1](/docs/_examples/template-syntax/ts/src/plnkr.html)
|
[Live Example 1](/resources/live-examples/template-syntax/ts/src/plnkr.html)
|
||||||
<a href='/docs/_examples/template-syntax/ts/src/plnkr.html'><code>Live Example 2</code></a>
|
|
||||||
|
|
Loading…
Reference in New Issue