-
Notifications
You must be signed in to change notification settings - Fork 32
Expand file tree
/
Copy pathmake.js
More file actions
130 lines (127 loc) · 4.28 KB
/
make.js
File metadata and controls
130 lines (127 loc) · 4.28 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
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
121
122
123
124
125
126
127
128
129
/**
build docs for kissy
@author yiminghe@gmail.com
*/
var options = {
'html': {
help: 'to make standalone HTML files',
postInfo: 'The HTML pages are in {buildDir}/html.'
},
'dirhtml': {
help: 'to make HTML files named index.html in directories',
'postInfo': 'The HTML pages are in {buildDir}/dirhtml.'
},
'singlehtml': {
help: 'to make a single large HTML file',
'postInfo': 'The HTML pages are in {buildDir}/singlehtml.'
},
'pickle': {
help: 'to make pickle files',
'postInfo': 'The pickle pages are in {buildDir}/pickle.'
},
'json': {
help: 'to make JSON files',
'postInfo': 'The json pages are in {buildDir}/json.'
},
'htmlhelp': {
help: 'to make HTML files and a HTML help project',
'postInfo': 'you can run HTML Help Workshop with the .hhp project file in {buildDir}/htmlhelp.'
},
'qthelp': {
help: 'to make HTML files and a qthelp project',
'postInfo': 'you can run "qcollectiongenerator" with the ' +
'.qhcp project file in {buildDir}/qthelp, like this:' +
'> qcollectiongenerator {buildDir} qthelp KISSYDOCS.qhcp' +
'To view the help file:' +
'> assistant -collectionFile {buildDir} qthelp KISSYDOCS.ghc'
},
'devhelp': {
help: 'to make HTML files and a Devhelp project',
'postInfo': ''
},
'epub': {
help: 'to make an epub',
'postInfo': 'The epub file is in {buildDir}/epub.'
},
'latex': {
help: 'to make LaTeX files, you can set PAPER=a4 or PAPER=letter',
'postInfo': 'the LaTeX files are in {buildDir}/latex.'
},
'text': {
help: 'to make text files',
'postInfo': 'The text files are in {buildDir}/text.'
},
'man': {
help: 'to make manual pages',
'postInfo': 'The manual pages are in {buildDir}/man.'
},
'changes': {
help: 'to make an overview over all changed/added/deprecated items',
'postInfo': 'The overview file is in {buildDir}/changes.'
},
'linkcheck': {
help: 'to check all external links for integrity',
'postInfo': 'Link check complete; look for any errors in the above output or in {buildDir}/linkcheck/output.txt.'
},
'doctest': {
help: 'to run all doctests embedded in the documentation if enabled',
'postInfo': 'look at the results in {buildDir}/doctest/output.txt.'
}
};
var SUBSTITUTE_REG = /\\?\{([^{}]+)\}/g;
function substitute(str, o, regexp) {
return str.replace(regexp || SUBSTITUTE_REG, function (match, name) {
if (match.charAt(0) === '\\') {
return match.slice(1);
}
return (o[name] === undefined) ? EMPTY : o[name];
});
}
var child_process = require('child_process');
var fs = require('fs-extra');
var program = require('./tools/commander/');
program.version(require('./package.json').version);
program.option('-b, --build-version <buildVersion>', 'Set build version of kissy docs')
.option('--stable', 'Set current docs stable')
.option('-c, --clean', 'clean current build');
for (var o in options) {
program.option('--' + o, options[o].help);
}
program.parse(process.argv);
var buildVersion = program.buildVersion;
var sphinxBuild = 'sphinx-build';
var buildDir = buildVersion + '/docs/';
var sourceDir = buildVersion + '/source/';
var stableBuildDir = './docs/';
var sphinxOptions = ['-d', buildDir + 'doctrees', sourceDir ];
(function () {
if (program.clean) {
fs.remove(buildDir);
if (program.stable) {
fs.remove(stableBuildDir);
}
return;
}
var option = 'html';
var postInfo = 'Build finished. ';
for (var o in options) {
if (program[o]) {
console.log(o);
option = o;
postInfo += substitute(options[o].postInfo, {
buildDir: buildDir
});
break;
}
}
sphinxOptions.unshift('-b', option);
sphinxOptions.push(buildDir + option);
child_process.spawn(sphinxBuild, sphinxOptions, {
stdio: 'inherit'
}).on('close', function (code) {
if (!code && program.stable) {
fs.copy(buildDir, stableBuildDir);
}
console.log(postInfo);
});
})();