Update Semantic to 2.1

Ticket #56
This commit is contained in:
Tim Schumacher 2016-06-10 00:34:34 +02:00
parent 3f1e728781
commit 4385f1acbc
425 changed files with 59924 additions and 37200 deletions

View file

@ -8,6 +8,7 @@ var
// node dependencies
console = require('better-console'),
fs = require('fs'),
map = require('map-stream'),
// gulp dependencies
autoprefixer = require('gulp-autoprefixer'),
@ -28,10 +29,13 @@ var
config = require('../config/docs'),
// install config
tasks = require('../config/tasks'),
configSetup = require('../config/project/config'),
tasks = require('../config/project/tasks'),
install = require('../config/project/install'),
// metadata parsing
metadata = require('./metadata'),
// shorthand
globs,
assets,
@ -64,17 +68,44 @@ module.exports = function(callback) {
output = config.paths.output;
source = config.paths.source;
/*--------------
Parse metadata
---------------*/
// parse all *.html.eco in docs repo, data will end up in
// metadata.result object. Note this assumes that the docs
// repository is present and in proper directory location as
// specified by docs.json.
console.info('Building Metadata');
gulp.src(config.paths.template.eco + globs.eco)
.pipe(map(metadata.parser))
.on('end', function() {
fs.writeFile(output.metadata + '/metadata.json', JSON.stringify(metadata.result, null, 2));
})
;
/*--------------
Copy Examples
---------------*/
console.info('Copying examples');
// copy src/ to server
gulp.src('examples/**/*.*')
.pipe(gulp.dest(output.examples))
.pipe(print(log.created))
;
/*--------------
Copy Source
---------------*/
console.info('Copying LESS source');
// copy src/ to server
gulp.src('src/**/*.*')
.pipe(gulp.dest(output.less))
.pipe(print(log.created))
;
/*--------------
Build
---------------*/
@ -155,4 +186,4 @@ module.exports = function(callback) {
})
;
};
};

View file

@ -0,0 +1,138 @@
/*******************************
Summarize Docs
*******************************/
var
// node dependencies
console = require('better-console'),
fs = require('fs'),
YAML = require('yamljs')
;
var data = {};
/**
* Test for prefix in string.
* @param {string} str
* @param {string} prefix
* @return {boolean}
*/
function startsWith(str, prefix) {
return str.indexOf(prefix) === 0;
};
function inArray(needle, haystack) {
var length = haystack.length;
for(var i = 0; i < length; i++) {
if(haystack[i] == needle) return true;
}
return false;
}
/**
* Parses a file for metadata and stores result in data object.
* @param {File} file - object provided by map-stream.
* @param {function(?,File)} - callback provided by map-stream to
* reply when done.
*/
function parser(file, callback) {
// file exit conditions
if(file.isNull()) {
return callback(null, file); // pass along
}
if(file.isStream()) {
return callback(new Error('Streaming not supported'));
}
try {
var
/** @type {string} */
text = String(file.contents.toString('utf8')),
lines = text.split('\n'),
filename = file.path.substring(0, file.path.length - 4),
key = 'server/documents',
position = filename.indexOf(key)
;
// exit conditions
if(!lines) {
return;
}
if(position < 0) {
return callback(null, file);
}
filename = filename.substring(position + key.length + 1, filename.length);
var
lineCount = lines.length,
active = false,
yaml = [],
categories = [
'UI Element',
'UI Global',
'UI Collection',
'UI View',
'UI Module',
'UI Behavior'
],
index,
meta,
line
;
for(index = 0; index < lineCount; index++) {
line = lines[index];
// Wait for metadata block to begin
if(!active) {
if(startsWith(line, '---')) {
active = true;
}
continue;
}
// End of metadata block, stop parsing.
if(startsWith(line, '---')) {
break;
}
yaml.push(line);
}
// Parse yaml.
meta = YAML.parse(yaml.join('\n'));
if(meta && meta.type && meta.title && inArray(meta.type, categories) ) {
meta.category = meta.type;
meta.filename = filename;
meta.url = '/' + filename;
meta.title = meta.title;
// Primary key will by filepath
data[meta.element] = meta;
}
else {
// skip
// console.log(meta);
}
}
catch(error) {
console.log(error, filename);
}
callback(null, file);
}
/**
* Export function expected by map-stream.
*/
module.exports = {
result : data,
parser : parser
};

View file

@ -28,8 +28,8 @@ var
config = require('../config/docs'),
// task config
tasks = require('../config/tasks'),
configSetup = require('../config/project/config'),
tasks = require('../config/project/tasks'),
install = require('../config/project/install'),
// shorthand
@ -76,6 +76,24 @@ module.exports = function () {
})
;
/*--------------
Copy Examples
---------------*/
gulp
.watch([
'examples/**/*.*'
], function(file) {
console.clear();
return gulp.src(file.path, {
base: 'examples/'
})
.pipe(gulp.dest(output.examples))
.pipe(print(log.created))
;
})
;
/*--------------
Watch CSS
---------------*/
@ -111,14 +129,15 @@ module.exports = function () {
---------------*/
// recompile on *.override , *.variable change
isConfig = (file.path.indexOf('theme.config') !== -1);
isConfig = (file.path.indexOf('theme.config') !== -1 || file.path.indexOf('site.variables') !== -1);
isPackagedTheme = (file.path.indexOf(source.themes) !== -1);
isSiteTheme = (file.path.indexOf(source.site) !== -1);
isDefinition = (file.path.indexOf(source.definitions) !== -1);
if(isConfig) {
console.info('Change detected in theme config, rebuild docs with `build-docs`');
// impossible to tell which file was updated in theme.config
// console.info('Rebuilding all files');
// cant rebuild paths are wrong
// gulp.start('build-docs');
return;
}
else if(isPackagedTheme) {