-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
66 lines (50 loc) · 1.54 KB
/
index.js
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
/**
* broccoli-sassdoc
*
* unlicenced
* https://github.com/SassDoc/broccoli-sassdoc/blob/master/UNLICENCE
*/
'use strict'
var Writer = require('broccoli-writer')
var sassdoc = require('sassdoc')
var ensure = require('lodash.assign')
function environment () {
// Defaults.
var options = ensure(this.options, {
noUpdateNotifier: true
})
// Instantiate a new SassDoc Logger.
var logger = new sassdoc.Logger(options.verbose)
// Instantiate a new SassDoc Environment.
var env = new sassdoc.Environment(logger, options.strict)
env.on('error', console.error)
// Load and process config file, if any.
env.load(options.config)
// Ensure that options take precedence over configuration values.
ensure(env, options)
env.postProcess()
return env
}
function SassDocCompile (inputTree, options) {
if (!(this instanceof SassDocCompile)) {
return new SassDocCompile(inputTree, options)
}
this.inputTree = inputTree
this.options = options || {}
}
SassDocCompile.prototype = Object.create(Writer.prototype)
SassDocCompile.prototype.constructor = SassDocCompile
SassDocCompile.prototype.description = 'Generates SassDoc documentation'
SassDocCompile.prototype.write = function (readTree, destDir) {
var env = environment.call(this)
env.dest = destDir
return readTree(this.inputTree).then(function (srcDir) {
return sassdoc(srcDir, env)
.then(function () {
console.log('SassDoc documentation successfully generated.')
}, function (err) {
throw err
})
})
}
module.exports = SassDocCompile