diff --git a/Gruntfile.js b/Gruntfile.js index 4718c7cb6dbe4afa7ea14aaeb657ef1d67098dbe..8dcee340ef46cdd59a9631a3d77b2155c0802e6c 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -68,12 +68,17 @@ module.exports = function (grunt) { 'less:luma', 'less:backend' ], + /** * Documentation */ documentation: [ + 'replace:documentation', 'less:documentation', 'styledocco:documentation', + 'usebanner:documentationCss', + 'usebanner:documentationLess', + 'usebanner:documentationHtml', 'clean:var', 'clean:pub' ], @@ -82,12 +87,6 @@ module.exports = function (grunt) { 'mage-minify:legacy' ], - 'documentation-banners': [ - 'usebanner:documentationCss', - 'usebanner:documentationLess', - 'usebanner:documentationHtml' - ], - spec: function (theme) { var runner = require('./dev/tests/js/jasmine/spec_runner'); diff --git a/dev/tools/grunt/configs/replace.js b/dev/tools/grunt/configs/replace.js new file mode 100644 index 0000000000000000000000000000000000000000..453a963c4b89d9a12e393a8f91c5ef2d7600d77c --- /dev/null +++ b/dev/tools/grunt/configs/replace.js @@ -0,0 +1,46 @@ +/** + * Copyright © 2015 Magento. All rights reserved. + * See COPYING.txt for license details. + */ + +'use strict'; + +function findCopyright(lang) { + var copyrightText = { + firstLine: 'Copyright © 2015 Magento. All rights reserved.', + secondLine: 'See COPYING.txt for license details.' + }; + switch (lang) { + case 'less': + return new RegExp( + '// /\\*\\*\r\n// \\* ' + + copyrightText.firstLine + + '\r\n// \\* ' + + copyrightText.secondLine + + '\r\n// \\*/\r\n\r\n' + ); + break; + default: + return; + } +} + +module.exports = { + documentation: { + options: { + patterns: [{ + match: findCopyright('less'), + replacement: '' + }] + }, + files: [{ + expand: true, + flatten: true, + src: [ + '<%= path.doc %>/source/**/*.less' + ], + dest: '<%= path.doc %>/source/' + }] + } + +}; diff --git a/dev/tools/grunt/configs/usebanner.js b/dev/tools/grunt/configs/usebanner.js index fb952f050c2b906907decaec2cdf19783960ba1c..57158e4befe732faca53f705c71b2220d6b57ffe 100644 --- a/dev/tools/grunt/configs/usebanner.js +++ b/dev/tools/grunt/configs/usebanner.js @@ -5,22 +5,25 @@ 'use strict'; -var banner = { - firstLine: 'Copyright © 2015 Magento. All rights reserved.', - secondLine: 'See COPYING.txt for license details.', - - css: function () { - return '/**\n * ' + this.firstLine + '\n * ' + this.secondLine + '\n */\n'; - }, - - less: function () { - return '// /**\n// * ' + this.firstLine + '\n// * ' + this.secondLine + '\n// */\n'; - }, - - html: function () { - return '<!--\n/**\n * ' + this.firstLine + '\n * ' + this.secondLine + '\n */\n-->\n'; +function printCopyright(lang) { + var copyrightText = { + firstLine: 'Copyright © 2015 Magento. All rights reserved.', + secondLine: 'See COPYING.txt for license details.' + }; + switch (lang) { + case 'css': + return '/**\n * ' + copyrightText.firstLine + '\n * ' + copyrightText.secondLine + '\n */\n'; + break; + case 'less': + return '// /**\n// * ' + copyrightText.firstLine + '\n// * ' + copyrightText.secondLine + '\n// */\n'; + break; + case 'html': + return '<!--\n/**\n * ' + copyrightText.firstLine + '\n * ' + copyrightText.secondLine + '\n */\n-->\n'; + break; + default: + return; } -}; +} module.exports = { options: { @@ -29,7 +32,7 @@ module.exports = { }, setup: { options: { - banner: banner.css() + banner: printCopyright('css') }, files: { src: '<%= path.css.setup %>/*.css' @@ -37,7 +40,7 @@ module.exports = { }, documentationCss: { options: { - banner: banner.css() + banner: printCopyright('css') }, files: { src: '<%= path.doc %>/**/*.css' @@ -45,7 +48,7 @@ module.exports = { }, documentationLess: { options: { - banner: banner.less() + banner: printCopyright('less') }, files: { src: '<%= path.doc %>/**/*.less' @@ -53,7 +56,7 @@ module.exports = { }, documentationHtml: { options: { - banner: banner.html() + banner: printCopyright('html') }, files: { src: '<%= path.doc %>/**/*.html' diff --git a/package.json b/package.json index 55e65759502a19f9b7a8bed20ea637dbbeb615fc..c2f3cb1eaaf9edd5e19767c82f75782f022f1373 100644 --- a/package.json +++ b/package.json @@ -20,6 +20,7 @@ "grunt-contrib-less": "^0.12.0", "grunt-contrib-watch": "^0.6.1", "grunt-exec": "^0.4.6", + "grunt-replace": "^0.9.2", "grunt-styledocco": "^0.1.4", "grunt-template-jasmine-requirejs": "^0.2.3", "grunt-text-replace": "^0.4.0",