-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdoc.js
More file actions
75 lines (73 loc) · 2.74 KB
/
doc.js
File metadata and controls
75 lines (73 loc) · 2.74 KB
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
/*
* fis-command-doc
* https://github.com/kaven85
* @author Kaven.D
*/
'use strict';
exports.name = 'doc';
exports.desc = 'output api html';
var Y=require('yuidocjs'),json
exports.register = function(commander){
commander
.option('--doc', 'output api html', String)
.action(function(){
var options = arguments[arguments.length - 1],root,filename='fis-conf.js',conf;
if(options.root){
root = fis.util.realpath(options.root);
if(fis.util.isDir(root)){
if(!conf && fis.util.isFile(root + '/' + filename)){
conf = root + '/' + filename;
}
delete options.root;
} else {
fis.log.error('invalid project root path [' + options.root + ']');
}
} else {
root = fis.util.realpath(process.cwd());
if(!conf){
//try to find fis-conf.js
var cwd = root, pos = cwd.length;
do {
cwd = cwd.substring(0, pos);
conf = cwd + '/' + filename;
if(fis.util.exists(conf)){
root = cwd;
break;
} else {
conf = false;
pos = cwd.lastIndexOf('/');
}
} while(pos > 0);
}
}
process.title = 'fis ' + process.argv.splice(2).join(' ') + ' [ ' + root + ' ]';
if(conf){
var cache = fis.cache(conf, 'conf');
if(!cache.revert()){
options.clean = true;
cache.save();
}
require(conf);
} else {
fis.log.warning('missing config file [' + filename + ']');
}
options=fis.config.get('settings.yuidoc.options')
var starttime = Date.now();
if(options&&options['paths']&&options['outdir']){
if(options['paths'].constructor ==String){
options['paths']=[options['paths']];
}
try {
json = (new Y.YUIDoc(options)).run();
} catch(e) {
console.error(e);
}
options = Y.Project.mix(json, options);
var builder = new Y.DocBuilder(options, json);
builder.compile(function() {
var endtime = Date.now();
console.log('YUIDoc compile completed in ' + ((endtime - starttime) / 1000) + ' seconds');
});
}
});
};