aboutsummaryrefslogtreecommitdiff
path: root/Gruntfile.js
diff options
context:
space:
mode:
authorMark Otto <[email protected]>2014-01-09 20:33:55 -0800
committerMark Otto <[email protected]>2014-01-09 20:33:55 -0800
commitea20f44815b535975d1f1416fee15bd1ea7acdb3 (patch)
treeedb73c6ae943629dbdc51d3350a50a079f7a2f7e /Gruntfile.js
parent04161a8c753c5f9ef83dd1f0848a17e8c4ab155c (diff)
parent7f153974e10980dccbdd485e63941b591e925148 (diff)
downloadbootstrap-ea20f44815b535975d1f1416fee15bd1ea7acdb3.tar.xz
bootstrap-ea20f44815b535975d1f1416fee15bd1ea7acdb3.zip
Merge branch 'master' into docs_derp
Conflicts: docs/assets/css/docs.css
Diffstat (limited to 'Gruntfile.js')
-rw-r--r--Gruntfile.js82
1 files changed, 36 insertions, 46 deletions
diff --git a/Gruntfile.js b/Gruntfile.js
index 2c9e4f985..2d70b014c 100644
--- a/Gruntfile.js
+++ b/Gruntfile.js
@@ -10,8 +10,11 @@ module.exports = function (grunt) {
return string.replace(/[-\\^$*+?.()|[\]{}]/g, '\\$&')
}
+ var BsLessdocParser = require('./docs/grunt/bs-lessdoc-parser.js')
var fs = require('fs')
- var btoa = require('btoa')
+ var generateGlyphiconsData = require('./docs/grunt/bs-glyphicons-data-generator.js')
+ var generateRawFilesJs = require('./docs/grunt/bs-raw-files-generator.js')
+ var path = require('path')
// Project configuration.
grunt.initConfig({
@@ -20,7 +23,7 @@ module.exports = function (grunt) {
pkg: grunt.file.readJSON('package.json'),
banner: '/*!\n' +
' * Bootstrap v<%= pkg.version %> (<%= pkg.homepage %>)\n' +
- ' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
+ ' * Copyright 2011-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under <%= _.pluck(pkg.licenses, "type") %> (<%= _.pluck(pkg.licenses, "url") %>)\n' +
' */\n',
jqueryCheck: 'if (typeof jQuery === "undefined") { throw new Error("Bootstrap requires jQuery") }\n\n',
@@ -45,6 +48,9 @@ module.exports = function (grunt) {
},
assets: {
src: ['docs/assets/js/application.js', 'docs/assets/js/customizer.js']
+ },
+ docsGrunt: {
+ src: ['docs/grunt/*.js']
}
},
@@ -63,6 +69,9 @@ module.exports = function (grunt) {
},
assets: {
src: ['docs/assets/js/application.js', 'docs/assets/js/customizer.js']
+ },
+ docsGrunt: {
+ src: ['docs/grunt/*.js']
}
},
@@ -114,7 +123,7 @@ module.exports = function (grunt) {
options: {
banner: '/*!\n' +
' * Bootstrap Docs (<%= pkg.homepage %>)\n' +
- ' * Copyright <%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
+ ' * Copyright 2011-<%= grunt.template.today("yyyy") %> <%= pkg.author %>\n' +
' * Licensed under the Creative Commons Attribution 3.0 Unported License. For\n' +
' * details, see http://creativecommons.org/licenses/by/3.0/.\n' +
' */\n',
@@ -127,7 +136,7 @@ module.exports = function (grunt) {
'docs/assets/js/filesaver.js',
'docs/assets/js/customizer.js'
],
- dest: 'docs/assets/js/customize.js'
+ dest: 'docs/assets/js/customize.min.js'
}
},
@@ -208,7 +217,7 @@ module.exports = function (grunt) {
cwd: './dist',
src: [
'{css,js}/*.min.*',
- '{css}/*.map',
+ 'css/*.map',
'fonts/*'
],
dest: 'docs/dist'
@@ -235,6 +244,23 @@ module.exports = function (grunt) {
docs: {}
},
+ jade: {
+ compile: {
+ options: {
+ pretty: true,
+ data: function () {
+ var filePath = path.join(__dirname, 'less/variables.less');
+ var fileContent = fs.readFileSync(filePath, {encoding: 'utf8'});
+ var parser = new BsLessdocParser(fileContent);
+ return {sections: parser.parseFile()};
+ }
+ },
+ files: {
+ 'docs/_includes/customizer-variables.html': 'docs/customizer-variables.jade'
+ }
+ }
+ },
+
validation: {
options: {
charset: 'utf-8',
@@ -300,7 +326,7 @@ module.exports = function (grunt) {
var testSubtasks = [];
// Skip core tests if running a different subset of the test suite
if (!process.env.TWBS_TEST || process.env.TWBS_TEST === 'core') {
- testSubtasks = testSubtasks.concat(['dist-css', 'jshint', 'jscs', 'qunit']);
+ testSubtasks = testSubtasks.concat(['dist-css', 'csslint', 'jshint', 'jscs', 'qunit', 'build-customizer-vars-form']);
}
// Skip HTML validation if running a different subset of the test suite
if (!process.env.TWBS_TEST || process.env.TWBS_TEST === 'validate-html') {
@@ -335,46 +361,10 @@ module.exports = function (grunt) {
// This can be overzealous, so its changes should always be manually reviewed!
grunt.registerTask('change-version-number', ['sed']);
- grunt.registerTask('build-glyphicons-data', function () {
- // Pass encoding, utf8, so `readFileSync` will return a string instead of a
- // buffer
- var glyphiconsFile = fs.readFileSync('less/glyphicons.less', 'utf8')
- var glpyhiconsLines = glyphiconsFile.split('\n')
-
- // Use any line that starts with ".glyphicon-" and capture the class name
- var iconClassName = /^\.(glyphicon-[^\s]+)/
- var glyphiconsData = '# This file is generated via Grunt task. **Do not edit directly.** \n' +
- '# See the \'build-glyphicons-data\' task in Gruntfile.js.\n\n';
- for (var i = 0, len = glpyhiconsLines.length; i < len; i++) {
- var match = glpyhiconsLines[i].match(iconClassName)
-
- if (match != null) {
- glyphiconsData += '- ' + match[1] + '\n'
- }
- }
-
- // Create the `_data` directory if it doesn't already exist
- if (!fs.existsSync('docs/_data')) fs.mkdirSync('docs/_data')
-
- fs.writeFileSync('docs/_data/glyphicons.yml', glyphiconsData)
- });
+ grunt.registerTask('build-glyphicons-data', generateGlyphiconsData);
// task for building customizer
- grunt.registerTask('build-customizer', 'Add scripts/less files to customizer.', function () {
- function getFiles(type) {
- var files = {}
- fs.readdirSync(type)
- .filter(function (path) {
- return type == 'fonts' ? true : new RegExp('\\.' + type + '$').test(path)
- })
- .forEach(function (path) {
- var fullPath = type + '/' + path
- return files[path] = (type == 'fonts' ? btoa(fs.readFileSync(fullPath)) : fs.readFileSync(fullPath, 'utf8'))
- })
- return 'var __' + type + ' = ' + JSON.stringify(files) + '\n'
- }
-
- var files = getFiles('js') + getFiles('less') + getFiles('fonts')
- fs.writeFileSync('docs/assets/js/raw-files.js', files)
- });
+ grunt.registerTask('build-customizer', ['build-customizer-vars-form', 'build-raw-files']);
+ grunt.registerTask('build-customizer-vars-form', ['jade']);
+ grunt.registerTask('build-raw-files', 'Add scripts/less files to customizer.', generateRawFilesJs);
};