From f562c31e824f573d9a3254a1eacb4981b29290eb Mon Sep 17 00:00:00 2001 From: SerenaFeng Date: Fri, 12 May 2017 01:49:57 +0800 Subject: add web portal framework for TestAPI Change-Id: I62cea8b59ffe6a6cde98051c130f4502c07d3557 Signed-off-by: SerenaFeng --- .../grunt/bs-glyphicons-data-generator.js | 41 ++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js (limited to 'utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js') diff --git a/utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js b/utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js new file mode 100644 index 000000000..339fd0ffe --- /dev/null +++ b/utils/test/testapi/3rd_party/static/testapi-ui/assets/lib/bootstrap/grunt/bs-glyphicons-data-generator.js @@ -0,0 +1,41 @@ +/*! + * Bootstrap Grunt task for Glyphicons data generation + * http://getbootstrap.com + * Copyright 2014 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ +'use strict'; +var fs = require('fs'); + +module.exports = function generateGlyphiconsData(grunt) { + // Pass encoding, utf8, so `readFileSync` will return a string instead of a + // buffer + var glyphiconsFile = fs.readFileSync('less/glyphicons.less', 'utf8'); + var glyphiconsLines = glyphiconsFile.split('\n'); + + // Use any line that starts with ".glyphicon-" and capture the class name + var iconClassName = /^\.(glyphicon-[a-zA-Z0-9-]+)/; + 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'; + var glyphiconsYml = 'docs/_data/glyphicons.yml'; + for (var i = 0, len = glyphiconsLines.length; i < len; i++) { + var match = glyphiconsLines[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'); + } + + try { + fs.writeFileSync(glyphiconsYml, glyphiconsData); + } + catch (err) { + grunt.fail.warn(err); + } + grunt.log.writeln('File ' + glyphiconsYml.cyan + ' created.'); +}; -- cgit 1.2.3-korg