summaryrefslogtreecommitdiffstats
path: root/tasks
diff options
context:
space:
mode:
authorTomi Virkki <virkki@vaadin.com>2016-01-12 16:59:26 +0200
committerTomi Virkki <virkki@vaadin.com>2016-01-12 21:41:11 +0200
commitd8b0a67cbfe0bce683ee4005797e0bd84ba7a54d (patch)
treeaad9b3be4ae4719a9700570ac70e77deee066c3e /tasks
parent22b6379602dff09bf1b3a662a6e59f5d852be1ae (diff)
downloadvaadin-core-d8b0a67cbfe0bce683ee4005797e0bd84ba7a54d.tar.gz
vaadin-core-d8b0a67cbfe0bce683ee4005797e0bd84ba7a54d.zip
Moved and updated integration examples from vaadin-grid to vaadin-core-elements
Diffstat (limited to 'tasks')
-rw-r--r--tasks/docsite.js90
1 files changed, 50 insertions, 40 deletions
diff --git a/tasks/docsite.js b/tasks/docsite.js
index 46d2ac2..b81bcbc 100644
--- a/tasks/docsite.js
+++ b/tasks/docsite.js
@@ -18,7 +18,7 @@ var permalink = config.permalink;
var stagingPath = stagingBasePath + '/' + version;
var modify = require('gulp-modify');
var rootZip = 'target/';
-var fileZip = 'docsite.zip'
+var fileZip = 'docsite.zip';
gulp.task('cdn:docsite:clean', function() {
fs.removeSync(docPath);
@@ -46,7 +46,12 @@ gulp.task('cdn:docsite:core-elements', function() {
.pipe(gulp.dest(docPath));
});
-var doctasks = ['cdn:docsite:core-elements'];
+gulp.task('cdn:docsite:core-elements-integrations', function() {
+ return getDocModifyTask('demo/**', docPath + '/integrations');
+});
+
+var doctasks = ['cdn:docsite:core-elements', 'cdn:docsite:core-elements-integrations'];
+
config.coreElements.forEach(function (n) {
var task = 'cdn:docsite:' + n;
doctasks.push(task);
@@ -54,47 +59,52 @@ config.coreElements.forEach(function (n) {
var elementDocsite = docPath + '/' + n;
var elementDemo = stagingPath + '/' + n + '/demo/**';
- gutil.log('Generating site documentation from ' + elementDemo + ' into ' + elementDocsite);
- fs.mkdirsSync(elementDocsite);
- return gulp.src([elementDemo, '!**/*-embed.html'])
- // Remove bad tags
- .pipe(replace(/^.*<(!doctype|\/?html|\/?head|\/?body|meta|title).*>.*\n/img, ''))
- // Uncomment metainfo, and enclose all the example in {% raw %} ... {% endraw %} to avoid liquid conflicts
- // We use gulp-modify instead of replace in order to handle the github url for this file
- .pipe(modify({
- fileModifier: function(file, contents) {
- var re = new RegExp(".*/" + n + "/");
- var gh = 'https://github.com/vaadin/' + n + '/edit/master/' + file.path.replace(re, '');
- return contents.replace(/^.*<!--[ \n]+([\s\S]*?title:[\s\S]*?)[ \n]+-->.*\n([\s\S]*)/img,
- '---\n$1\nsourceurl: ' + gh + '\n---\n{% raw %}\n$2\n{% endraw %}');
- }
- }))
- .pipe(replace(/^.*<section>[\s\S]*?table-of-contents[\s\S]*?<\/section>.*\n/im, ''))
- // Add ids to headers, so as site configures permalinks
- .pipe(replace(/<h(\d+)>(.*)(<\/h\d+>)/img, function($0, $1, $2, $3){
- var id = $2.trim().toLowerCase().replace(/[^\w]+/g,'_');
- return '<h' + $1 + ' id="' + id + '">' + $2 + $3;
- }))
- // Remove webcomponents polyfill since it's added at top of the site
- .pipe(replace(/^.*<script.*?\/webcomponents.*\.js[\"'].*?<\/script>\s*?\n?/img, ''))
- // embed files are displayed as iframe, we don't remove above fragments like body or polyfill
- .pipe(addsrc(elementDemo + '/*-embed.html'))
- // Remove Analytics
- .pipe(replace(/^.*<script.*?ga\.js[\"'].*?<\/script>\s*?\n?/img, ''))
- // Adjust bowerComponents variable in common.html
- .pipe(replace(/(bowerComponents *= *)'..\/..\/'/, "$1'../bower_components/'"))
- // Adjust location of the current component in bower_components (..)
- .pipe(replace(/(src|href)=("|')\.\.(\/\w)/mg, '$1=$2../bower_components/' + n + '$3'))
- // Adjust location of dependencies in bower_components (../..)
- .pipe(replace(/(src|href)=("|')(.*?)\.\.\/\.\.\//mg, '$1=$2../bower_components/'))
- // Remove references to demo.css file
- .pipe(replace(/^.*<link.*demo.css.*\n/im, ''))
- // Remove table of contents
- .pipe(replace(/^.*table-of-contents.html.*\n/im, ''))
- .pipe(gulp.dest(elementDocsite));
+ return getDocModifyTask(elementDemo, elementDocsite, n);
});
});
+function getDocModifyTask(sourceFiles, targetFolder, n) {
+ fs.mkdirsSync(targetFolder);
+ gutil.log('Generating site documentation from ' + sourceFiles + ' into ' + targetFolder);
+
+ return gulp.src([sourceFiles, '!**/*-embed.html'])
+ // Remove bad tags
+ .pipe(replace(/^.*<(!doctype|\/?html|\/?head|\/?body|meta|title).*>.*\n/img, ''))
+ // Uncomment metainfo, and enclose all the example in {% raw %} ... {% endraw %} to avoid liquid conflicts
+ // We use gulp-modify instead of replace in order to handle the github url for this file
+ .pipe(modify({
+ fileModifier: function(file, contents) {
+ var re = new RegExp(".*/" + n + "/");
+ var gh = 'https://github.com/vaadin/' + n + '/edit/master/' + file.path.replace(re, '');
+ return contents.replace(/^.*<!--[ \n]+([\s\S]*?title:[\s\S]*?)[ \n]+-->.*\n([\s\S]*)/img,
+ '---\n$1\nsourceurl: ' + gh + '\n---\n{% raw %}\n$2\n{% endraw %}');
+ }
+ }))
+ .pipe(replace(/^.*<section>[\s\S]*?table-of-contents[\s\S]*?<\/section>.*\n/im, ''))
+ // Add ids to headers, so as site configures permalinks
+ .pipe(replace(/<h(\d+)>(.*)(<\/h\d+>)/img, function($0, $1, $2, $3){
+ var id = $2.trim().toLowerCase().replace(/[^\w]+/g,'_');
+ return '<h' + $1 + ' id="' + id + '">' + $2 + $3;
+ }))
+ // Remove webcomponents polyfill since it's added at top of the site
+ .pipe(replace(/^.*<script.*?\/webcomponents.*\.js[\"'].*?<\/script>\s*?\n?/img, ''))
+ // embed files are displayed as iframe, we don't remove above fragments like body or polyfill
+ .pipe(addsrc(sourceFiles + '/*-embed.html'))
+ // Remove Analytics
+ .pipe(replace(/^.*<script.*?ga\.js[\"'].*?<\/script>\s*?\n?/img, ''))
+ // Adjust bowerComponents variable in common.html
+ .pipe(replace(/(bowerComponents *= *)'..\/..\/'/, "$1'../bower_components/'"))
+ // Adjust location of the current component in bower_components (..)
+ .pipe(replace(/(src|href)=("|')\.\.(\/\w)/mg, '$1=$2../bower_components/' + n + '$3'))
+ // Adjust location of dependencies in bower_components (../..)
+ .pipe(replace(/(src|href)=("|')(.*?)\.\.\/\.\.\//mg, '$1=$2../bower_components/'))
+ // Remove references to demo.css file
+ .pipe(replace(/^.*<link.*demo.css.*\n/im, ''))
+ // Remove table of contents
+ .pipe(replace(/^.*table-of-contents.html.*\n/im, ''))
+ .pipe(gulp.dest(targetFolder));
+}
+
gulp.task('cdn:docsite:zip', doctasks, function() {
var src = docPath + '/**/*';
gutil.log("Creating docsite zip " + docPath + " -> " + rootZip + fileZip);