Permalink
Browse files

Merge pull request #16 from darcyclarke/develop

Added fix for sections not including all blocks
  • Loading branch information...
2 parents f479e94 + 01cfa46 commit 83eac086a8ec0b45b2935eb26d3da4d5230209ce @darcyclarke darcyclarke committed Mar 12, 2013
Showing with 76 additions and 11 deletions.
  1. +0 −6 package.json
  2. +74 −3 tasks/DSS.js
  3. +1 −1 template/assets/css/styles.css
  4. +1 −1 template/index.mustache
View
@@ -15,12 +15,6 @@
"bugs": {
"url": "https://github.com/darcyclarke/DSS/issues"
},
- "licenses": [
- {
- "type": "MIT",
- "url": "https://github.com/darcyclarke/DSS/blob/master/LICENSE-MIT"
- }
- ],
"main": "Gruntfile.js",
"engines": {
"node": ">= 0.8.0"
View
@@ -87,6 +87,64 @@ module.exports = function(grunt) {
};
/*
+ * Check if object is empty
+ *
+ * @param (Object) The object to check if it's empty
+ * @return (Boolean) The result of the test
+ */
+ _dss.isEmpty = function(obj){
+ if (obj === null || obj === undefined)
+ return true;
+ if (obj.length && obj.length > 0)
+ return false;
+ if (obj.length === 0)
+ return true;
+ for(var key in obj){
+ if(Object.prototype.hasOwnProperty.call(obj, key))
+ return false;
+ }
+ return true;
+ }
+
+ /*
+ * Iterate over an object
+ *
+ * @param (Object) The object to iterate over
+ * @param (Function) Callback function to use when iterating
+ * @param (Object) Optional context to pass to iterator
+ */
+ _dss.each = function(obj, iterator, context){
+ if(obj == null) return;
+ if(obj.length === +obj.length){
+ for(var i = 0, l = obj.length; i < l; i++){
+ if(iterator.call(context, obj[i], i, obj) === {}) return;
+ }
+ } else {
+ for(var key in obj){
+ if(_.has(obj, key)){
+ if(iterator.call(context, obj[key], key, obj) === {}) return;
+ }
+ }
+ }
+ };
+
+ /*
+ * Extend an object
+ *
+ * @param (Object) The object to extend
+ */
+ _dss.extend = function(obj){
+ _dss.each(Array.prototype.slice.call(arguments, 1), function(source){
+ if(source){
+ for(var prop in source){
+ obj[prop] = source[prop];
+ }
+ }
+ });
+ return obj;
+ };
+
+ /*
* Squeeze unnecessary extra characters/string
*
* @param (String) The string to be squeeze
@@ -120,7 +178,7 @@ module.exports = function(grunt) {
_blocks = [],
parsed = '',
blocks = [],
- temp = [],
+ temp = {},
lines = grunt.file.read(options.file),
lineNum = 0;
@@ -287,15 +345,28 @@ module.exports = function(grunt) {
inside_single_line_block = false;
current_block = '';
}
+
});
// Create new blocks with custom parsing
_parsed = true;
_blocks.forEach(function(block, index){
- // Detect if block is DSS and add to blocks
+
+ // Detect if we're done
+ var check = block.match(end, 'gi');
+
+ // Detect if we need to add to temporary array
block = normalize(block);
if(_dss.detect(block))
- blocks.push(parser(index, lines, block));
+ temp = _dss.extend(temp, parser(index, lines, block));
+
+ // Push into blocks if we're done
+ if(check){
+ if(!_dss.isEmpty(temp))
+ blocks.push(temp);
+ temp = {};
+ }
+
});
callback({ file: options.file, blocks: blocks });
@@ -72,7 +72,7 @@ td { vertical-align: top; }
header {
width: 100%;
background: #efefef;
- padding: 15% 60px;
+ padding: 10% 60px;
}
header h1 {
View
@@ -18,7 +18,7 @@
<nav role="main">
<ul>
{{#files}}
- <li><a href="#" data-file="{{file}}">{{file}}</a></li>
+ <li><a href="#{{file}}" data-file="{{file}}">{{file}}</a></li>
{{/files}}
</ul>
</nav>

0 comments on commit 83eac08

Please sign in to comment.