Issues (117)

lib/adapters/example.js (3 issues)

1
2 1
var fs          = require('fs');
3 1
var path        = require('path');
4 1
var format      = require('string-template');
5 1
var frontMatter = require('front-matter');
6 1
var escapeHTML  = require('escape-html');
7 1
var multiline   = require('multiline');
8 1
var highlightCode = require('../util/highlight-code');
9
10 1
var HTML_EXAMPLE_TEMPLATE = multiline(function() {/*
11
<div class="docs-code" data-docs-code>
12
<pre>
13
<code class="{0}">
14
{1}
15
</code>
16
</pre>
17
</div>
18
*/}).replace(/(^(\s)*)/gm, '');
19
20 1
module.exports = function(value, config, cb, pl) {
21 2
    var data = getSourceExample (value, config, pl);
22 2
    cb(null, processTree(data));
23
}
24
25 1
module.exports.config = {
26
    verbose: false
27
}
28
29 1
module.exports.search = function(items, link) {
0 ignored issues
show
The parameter items is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
The parameter link is not used and could be removed.

This check looks for parameters in functions that are not used in the function body and are not followed by other parameters which are used inside the function.

Loading history...
30 1
    var results = [];
31
    // this => collider
32
    /* results.push({
33
        name: name,
34
        type: 'sass ' + type,
35
        description: description,
36
        link: link + hash
37
    }); */
38
39 1
    return results;
40
}
41
42
43
function getSourceExample(value, config, pl) {
44 2
    if (!fs.existsSync(value)) return false;
0 ignored issues
show
Coding Style Best Practice introduced by
Curly braces around statements make for more readable code and help prevent bugs when you add further statements.

Consider adding curly braces around all statements when they are executed conditionally. This is optional if there is only one statement, but leaving them out can lead to unexpected behaviour if another statement is added later.

Consider:

if (a > 0)
    b = 42;

If you or someone else later decides to put another statement in, only the first statement will be executed.

if (a > 0)
    console.log("a > 0");
    b = 42;

In this case the statement b = 42 will always be executed, while the logging statement will be executed conditionally.

if (a > 0) {
    console.log("a > 0");
    b = 42;
}

ensures that the proper code will be executed conditionally no matter how many statements are added or removed.

Loading history...
45 1
    var patternFile = fs.readFileSync(value).toString();
46 1
    var renderedPattern = pl.renderpattern(patternFile, {});
47 1
    var renderedCode = highlightCode('html', renderedPattern);
48 1
    var output = format(HTML_EXAMPLE_TEMPLATE, ['html', renderedCode]);
49
50 1
    return {
51
        highlight : output,
52
        escaped   : escapeHTML(renderedPattern),
53
        raw       : renderedPattern
54
    };
55
}
56
57
58
function processTree(tree) {
59
    
60
    // do tree assignment stuff...
61
62 2
    return tree; //my_stuff;
63
}
64
65