summaryrefslogtreecommitdiffstats
path: root/tasks/docsite.js
diff options
context:
space:
mode:
authorManuel Carrasco Moñino <manolo@apache.org>2016-01-13 15:54:33 +0100
committerManuel Carrasco Moñino <manolo@apache.org>2016-01-13 15:54:33 +0100
commit16c8708ead2d1795e9b53a19d91ab8ac484101cc (patch)
treed8db55569576f42c892fbdf5496ac862a749d0b2 /tasks/docsite.js
parentb45e474633eb2c4b168f472e914b5134740d37d6 (diff)
parent985e9bf43a32fa5ae4b51198a70dc31197d3706d (diff)
downloadvaadin-core-16c8708ead2d1795e9b53a19d91ab8ac484101cc.tar.gz
vaadin-core-16c8708ead2d1795e9b53a19d91ab8ac484101cc.zip
Merge pull request #32 from vaadin/integration-examples
Integration examples
Diffstat (limited to 'tasks/docsite.js')
-rw-r--r--tasks/docsite.js88
1 files changed, 49 insertions, 39 deletions
diff --git a/tasks/docsite.js b/tasks/docsite.js
index e1abec6..3888808 100644
--- a/tasks/docsite.js
+++ b/tasks/docsite.js
@@ -45,7 +45,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);
@@ -53,47 +58,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);