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
|
|||
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; |
|
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 |
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.