styledocco
Version:
Generate documentation and style guides with design patterns from stylesheets.
680 lines (643 loc) • 25.9 kB
HTML
<html lang="en">
<head>
<title>Code coverage report for src/gather.js</title>
<meta charset="utf-8">
<link rel="stylesheet" href="../prettify.css">
<style>
body, html {
margin:0; padding: 0;
}
body {
font-family: Helvetica Neue, Helvetica,Arial;
font-size: 10pt;
}
div.header, div.footer {
background: #eee;
padding: 1em;
}
div.header {
z-index: 100;
position: fixed;
top: 0;
border-bottom: 1px solid #666;
width: 100%;
}
div.footer {
border-top: 1px solid #666;
}
div.body {
margin-top: 10em;
}
div.meta {
font-size: 90%;
text-align: center;
}
h1, h2, h3 {
font-weight: normal;
}
h1 {
font-size: 12pt;
}
h2 {
font-size: 10pt;
}
pre {
font-family: Consolas, Menlo, Monaco, monospace;
margin: 0;
padding: 0;
line-height: 14px;
font-size: 14px;
-moz-tab-size: 2;
-o-tab-size: 2;
tab-size: 2;
}
div.path { font-size: 110%; }
div.path a:link, div.path a:visited { color: #000; }
table.coverage { border-collapse: collapse; margin:0; padding: 0 }
table.coverage td {
margin: 0;
padding: 0;
color: #111;
vertical-align: top;
}
table.coverage td.line-count {
width: 50px;
text-align: right;
padding-right: 5px;
}
table.coverage td.line-coverage {
color: #777 ;
text-align: right;
border-left: 1px solid #666;
border-right: 1px solid #666;
}
table.coverage td.text {
}
table.coverage td span.cline-any {
display: inline-block;
padding: 0 5px;
width: 40px;
}
table.coverage td span.cline-neutral {
background: #eee;
}
table.coverage td span.cline-yes {
background: #b5d592;
color: #999;
}
table.coverage td span.cline-no {
background: #fc8c84;
}
.cstat-yes { color: #111; }
.cstat-no { background: #fc8c84; color: #111; }
.fstat-no { background: #ffc520; color: #111 ; }
.cbranch-no { background: yellow ; color: #111; }
.cstat-skip { background: #ddd; color: #111; }
.fstat-skip { background: #ddd; color: #111 ; }
.cbranch-skip { background: #ddd ; color: #111; }
.missing-if-branch {
display: inline-block;
margin-right: 10px;
position: relative;
padding: 0 4px;
background: black;
color: yellow;
}
.skip-if-branch {
display: none;
margin-right: 10px;
position: relative;
padding: 0 4px;
background: #ccc;
color: white;
}
.missing-if-branch .typ, .skip-if-branch .typ {
color: inherit ;
}
.entity, .metric { font-weight: bold; }
.metric { display: inline-block; border: 1px solid #333; padding: 0.3em; background: white; }
.metric small { font-size: 80%; font-weight: normal; color: #666; }
div.coverage-summary table { border-collapse: collapse; margin: 3em; font-size: 110%; }
div.coverage-summary td, div.coverage-summary table th { margin: 0; padding: 0.25em 1em; border-top: 1px solid #666; border-bottom: 1px solid #666; }
div.coverage-summary th { text-align: left; border: 1px solid #666; background: #eee; font-weight: normal; }
div.coverage-summary th.file { border-right: none ; }
div.coverage-summary th.pic { border-left: none ; text-align: right; }
div.coverage-summary th.pct { border-right: none ; }
div.coverage-summary th.abs { border-left: none ; text-align: right; }
div.coverage-summary td.pct { text-align: right; border-left: 1px solid #666; }
div.coverage-summary td.abs { text-align: right; font-size: 90%; color: #444; border-right: 1px solid #666; }
div.coverage-summary td.file { text-align: right; border-left: 1px solid #666; white-space: nowrap; }
div.coverage-summary td.pic { min-width: 120px ; }
div.coverage-summary a:link { text-decoration: none; color: #000; }
div.coverage-summary a:visited { text-decoration: none; color: #333; }
div.coverage-summary a:hover { text-decoration: underline; }
div.coverage-summary tfoot td { border-top: 1px solid #666; }
div.coverage-summary .yui3-datatable-sort-indicator, div.coverage-summary .dummy-sort-indicator {
height: 10px;
width: 7px;
display: inline-block;
margin-left: 0.5em;
}
div.coverage-summary .yui3-datatable-sort-indicator {
background: url("http://yui.yahooapis.com/3.6.0/build/datatable-sort/assets/skins/sam/sort-arrow-sprite.png") no-repeat scroll 0 0 transparent;
}
div.coverage-summary .yui3-datatable-sorted .yui3-datatable-sort-indicator {
background-position: 0 -20px;
}
div.coverage-summary .yui3-datatable-sorted-desc .yui3-datatable-sort-indicator {
background-position: 0 -10px;
}
.high { background: #b5d592 ; }
.medium { background: #ffe87c ; }
.low { background: #fc8c84 ; }
span.cover-fill, span.cover-empty {
display:inline-block;
border:1px solid #444;
background: white;
height: 12px;
}
span.cover-fill {
background: #ccc;
border-right: 1px solid #444;
}
span.cover-empty {
background: white;
border-left: none;
}
span.cover-full {
border-right: none ;
}
pre.prettyprint {
border: none ;
padding: 0 ;
margin: 0 ;
}
.com { color: #999 ; }
.ignore-none { color: #999; font-weight: normal; }
</style>
</head>
<body>
<div class="header low">
<h1>Code coverage report for <span class="entity">src/gather.js</span></h1>
<h2>
Statements: <span class="metric">40.51% <small>(32 / 79)</small></span>
Branches: <span class="metric">25% <small>(8 / 32)</small></span>
Functions: <span class="metric">33.33% <small>(10 / 30)</small></span>
Lines: <span class="metric">46.77% <small>(29 / 62)</small></span>
Ignored: <span class="metric"><span class="ignore-none">none</span></span>
</h2>
<div class="path"><a href="../index.html">All files</a> » <a href="index.html">src/</a> » gather.js</div>
</div>
<div class="body">
<pre><table class="coverage">
<tr><td class="line-count">1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120</td><td class="line-coverage"><span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">20</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">1</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">3</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">20</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">10</span>
<span class="cline-any cline-yes">10</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-yes">2</span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-no"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span>
<span class="cline-any cline-neutral"> </span></td><td class="text"><pre class="prettyprint lang-js">// vim: set shiftwidth=2: expandtab:
'use strict';
var fs = require('fs');
var async = require('async');
var findit = require('findit');
var jade = require('jade');
var path = require('path');
var helper = require('./helper');
// Find first file matching `re` in `dir`.
var findFile = <span class="fstat-no" title="function not covered" >function(dir, re, cb) {</span>
<span class="cstat-no" title="statement not covered" > fs.stat(dir, <span class="fstat-no" title="function not covered" >function(err, stat) {</span></span>
<span class="cstat-no" title="statement not covered" > var files = fs.readdir(dir, <span class="fstat-no" title="function not covered" >function(err, files) {</span></span>
<span class="cstat-no" title="statement not covered" > files = files.sort().filter(<span class="fstat-no" title="function not covered" >function(file) {</span> <span class="cstat-no" title="statement not covered" >return file.match(re); </span>});</span>
<span class="cstat-no" title="statement not covered" > if (!files.length) <span class="cstat-no" title="statement not covered" >cb(new Error('No file found.'));</span></span>
else <span class="cstat-no" title="statement not covered" >cb(null, path.join(dir, files[0]));</span>
});
});
};
var getFiles = function(inPath, cb) {
fs.stat(inPath, function(err, stat) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (err != null) <span class="cstat-no" title="statement not covered" >return cb(err);</span>
<span class="missing-if-branch" title="if path not taken" >I</span>if (stat.isFile()) {
<span class="cstat-no" title="statement not covered" > cb(null, [ inPath ]);</span>
} else {
var finder = findit(inPath);
var files = [];
finder.on('file', function(file) { files.push(file); });
finder.on('end', function() { cb(null, files); });
}
});
};
var resourcesDir = __dirname + '/../share/';
// TODO Write unit tests for these
module.exports = function(options) {
// TODO: Cache each method result so that we can treat these as resources.
return {
template: <span class="fstat-no" title="function not covered" >function(cb) {</span>
<span class="cstat-no" title="statement not covered" > fs.readFile(resourcesDir + 'docs.jade', 'utf8', <span class="fstat-no" title="function not covered" >function(err, contents) {</span></span>
<span class="cstat-no" title="statement not covered" > if (err != null) <span class="cstat-no" title="statement not covered" >return cb(err);</span></span>
<span class="cstat-no" title="statement not covered" > cb(null, jade.compile(contents));</span>
});
},
docs: <span class="fstat-no" title="function not covered" >function(cb) {</span>
<span class="cstat-no" title="statement not covered" > async.parallel({</span>
css: async.apply(fs.readFile, resourcesDir + 'docs.css', 'utf8'),
js: <span class="fstat-no" title="function not covered" >function(cb) {</span>
<span class="cstat-no" title="statement not covered" > async.parallel([</span>
async.apply(fs.readFile, resourcesDir + 'docs.ui.js', 'utf8'),
async.apply(fs.readFile, resourcesDir + 'docs.previews.js', 'utf8')
], <span class="fstat-no" title="function not covered" >function(err, res) {</span>
<span class="cstat-no" title="statement not covered" > if (err != null) <span class="cstat-no" title="statement not covered" >return cb(err);</span></span>
<span class="cstat-no" title="statement not covered" > cb(null, res.join(''));</span>
});
}
}, cb);
},
// Extra JavaScript and CSS files to include in previews.
previews: <span class="fstat-no" title="function not covered" >function(cb) {</span>
<span class="cstat-no" title="statement not covered" > fs.readFile(resourcesDir + 'previews.js', 'utf8', <span class="fstat-no" title="function not covered" >function(err, js) {</span></span>
<span class="cstat-no" title="statement not covered" > if (err != null) <span class="cstat-no" title="statement not covered" >return cb(err);</span></span>
<span class="cstat-no" title="statement not covered" > var code = { js: js, css: '' };</span>
<span class="cstat-no" title="statement not covered" > var files = options.include.filter(<span class="fstat-no" title="function not covered" >function(file) {</span></span>
<span class="cstat-no" title="statement not covered" > return helper.inArray(['.css', '.js'], path.extname(file));</span>
});
<span class="cstat-no" title="statement not covered" > async.filter(files, path.exists, <span class="fstat-no" title="function not covered" >function(files) {</span></span>
<span class="cstat-no" title="statement not covered" > async.reduce(files, code, <span class="fstat-no" title="function not covered" >function(tot, cur, cb) {</span></span>
<span class="cstat-no" title="statement not covered" > fs.readFile(cur, 'utf8', <span class="fstat-no" title="function not covered" >function(err, contents) {</span></span>
<span class="cstat-no" title="statement not covered" > if (err != null) <span class="cstat-no" title="statement not covered" >return cb(err);</span></span>
<span class="cstat-no" title="statement not covered" > tot[path.extname(cur).slice(1)] += contents;</span>
<span class="cstat-no" title="statement not covered" > cb(null, tot);</span>
});
}, cb);
});
});
},
// Find input files.
files: function(cb) {
async.reduce(options['in'], [], function(all, cur, cb) {
getFiles(cur, function(err, files) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (err != null) <span class="cstat-no" title="statement not covered" >return cb(err);</span>
cb(null, all.concat(files));
});
}, function(err, files) {
<span class="missing-if-branch" title="if path not taken" >I</span>if (err != null) <span class="cstat-no" title="statement not covered" >return cb(err);</span>
files = files.filter(function(file) {
// No hidden files
if (file.match(/(\/|^)\.[^\.\/]/)) return false;
// Only supported file types
<span class="missing-if-branch" title="if path not taken" >I</span>if (!(path.extname(file) in helper.fileTypes)) <span class="cstat-no" title="statement not covered" >return false;</span>
return true;
}).sort();
<span class="missing-if-branch" title="if path not taken" >I</span>if (!files.length) <span class="cstat-no" title="statement not covered" >cb(new Error(errorMessages.noFiles + ' in path "' + options['in'] + '"'));</span>
cb(null, files);
});
},
// Look for a README file.
readme: <span class="fstat-no" title="function not covered" >function(cb) {</span>
<span class="cstat-no" title="statement not covered" > findFile(options.basePath, /^readme\.m(ark)?d(own)?/i, <span class="fstat-no" title="function not covered" >function(err, file) {</span></span>
<span class="cstat-no" title="statement not covered" > if (file != null && err == null) <span class="cstat-no" title="statement not covered" >return read(file);</span></span>
<span class="cstat-no" title="statement not covered" > findFile(process.cwd(), /^readme\.m(ark)?d(own)?/i, <span class="fstat-no" title="function not covered" >function(err, file) {</span></span>
<span class="cstat-no" title="statement not covered" > if (err != null) <span class="cstat-no" title="statement not covered" >file = resourcesDir + 'README.md';</span></span>
<span class="cstat-no" title="statement not covered" > read(file);</span>
});
});
<span class="cstat-no" title="statement not covered" > var read = <span class="fstat-no" title="function not covered" >function(file) {</span></span>
<span class="cstat-no" title="statement not covered" > fs.readFile(file, 'utf8', <span class="fstat-no" title="function not covered" >function(err, content) {</span></span>
<span class="cstat-no" title="statement not covered" > if (err != null) <span class="cstat-no" title="statement not covered" >cb(err);</span></span>
<span class="cstat-no" title="statement not covered" > cb(null, content);</span>
});
};
}
};
}
</pre></td></tr>
</table></pre>
</div>
<div class="footer">
<div class="meta">Generated by <a href="http://istanbul-js.org/" target="_blank">istanbul</a> at Mon Dec 23 2013 20:06:34 GMT+0000 (GMT)</div>
</div>
<script src="../prettify.js"></script>
<script src="http://yui.yahooapis.com/3.6.0/build/yui/yui-min.js"></script>
<script>
YUI().use('datatable', function (Y) {
var formatters = {
pct: function (o) {
o.className += o.record.get('classes')[o.column.key];
try {
return o.value.toFixed(2) + '%';
} catch (ex) { return o.value + '%'; }
},
html: function (o) {
o.className += o.record.get('classes')[o.column.key];
return o.record.get(o.column.key + '_html');
}
},
defaultFormatter = function (o) {
o.className += o.record.get('classes')[o.column.key];
return o.value;
};
function getColumns(theadNode) {
var colNodes = theadNode.all('tr th'),
cols = [],
col;
colNodes.each(function (colNode) {
col = {
key: colNode.getAttribute('data-col'),
label: colNode.get('innerHTML') || ' ',
sortable: !colNode.getAttribute('data-nosort'),
className: colNode.getAttribute('class'),
type: colNode.getAttribute('data-type'),
allowHTML: colNode.getAttribute('data-html') === 'true' || colNode.getAttribute('data-fmt') === 'html'
};
col.formatter = formatters[colNode.getAttribute('data-fmt')] || defaultFormatter;
cols.push(col);
});
return cols;
}
function getRowData(trNode, cols) {
var tdNodes = trNode.all('td'),
i,
row = { classes: {} },
node,
name;
for (i = 0; i < cols.length; i += 1) {
name = cols[i].key;
node = tdNodes.item(i);
row[name] = node.getAttribute('data-value') || node.get('innerHTML');
row[name + '_html'] = node.get('innerHTML');
row.classes[name] = node.getAttribute('class');
//Y.log('Name: ' + name + '; Value: ' + row[name]);
if (cols[i].type === 'number') { row[name] = row[name] * 1; }
}
//Y.log(row);
return row;
}
function getData(tbodyNode, cols) {
var data = [];
tbodyNode.all('tr').each(function (trNode) {
data.push(getRowData(trNode, cols));
});
return data;
}
function replaceTable(node) {
if (!node) { return; }
var cols = getColumns(node.one('thead')),
data = getData(node.one('tbody'), cols),
table,
parent = node.get('parentNode');
table = new Y.DataTable({
columns: cols,
data: data,
sortBy: 'file'
});
parent.set('innerHTML', '');
table.render(parent);
}
Y.on('domready', function () {
replaceTable(Y.one('div.coverage-summary table'));
if (typeof prettyPrint === 'function') {
prettyPrint();
}
});
});
</script>
</body>
</html>