docgen-tool 3.2.13 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/docgen/docgen.js +323 -282
- package/dist/docgen/fs/fs.js +178 -0
- package/dist/docgen.js +10 -8
- package/dist/include/require/styles/framework.css +2 -5
- package/package.json +11 -11
package/dist/docgen/docgen.js
CHANGED
|
@@ -1,28 +1,67 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
2
41
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
var
|
|
5
|
-
var
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var
|
|
42
|
+
exports.DocGen = void 0;
|
|
43
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
44
|
+
var path_1 = __importDefault(require("path"));
|
|
45
|
+
var cheerio_1 = __importDefault(require("cheerio"));
|
|
46
|
+
var rsvp_1 = __importDefault(require("rsvp"));
|
|
47
|
+
var moment_1 = __importDefault(require("moment"));
|
|
48
|
+
var z_schema_1 = __importDefault(require("z-schema"));
|
|
9
49
|
var child_process_1 = require("child_process");
|
|
10
|
-
var
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
50
|
+
var spawn_args_1 = __importDefault(require("spawn-args"));
|
|
51
|
+
var markdown_it_1 = __importDefault(require("markdown-it"));
|
|
52
|
+
var image_size_1 = __importDefault(require("image-size"));
|
|
53
|
+
var cli_spinner_1 = require("cli-spinner");
|
|
54
|
+
var fs_1 = require("./fs/fs");
|
|
15
55
|
var package_json_1 = require("../../package.json");
|
|
56
|
+
var markdown = new markdown_it_1.default('commonmark').enable('table');
|
|
16
57
|
//Allow CommonMark links that use other protocols, such as file:///
|
|
17
58
|
//The markdown-it implementation is more restrictive than the CommonMark spec
|
|
18
59
|
//See https://github.com/markdown-it/markdown-it/issues/108
|
|
19
60
|
markdown.validateLink = function () {
|
|
20
61
|
return true;
|
|
21
62
|
};
|
|
22
|
-
/**
|
|
23
|
-
* DocGen class
|
|
24
|
-
*/
|
|
25
63
|
function DocGen(process) {
|
|
64
|
+
var _this = this;
|
|
26
65
|
var mainProcess = process;
|
|
27
66
|
var wkhtmltopdfVersion = 'wkhtmltopdf 0.12.6 (with patched qt)'; //output from wkhtmltopdf -V
|
|
28
67
|
var options;
|
|
@@ -37,150 +76,99 @@ function DocGen(process) {
|
|
|
37
76
|
options = userOptions;
|
|
38
77
|
//all user-specified paths must be normalized
|
|
39
78
|
if (options.input) {
|
|
40
|
-
options.input =
|
|
79
|
+
options.input = path_1.default.normalize(options.input + '/');
|
|
41
80
|
}
|
|
42
81
|
if (options.output) {
|
|
43
|
-
options.output =
|
|
82
|
+
options.output = path_1.default.normalize(options.output + '/');
|
|
44
83
|
}
|
|
45
84
|
//wkhtmltopdf path does not need a trailing slash
|
|
46
85
|
if (options.wkhtmltopdfPath && options.wkhtmltopdfPath !== '') {
|
|
47
|
-
options.wkhtmltopdfPath =
|
|
86
|
+
options.wkhtmltopdfPath = path_1.default.normalize(options.wkhtmltopdfPath);
|
|
48
87
|
}
|
|
49
88
|
};
|
|
50
89
|
/*
|
|
51
90
|
copy the example src files (template) to any directory, when scaffold command is invoked
|
|
52
91
|
*/
|
|
53
|
-
this.scaffold = function () {
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
63
|
-
/*
|
|
64
|
-
read any file (async)
|
|
65
|
-
*/
|
|
66
|
-
var readFile = function (filePath) {
|
|
67
|
-
var normalized = path.normalize(filePath);
|
|
68
|
-
return new rsvp.Promise(function (resolve, reject) {
|
|
69
|
-
fs.readFile(normalized, 'utf8', function (error, data) {
|
|
70
|
-
if (error) {
|
|
71
|
-
console.log(chalk.red('Error reading file: ' + normalized));
|
|
72
|
-
reject(error);
|
|
73
|
-
}
|
|
74
|
-
else {
|
|
75
|
-
data = data.replace(/^\uFEFF/, ''); //remove the BOM (byte-order-mark) from UTF-8 files, if present
|
|
76
|
-
resolve(data);
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
};
|
|
81
|
-
/*
|
|
82
|
-
write any file (async)
|
|
83
|
-
*/
|
|
84
|
-
var writeFile = function (filePath, data) {
|
|
85
|
-
var normalized = path.normalize(filePath);
|
|
86
|
-
return new rsvp.Promise(function (resolve, reject) {
|
|
87
|
-
fs.writeFile(normalized, data, function (error) {
|
|
88
|
-
if (error) {
|
|
89
|
-
console.log(chalk.red('Error writing file: ' + normalized));
|
|
90
|
-
reject(error);
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
resolve(true);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
/*
|
|
99
|
-
copy any directory (sync)
|
|
100
|
-
*/
|
|
101
|
-
var copyDirSync = function (source, destination) {
|
|
102
|
-
var normalizedSource = path.normalize(source);
|
|
103
|
-
var normalizedDestination = path.normalize(destination);
|
|
104
|
-
try {
|
|
105
|
-
fs.copySync(normalizedSource, normalizedDestination);
|
|
106
|
-
}
|
|
107
|
-
catch (error) {
|
|
108
|
-
console.log(chalk.red('Error copying directory: ' +
|
|
109
|
-
normalizedSource +
|
|
110
|
-
' to ' +
|
|
111
|
-
normalizedDestination));
|
|
112
|
-
if (options.verbose === true) {
|
|
113
|
-
console.log(chalk.red(error));
|
|
114
|
-
mainProcess.exit(1);
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
/*
|
|
119
|
-
remake a directory (sync) ... remove and then mkdir in one operation
|
|
120
|
-
*/
|
|
121
|
-
var remakeDirSync = function (directoryPath) {
|
|
122
|
-
var normalized = path.normalize(directoryPath);
|
|
123
|
-
try {
|
|
124
|
-
fs.removeSync(normalized);
|
|
125
|
-
fs.mkdirpSync(normalized);
|
|
126
|
-
}
|
|
127
|
-
catch (error) {
|
|
128
|
-
console.log(chalk.red('Error recreating directory: ' + normalized));
|
|
129
|
-
if (options.verbose === true) {
|
|
130
|
-
console.log(chalk.red(error));
|
|
131
|
-
mainProcess.exit(1);
|
|
92
|
+
this.scaffold = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
console.log(chalk_1.default.green('Creating scaffold template directory'));
|
|
97
|
+
return [4 /*yield*/, (0, fs_1.copyDirectory)(__dirname + '/../include/example', options.output, options.verbose === true)];
|
|
98
|
+
case 1:
|
|
99
|
+
_a.sent();
|
|
100
|
+
return [2 /*return*/];
|
|
132
101
|
}
|
|
133
|
-
}
|
|
134
|
-
};
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
mainProcess.exit(1);
|
|
102
|
+
});
|
|
103
|
+
}); };
|
|
104
|
+
this.run = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
105
|
+
return __generator(this, function (_a) {
|
|
106
|
+
switch (_a.label) {
|
|
107
|
+
case 0:
|
|
108
|
+
console.log(chalk_1.default.green.bold('DocGen version ' + package_json_1.version));
|
|
109
|
+
//delete and recreate the output directory
|
|
110
|
+
return [4 /*yield*/, (0, fs_1.cleanDirectory)(options.output)];
|
|
111
|
+
case 1:
|
|
112
|
+
//delete and recreate the output directory
|
|
113
|
+
_a.sent();
|
|
114
|
+
loadTemplates();
|
|
115
|
+
return [2 /*return*/];
|
|
148
116
|
}
|
|
149
|
-
}
|
|
150
|
-
};
|
|
117
|
+
});
|
|
118
|
+
}); };
|
|
151
119
|
/*
|
|
152
120
|
load all HTML template files
|
|
153
121
|
*/
|
|
154
|
-
var loadTemplates = function () {
|
|
155
|
-
|
|
156
|
-
var
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
122
|
+
var loadTemplates = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
123
|
+
var files;
|
|
124
|
+
var _a;
|
|
125
|
+
return __generator(this, function (_b) {
|
|
126
|
+
switch (_b.label) {
|
|
127
|
+
case 0:
|
|
128
|
+
console.log(chalk_1.default.green('Loading templates'));
|
|
129
|
+
_a = {};
|
|
130
|
+
return [4 /*yield*/, (0, fs_1.readFile)(__dirname + '/../include/templates/main.html')];
|
|
131
|
+
case 1:
|
|
132
|
+
_a.main = _b.sent();
|
|
133
|
+
return [4 /*yield*/, (0, fs_1.readFile)(__dirname + '/../include/templates/redirect.html')];
|
|
134
|
+
case 2:
|
|
135
|
+
_a.redirect = _b.sent();
|
|
136
|
+
return [4 /*yield*/, (0, fs_1.readFile)(__dirname + '/../include/templates/webCover.html')];
|
|
137
|
+
case 3:
|
|
138
|
+
_a.webCover = _b.sent();
|
|
139
|
+
return [4 /*yield*/, (0, fs_1.readFile)(__dirname + '/../include/templates/pdfCover.html')];
|
|
140
|
+
case 4:
|
|
141
|
+
_a.pdfCover = _b.sent();
|
|
142
|
+
return [4 /*yield*/, (0, fs_1.readFile)(__dirname + '/../include/templates/pdfHeader.html')];
|
|
143
|
+
case 5:
|
|
144
|
+
_a.pdfHeader = _b.sent();
|
|
145
|
+
return [4 /*yield*/, (0, fs_1.readFile)(__dirname + '/../include/templates/pdfFooter.html')];
|
|
146
|
+
case 6:
|
|
147
|
+
files = (_a.pdfFooter = _b.sent(),
|
|
148
|
+
_a);
|
|
149
|
+
rsvp_1.default
|
|
150
|
+
.hash(files)
|
|
151
|
+
.then(function (files) {
|
|
152
|
+
for (var key in files) {
|
|
153
|
+
if (files.hasOwnProperty(key)) {
|
|
154
|
+
var file = files[key];
|
|
155
|
+
var dom = cheerio_1.default.load(file);
|
|
156
|
+
templates[key] = dom;
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
loadMeta();
|
|
160
|
+
})
|
|
161
|
+
.catch(function (error) {
|
|
162
|
+
console.log(chalk_1.default.red('Error loading templates'));
|
|
163
|
+
if (options.verbose === true) {
|
|
164
|
+
console.log(chalk_1.default.red(error));
|
|
165
|
+
}
|
|
166
|
+
mainProcess.exit(1);
|
|
167
|
+
});
|
|
168
|
+
return [2 /*return*/];
|
|
180
169
|
}
|
|
181
|
-
mainProcess.exit(1);
|
|
182
170
|
});
|
|
183
|
-
};
|
|
171
|
+
}); };
|
|
184
172
|
/*
|
|
185
173
|
JSON schema validation
|
|
186
174
|
*/
|
|
@@ -315,14 +303,14 @@ function DocGen(process) {
|
|
|
315
303
|
};
|
|
316
304
|
var validateJSON = function (key, data) {
|
|
317
305
|
var schema = schemas[key];
|
|
318
|
-
var validator = new
|
|
306
|
+
var validator = new z_schema_1.default();
|
|
319
307
|
var valid = validator.validate(data, schema);
|
|
320
308
|
if (!valid) {
|
|
321
|
-
console.log(
|
|
309
|
+
console.log(chalk_1.default.red('Error parsing required file: ' +
|
|
322
310
|
key +
|
|
323
311
|
'.json (failed schema validation)'));
|
|
324
312
|
if (options.verbose === true) {
|
|
325
|
-
console.log(
|
|
313
|
+
console.log(chalk_1.default.red(validator.getLastError()));
|
|
326
314
|
}
|
|
327
315
|
}
|
|
328
316
|
return valid;
|
|
@@ -330,60 +318,72 @@ function DocGen(process) {
|
|
|
330
318
|
/*
|
|
331
319
|
load all metadata files (JSON)
|
|
332
320
|
*/
|
|
333
|
-
var loadMeta = function () {
|
|
334
|
-
|
|
335
|
-
var
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
321
|
+
var loadMeta = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
322
|
+
var files;
|
|
323
|
+
var _a;
|
|
324
|
+
return __generator(this, function (_b) {
|
|
325
|
+
switch (_b.label) {
|
|
326
|
+
case 0:
|
|
327
|
+
console.log(chalk_1.default.green('Loading required JSON metadata files'));
|
|
328
|
+
_a = {};
|
|
329
|
+
return [4 /*yield*/, (0, fs_1.readFile)(options.input + '/parameters.json')];
|
|
330
|
+
case 1:
|
|
331
|
+
_a.parameters = _b.sent();
|
|
332
|
+
return [4 /*yield*/, (0, fs_1.readFile)(options.input + '/contents.json')];
|
|
333
|
+
case 2:
|
|
334
|
+
files = (_a.contents = _b.sent(),
|
|
335
|
+
_a);
|
|
336
|
+
rsvp_1.default
|
|
337
|
+
.hash(files)
|
|
338
|
+
.then(function (files) {
|
|
339
|
+
for (var key in files) {
|
|
340
|
+
if (files.hasOwnProperty(key)) {
|
|
341
|
+
//ignore prototype
|
|
342
|
+
try {
|
|
343
|
+
var file = JSON.parse(files[key]);
|
|
344
|
+
if (validateJSON(key, file)) {
|
|
345
|
+
meta[key] = file;
|
|
346
|
+
}
|
|
347
|
+
else {
|
|
348
|
+
mainProcess.exit(1);
|
|
349
|
+
}
|
|
350
|
+
}
|
|
351
|
+
catch (error) {
|
|
352
|
+
console.log(chalk_1.default.red('Error parsing required file: ' +
|
|
353
|
+
key +
|
|
354
|
+
'.json (invalid JSON)'));
|
|
355
|
+
if (options.verbose === true) {
|
|
356
|
+
console.log(chalk_1.default.red(error));
|
|
357
|
+
}
|
|
358
|
+
mainProcess.exit(1);
|
|
359
|
+
}
|
|
360
|
+
}
|
|
349
361
|
}
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
362
|
+
//add the release notes to the contents list
|
|
363
|
+
var extra = {
|
|
364
|
+
heading: 'Extra',
|
|
365
|
+
column: 5,
|
|
366
|
+
pages: [{ title: 'Release notes', source: 'release-notes.md' }],
|
|
367
|
+
};
|
|
368
|
+
meta.contents.push(extra);
|
|
369
|
+
loadMarkdown();
|
|
370
|
+
})
|
|
371
|
+
.catch(function (error) {
|
|
372
|
+
console.log(chalk_1.default.red('Error loading required JSON metadata files'));
|
|
358
373
|
if (options.verbose === true) {
|
|
359
|
-
console.log(
|
|
374
|
+
console.log(chalk_1.default.red(error));
|
|
360
375
|
}
|
|
361
376
|
mainProcess.exit(1);
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
//add the release notes to the contents list
|
|
366
|
-
var extra = {
|
|
367
|
-
heading: 'Extra',
|
|
368
|
-
column: 5,
|
|
369
|
-
pages: [{ title: 'Release notes', source: 'release-notes.md' }],
|
|
370
|
-
};
|
|
371
|
-
meta.contents.push(extra);
|
|
372
|
-
loadMarkdown();
|
|
373
|
-
})
|
|
374
|
-
.catch(function (error) {
|
|
375
|
-
console.log(chalk.red('Error loading required JSON metadata files'));
|
|
376
|
-
if (options.verbose === true) {
|
|
377
|
-
console.log(chalk.red(error));
|
|
377
|
+
});
|
|
378
|
+
return [2 /*return*/];
|
|
378
379
|
}
|
|
379
|
-
mainProcess.exit(1);
|
|
380
380
|
});
|
|
381
|
-
};
|
|
381
|
+
}); };
|
|
382
382
|
/*
|
|
383
383
|
load all markdown files (src)
|
|
384
384
|
*/
|
|
385
385
|
var loadMarkdown = function () {
|
|
386
|
-
console.log(
|
|
386
|
+
console.log(chalk_1.default.green('Loading src files'));
|
|
387
387
|
var keys = [];
|
|
388
388
|
var files = [];
|
|
389
389
|
meta.contents.forEach(function (section) {
|
|
@@ -395,8 +395,8 @@ function DocGen(process) {
|
|
|
395
395
|
//add the release notes page
|
|
396
396
|
keys.push('ownership');
|
|
397
397
|
files.push(options.input + '/release-notes.md');
|
|
398
|
-
|
|
399
|
-
.all(files.map(readFile))
|
|
398
|
+
rsvp_1.default
|
|
399
|
+
.all(files.map(fs_1.readFile))
|
|
400
400
|
.then(function (files) {
|
|
401
401
|
files.forEach(function (page, index) {
|
|
402
402
|
try {
|
|
@@ -412,9 +412,9 @@ function DocGen(process) {
|
|
|
412
412
|
}
|
|
413
413
|
}
|
|
414
414
|
catch (error) {
|
|
415
|
-
console.log(
|
|
415
|
+
console.log(chalk_1.default.red('Error parsing Markdown file: ' + file.source));
|
|
416
416
|
if (options.verbose === true) {
|
|
417
|
-
console.log(
|
|
417
|
+
console.log(chalk_1.default.red(error));
|
|
418
418
|
}
|
|
419
419
|
mainProcess.exit(1);
|
|
420
420
|
}
|
|
@@ -423,9 +423,9 @@ function DocGen(process) {
|
|
|
423
423
|
})
|
|
424
424
|
.catch(function (error) {
|
|
425
425
|
console.log(error);
|
|
426
|
-
console.log(
|
|
426
|
+
console.log(chalk_1.default.red('Error loading src files'));
|
|
427
427
|
if (options.verbose === true) {
|
|
428
|
-
console.log(
|
|
428
|
+
console.log(chalk_1.default.red(error));
|
|
429
429
|
}
|
|
430
430
|
mainProcess.exit(1);
|
|
431
431
|
});
|
|
@@ -502,7 +502,7 @@ function DocGen(process) {
|
|
|
502
502
|
var logoPath;
|
|
503
503
|
try {
|
|
504
504
|
logoPath = 'files/images/logo.svg';
|
|
505
|
-
var logo =
|
|
505
|
+
var logo = (0, image_size_1.default)("".concat(options.input, "/").concat(logoPath));
|
|
506
506
|
logoWidth = logo.width;
|
|
507
507
|
logoHeight = logo.height;
|
|
508
508
|
hasLogo = true;
|
|
@@ -514,7 +514,7 @@ function DocGen(process) {
|
|
|
514
514
|
//PNG fallback
|
|
515
515
|
try {
|
|
516
516
|
logoPath = 'files/images/logo.png';
|
|
517
|
-
var logo =
|
|
517
|
+
var logo = (0, image_size_1.default)("".concat(options.input, "/").concat(logoPath));
|
|
518
518
|
logoWidth = logo.width;
|
|
519
519
|
logoHeight = logo.height;
|
|
520
520
|
hasLogo = true;
|
|
@@ -528,9 +528,9 @@ function DocGen(process) {
|
|
|
528
528
|
var homelink = meta.contents[0].pages[0];
|
|
529
529
|
homelink =
|
|
530
530
|
homelink.source.substr(0, homelink.source.lastIndexOf('.')) + '.html';
|
|
531
|
-
var date =
|
|
532
|
-
var time =
|
|
533
|
-
var year =
|
|
531
|
+
var date = (0, moment_1.default)().format('DD/MM/YYYY');
|
|
532
|
+
var time = (0, moment_1.default)().format('HH:mm:ss');
|
|
533
|
+
var year = (0, moment_1.default)().format('YYYY');
|
|
534
534
|
var attribution = 'Created by DocGen ' + package_json_1.version + ' on ' + date + ' at ' + time + '.';
|
|
535
535
|
var releaseVersion = meta.parameters.version;
|
|
536
536
|
if (options.setVersion !== false) {
|
|
@@ -673,12 +673,12 @@ function DocGen(process) {
|
|
|
673
673
|
process each input into an output
|
|
674
674
|
*/
|
|
675
675
|
var processContent = function () {
|
|
676
|
-
console.log(
|
|
676
|
+
console.log(chalk_1.default.green('Generating the static web content'));
|
|
677
677
|
webToc();
|
|
678
678
|
insertParameters();
|
|
679
679
|
meta.contents.forEach(function (section) {
|
|
680
680
|
section.pages.forEach(function (page) {
|
|
681
|
-
var $ =
|
|
681
|
+
var $ = cheerio_1.default.load(templates.main.html()); //clone
|
|
682
682
|
var key = page.source;
|
|
683
683
|
var content = pages[key];
|
|
684
684
|
//add relevant container
|
|
@@ -725,7 +725,7 @@ function DocGen(process) {
|
|
|
725
725
|
});
|
|
726
726
|
});
|
|
727
727
|
//add web ownership page
|
|
728
|
-
var $ =
|
|
728
|
+
var $ = cheerio_1.default.load(templates.main.html()); //clone
|
|
729
729
|
$('#dg-content').html('<div class="w-fixed-width"><div id="dg-innerContent"></div></div>');
|
|
730
730
|
$('#dg-innerContent').html(templates.webCover.html());
|
|
731
731
|
templates.webCover = $;
|
|
@@ -734,45 +734,68 @@ function DocGen(process) {
|
|
|
734
734
|
/*
|
|
735
735
|
write each html page
|
|
736
736
|
*/
|
|
737
|
-
var writePages = function () {
|
|
738
|
-
|
|
739
|
-
var
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
737
|
+
var writePages = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
738
|
+
var promises, pdfTempDir;
|
|
739
|
+
var _this = this;
|
|
740
|
+
return __generator(this, function (_a) {
|
|
741
|
+
switch (_a.label) {
|
|
742
|
+
case 0:
|
|
743
|
+
console.log(chalk_1.default.green('Writing the web page files'));
|
|
744
|
+
promises = {};
|
|
745
|
+
meta.contents.forEach(function (section) {
|
|
746
|
+
section.pages.forEach(function (page) {
|
|
747
|
+
var key = page.source;
|
|
748
|
+
var name = key.substr(0, page.source.lastIndexOf('.'));
|
|
749
|
+
var path = options.output + name + '.html';
|
|
750
|
+
var html = pages[key].html();
|
|
751
|
+
promises[key] = (0, fs_1.writeFile)(path, html);
|
|
752
|
+
});
|
|
753
|
+
});
|
|
754
|
+
//add extra files
|
|
755
|
+
promises['ownership'] = (0, fs_1.writeFile)(options.output + 'ownership.html', templates.webCover.html());
|
|
756
|
+
if (!(options.pdf === true)) return [3 /*break*/, 2];
|
|
757
|
+
pdfTempDir = options.output + 'temp/';
|
|
758
|
+
return [4 /*yield*/, (0, fs_1.makeDirectory)(pdfTempDir)];
|
|
759
|
+
case 1:
|
|
760
|
+
_a.sent();
|
|
761
|
+
promises['docgenPdfCover'] = (0, fs_1.writeFile)(pdfTempDir + 'pdfCover.html', templates.pdfCover.html());
|
|
762
|
+
promises['docgenPdfHeader'] = (0, fs_1.writeFile)(pdfTempDir + 'pdfHeader.html', templates.pdfHeader.html());
|
|
763
|
+
promises['docgenPdfFooter'] = (0, fs_1.writeFile)(pdfTempDir + 'pdfFooter.html', templates.pdfFooter.html());
|
|
764
|
+
_a.label = 2;
|
|
765
|
+
case 2:
|
|
766
|
+
rsvp_1.default
|
|
767
|
+
.hash(promises)
|
|
768
|
+
.then(function () { return __awaiter(_this, void 0, void 0, function () {
|
|
769
|
+
return __generator(this, function (_a) {
|
|
770
|
+
switch (_a.label) {
|
|
771
|
+
case 0: return [4 /*yield*/, (0, fs_1.copyDirectory)(__dirname + '/../include/require', options.output + 'require', options.verbose === true)];
|
|
772
|
+
case 1:
|
|
773
|
+
_a.sent(); //CSS, JavaScript
|
|
774
|
+
return [4 /*yield*/, (0, fs_1.copyDirectory)(options.input + '/files', options.output + 'files', options.verbose === true)];
|
|
775
|
+
case 2:
|
|
776
|
+
_a.sent(); //user-attached files and images
|
|
777
|
+
if (!(options.mathKatex === true)) return [3 /*break*/, 4];
|
|
778
|
+
return [4 /*yield*/, (0, fs_1.copyDirectory)(__dirname + '/../include/optional/katex', options.output + 'require/katex', options.verbose === true)];
|
|
779
|
+
case 3:
|
|
780
|
+
_a.sent();
|
|
781
|
+
_a.label = 4;
|
|
782
|
+
case 4:
|
|
783
|
+
checkPdfVersion();
|
|
784
|
+
return [2 /*return*/];
|
|
785
|
+
}
|
|
786
|
+
});
|
|
787
|
+
}); })
|
|
788
|
+
.catch(function (error) {
|
|
789
|
+
console.log(chalk_1.default.red('Error writing the web page files'));
|
|
790
|
+
if (options.verbose === true) {
|
|
791
|
+
console.log(chalk_1.default.red(error));
|
|
792
|
+
}
|
|
793
|
+
mainProcess.exit(1);
|
|
794
|
+
});
|
|
795
|
+
return [2 /*return*/];
|
|
772
796
|
}
|
|
773
|
-
mainProcess.exit(1);
|
|
774
797
|
});
|
|
775
|
-
};
|
|
798
|
+
}); };
|
|
776
799
|
/*
|
|
777
800
|
wkthmltopdf options
|
|
778
801
|
*/
|
|
@@ -815,16 +838,16 @@ function DocGen(process) {
|
|
|
815
838
|
var args = pdfOptions.join('');
|
|
816
839
|
args += allPages;
|
|
817
840
|
args += ' ' + options.output + pdfName;
|
|
818
|
-
return
|
|
841
|
+
return (0, spawn_args_1.default)(args);
|
|
819
842
|
};
|
|
820
843
|
var checkPdfVersion = function () {
|
|
821
844
|
if (options.pdf === true) {
|
|
822
845
|
//first check that wkhtmltopdf is installed
|
|
823
846
|
(0, child_process_1.exec)(options.wkhtmltopdfPath + ' -V', function (error, stdout, stderr) {
|
|
824
847
|
if (error) {
|
|
825
|
-
console.log(
|
|
848
|
+
console.log(chalk_1.default.red('Unable to call wkhtmltopdf. Is it installed and in path? See http://wkhtmltopdf.org'));
|
|
826
849
|
if (options.verbose === true) {
|
|
827
|
-
console.log(
|
|
850
|
+
console.log(chalk_1.default.red(error));
|
|
828
851
|
}
|
|
829
852
|
mainProcess.exit(1);
|
|
830
853
|
}
|
|
@@ -835,9 +858,9 @@ function DocGen(process) {
|
|
|
835
858
|
var warning = 'Warning: unexpected version of wkhtmltopdf, which may work but is not tested or supported';
|
|
836
859
|
var expectedVersion = ' expected version: ' + wkhtmltopdfVersion;
|
|
837
860
|
var detectedVersion = ' detected version: ' + actualWkhtmltopdfVersion;
|
|
838
|
-
console.log(
|
|
839
|
-
console.log(
|
|
840
|
-
console.log(
|
|
861
|
+
console.log(chalk_1.default.yellow(warning));
|
|
862
|
+
console.log(chalk_1.default.yellow(expectedVersion));
|
|
863
|
+
console.log(chalk_1.default.yellow(detectedVersion));
|
|
841
864
|
}
|
|
842
865
|
generatePdf();
|
|
843
866
|
}
|
|
@@ -851,15 +874,15 @@ function DocGen(process) {
|
|
|
851
874
|
call wkhtmltopdf as an external executable
|
|
852
875
|
*/
|
|
853
876
|
var generatePdf = function () {
|
|
854
|
-
console.log(
|
|
877
|
+
console.log(chalk_1.default.green('Creating the PDF copy (may take some time)'));
|
|
855
878
|
var args = getPdfArguments();
|
|
856
879
|
var wkhtmltopdf = (0, child_process_1.spawn)(options.wkhtmltopdfPath, args);
|
|
857
|
-
var spinner = new
|
|
880
|
+
var spinner = new cli_spinner_1.Spinner(chalk_1.default.green(' Processing... %s'));
|
|
858
881
|
spinner.setSpinnerString('|/-\\');
|
|
859
882
|
wkhtmltopdf.on('error', function (error) {
|
|
860
|
-
console.log(
|
|
883
|
+
console.log(chalk_1.default.red('Error calling wkhtmltopdf to generate the PDF'));
|
|
861
884
|
if (options.verbose === true) {
|
|
862
|
-
console.log(
|
|
885
|
+
console.log(chalk_1.default.red(error));
|
|
863
886
|
}
|
|
864
887
|
});
|
|
865
888
|
if (options.verbose !== true) {
|
|
@@ -884,45 +907,63 @@ function DocGen(process) {
|
|
|
884
907
|
}
|
|
885
908
|
if (code !== 0) {
|
|
886
909
|
var warning = 'wkhtmltopdf exited with a warning or error: try the -v option for details';
|
|
887
|
-
console.log(
|
|
910
|
+
console.log(chalk_1.default.yellow(warning));
|
|
888
911
|
}
|
|
889
912
|
cleanUp();
|
|
890
913
|
});
|
|
891
914
|
};
|
|
892
|
-
var createRedirect = function () {
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
915
|
+
var createRedirect = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
916
|
+
var parent_1, homepage, redirectLink, $, file, error_1;
|
|
917
|
+
return __generator(this, function (_a) {
|
|
918
|
+
switch (_a.label) {
|
|
919
|
+
case 0:
|
|
920
|
+
if (!options.redirect) return [3 /*break*/, 4];
|
|
921
|
+
parent_1 = options.output.replace(/\/$/, '');
|
|
922
|
+
parent_1 = parent_1.split(path_1.default.sep).slice(-1).pop(); //get name of final directory in the path
|
|
923
|
+
homepage = meta.contents[0].pages[0];
|
|
924
|
+
homepage =
|
|
925
|
+
homepage.source.substr(0, homepage.source.lastIndexOf('.')) + '.html';
|
|
926
|
+
redirectLink = parent_1 + '/' + homepage;
|
|
927
|
+
$ = templates.redirect;
|
|
928
|
+
$('a').attr('href', redirectLink);
|
|
929
|
+
$('meta[http-equiv=REFRESH]').attr('content', '0;url=' + redirectLink);
|
|
930
|
+
file = options.output + '../' + 'index.html';
|
|
931
|
+
_a.label = 1;
|
|
932
|
+
case 1:
|
|
933
|
+
_a.trys.push([1, 3, , 4]);
|
|
934
|
+
return [4 /*yield*/, (0, fs_1.writeFile)(file, $.html())];
|
|
935
|
+
case 2:
|
|
936
|
+
_a.sent();
|
|
937
|
+
return [3 /*break*/, 4];
|
|
938
|
+
case 3:
|
|
939
|
+
error_1 = _a.sent();
|
|
940
|
+
console.log(chalk_1.default.red('Error writing redirect file: ' + file));
|
|
941
|
+
if (options.verbose === true) {
|
|
942
|
+
console.log(chalk_1.default.red(error_1));
|
|
943
|
+
}
|
|
944
|
+
return [3 /*break*/, 4];
|
|
945
|
+
case 4: return [2 /*return*/];
|
|
913
946
|
}
|
|
914
|
-
}
|
|
915
|
-
};
|
|
947
|
+
});
|
|
948
|
+
}); };
|
|
916
949
|
/*
|
|
917
950
|
cleanup
|
|
918
951
|
*/
|
|
919
|
-
var cleanUp = function () {
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
952
|
+
var cleanUp = function () { return __awaiter(_this, void 0, void 0, function () {
|
|
953
|
+
return __generator(this, function (_a) {
|
|
954
|
+
switch (_a.label) {
|
|
955
|
+
case 0:
|
|
956
|
+
createRedirect();
|
|
957
|
+
if (!(options.pdf === true)) return [3 /*break*/, 2];
|
|
958
|
+
return [4 /*yield*/, (0, fs_1.removeDirectory)(options.output + 'temp')];
|
|
959
|
+
case 1:
|
|
960
|
+
_a.sent();
|
|
961
|
+
_a.label = 2;
|
|
962
|
+
case 2:
|
|
963
|
+
console.log(chalk_1.default.green.bold('Done!'));
|
|
964
|
+
return [2 /*return*/];
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
}); };
|
|
927
968
|
}
|
|
928
|
-
|
|
969
|
+
exports.DocGen = DocGen;
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
|
+
};
|
|
41
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
+
exports.removeDirectory = exports.makeDirectory = exports.cleanDirectory = exports.copyDirectory = exports.writeFile = exports.readFile = void 0;
|
|
43
|
+
var path_1 = __importDefault(require("path"));
|
|
44
|
+
var chalk_1 = __importDefault(require("chalk"));
|
|
45
|
+
var fs_1 = require("fs");
|
|
46
|
+
var fs_extra_1 = __importDefault(require("fs-extra"));
|
|
47
|
+
var readFile = function (filePath) { return __awaiter(void 0, void 0, void 0, function () {
|
|
48
|
+
var normalized, error_1;
|
|
49
|
+
var _a;
|
|
50
|
+
return __generator(this, function (_b) {
|
|
51
|
+
switch (_b.label) {
|
|
52
|
+
case 0:
|
|
53
|
+
normalized = path_1.default.normalize(filePath);
|
|
54
|
+
_b.label = 1;
|
|
55
|
+
case 1:
|
|
56
|
+
_b.trys.push([1, 3, , 4]);
|
|
57
|
+
return [4 /*yield*/, fs_1.promises.readFile(normalized, { encoding: 'utf8' })];
|
|
58
|
+
case 2: return [2 /*return*/, (_a = (_b.sent())) === null || _a === void 0 ? void 0 : _a.replace(/^\uFEFF/, '')]; //remove the BOM (byte-order-mark) from UTF-8 files, if present
|
|
59
|
+
case 3:
|
|
60
|
+
error_1 = _b.sent();
|
|
61
|
+
console.log(chalk_1.default.red('Error reading file: ' + normalized));
|
|
62
|
+
return [3 /*break*/, 4];
|
|
63
|
+
case 4: return [2 /*return*/];
|
|
64
|
+
}
|
|
65
|
+
});
|
|
66
|
+
}); };
|
|
67
|
+
exports.readFile = readFile;
|
|
68
|
+
var writeFile = function (filePath, data) { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
|
+
var normalized, error_2;
|
|
70
|
+
return __generator(this, function (_a) {
|
|
71
|
+
switch (_a.label) {
|
|
72
|
+
case 0:
|
|
73
|
+
normalized = path_1.default.normalize(filePath);
|
|
74
|
+
_a.label = 1;
|
|
75
|
+
case 1:
|
|
76
|
+
_a.trys.push([1, 3, , 4]);
|
|
77
|
+
return [4 /*yield*/, fs_1.promises.writeFile(normalized, data, { encoding: 'utf8' })];
|
|
78
|
+
case 2:
|
|
79
|
+
_a.sent(); //remove the BOM (byte-order-mark) from UTF-8 files, if present
|
|
80
|
+
return [3 /*break*/, 4];
|
|
81
|
+
case 3:
|
|
82
|
+
error_2 = _a.sent();
|
|
83
|
+
console.log(chalk_1.default.red('Error writing file: ' + normalized));
|
|
84
|
+
return [3 /*break*/, 4];
|
|
85
|
+
case 4: return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); };
|
|
89
|
+
exports.writeFile = writeFile;
|
|
90
|
+
var copyDirectory = function (source, destination, verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
91
|
+
var normalizedSource, normalizedDestination, error_3;
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
normalizedSource = path_1.default.normalize(source);
|
|
96
|
+
normalizedDestination = path_1.default.normalize(destination);
|
|
97
|
+
_a.label = 1;
|
|
98
|
+
case 1:
|
|
99
|
+
_a.trys.push([1, 3, , 4]);
|
|
100
|
+
return [4 /*yield*/, fs_extra_1.default.copySync(normalizedSource, normalizedDestination)];
|
|
101
|
+
case 2:
|
|
102
|
+
_a.sent();
|
|
103
|
+
return [3 /*break*/, 4];
|
|
104
|
+
case 3:
|
|
105
|
+
error_3 = _a.sent();
|
|
106
|
+
console.log(chalk_1.default.red('Error copying directory: ' +
|
|
107
|
+
normalizedSource +
|
|
108
|
+
' to ' +
|
|
109
|
+
normalizedDestination));
|
|
110
|
+
if (verbose === true) {
|
|
111
|
+
console.log(chalk_1.default.red(error_3));
|
|
112
|
+
}
|
|
113
|
+
return [3 /*break*/, 4];
|
|
114
|
+
case 4: return [2 /*return*/];
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
}); };
|
|
118
|
+
exports.copyDirectory = copyDirectory;
|
|
119
|
+
var cleanDirectory = function (directoryPath, verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
120
|
+
var normalized, error_4;
|
|
121
|
+
return __generator(this, function (_a) {
|
|
122
|
+
switch (_a.label) {
|
|
123
|
+
case 0:
|
|
124
|
+
normalized = path_1.default.normalize(directoryPath);
|
|
125
|
+
_a.label = 1;
|
|
126
|
+
case 1:
|
|
127
|
+
_a.trys.push([1, 4, , 5]);
|
|
128
|
+
return [4 /*yield*/, fs_extra_1.default.removeSync(normalized)];
|
|
129
|
+
case 2:
|
|
130
|
+
_a.sent();
|
|
131
|
+
return [4 /*yield*/, fs_extra_1.default.mkdirpSync(normalized)];
|
|
132
|
+
case 3:
|
|
133
|
+
_a.sent();
|
|
134
|
+
return [3 /*break*/, 5];
|
|
135
|
+
case 4:
|
|
136
|
+
error_4 = _a.sent();
|
|
137
|
+
console.log(chalk_1.default.red('Error recreating directory: ' + normalized));
|
|
138
|
+
if (verbose === true) {
|
|
139
|
+
console.log(chalk_1.default.red(error_4));
|
|
140
|
+
}
|
|
141
|
+
return [3 /*break*/, 5];
|
|
142
|
+
case 5: return [2 /*return*/];
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
}); };
|
|
146
|
+
exports.cleanDirectory = cleanDirectory;
|
|
147
|
+
var makeDirectory = function (path) { return __awaiter(void 0, void 0, void 0, function () { return __generator(this, function (_a) {
|
|
148
|
+
switch (_a.label) {
|
|
149
|
+
case 0: return [4 /*yield*/, fs_extra_1.default.mkdirsSync(path)];
|
|
150
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
151
|
+
}
|
|
152
|
+
}); }); };
|
|
153
|
+
exports.makeDirectory = makeDirectory;
|
|
154
|
+
var removeDirectory = function (directoryPath, verbose) { return __awaiter(void 0, void 0, void 0, function () {
|
|
155
|
+
var normalized, error_5;
|
|
156
|
+
return __generator(this, function (_a) {
|
|
157
|
+
switch (_a.label) {
|
|
158
|
+
case 0:
|
|
159
|
+
normalized = path_1.default.normalize(directoryPath);
|
|
160
|
+
_a.label = 1;
|
|
161
|
+
case 1:
|
|
162
|
+
_a.trys.push([1, 3, , 4]);
|
|
163
|
+
return [4 /*yield*/, fs_extra_1.default.removeSync(normalized)];
|
|
164
|
+
case 2:
|
|
165
|
+
_a.sent();
|
|
166
|
+
return [3 /*break*/, 4];
|
|
167
|
+
case 3:
|
|
168
|
+
error_5 = _a.sent();
|
|
169
|
+
console.log(chalk_1.default.red('Error removing directory: ' + normalized));
|
|
170
|
+
if (verbose === true) {
|
|
171
|
+
console.log(chalk_1.default.red(error_5));
|
|
172
|
+
}
|
|
173
|
+
return [3 /*break*/, 4];
|
|
174
|
+
case 4: return [2 /*return*/];
|
|
175
|
+
}
|
|
176
|
+
});
|
|
177
|
+
}); };
|
|
178
|
+
exports.removeDirectory = removeDirectory;
|
package/dist/docgen.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var
|
|
2
|
+
"use strict";
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
var commander_1 = require("commander");
|
|
5
|
+
var docgen_1 = require("./docgen/docgen");
|
|
6
|
+
var generator = new docgen_1.DocGen(process);
|
|
5
7
|
var scaffold = function (command) {
|
|
6
8
|
generator.setOptions(command);
|
|
7
9
|
generator.scaffold();
|
|
@@ -15,8 +17,8 @@ var run = function (command) {
|
|
|
15
17
|
commander help: http://slides.com/timsanteford/conquering-commander-js
|
|
16
18
|
command-line conventions: http://docopt.org
|
|
17
19
|
*/
|
|
18
|
-
program.version(generator.getVersion()).usage('[command] [--option]');
|
|
19
|
-
program
|
|
20
|
+
commander_1.program.version(generator.getVersion()).usage('[command] [--option]');
|
|
21
|
+
commander_1.program
|
|
20
22
|
.command('scaffold')
|
|
21
23
|
.usage('[--option]')
|
|
22
24
|
.description('create a template input directory')
|
|
@@ -25,7 +27,7 @@ program
|
|
|
25
27
|
.action(function (command) {
|
|
26
28
|
scaffold(command);
|
|
27
29
|
});
|
|
28
|
-
program
|
|
30
|
+
commander_1.program
|
|
29
31
|
.command('run')
|
|
30
32
|
.usage('[--option]')
|
|
31
33
|
.description('create a static website from an input directory')
|
|
@@ -44,8 +46,8 @@ program
|
|
|
44
46
|
.action(function (command) {
|
|
45
47
|
run(command);
|
|
46
48
|
});
|
|
47
|
-
program.parse(process.argv);
|
|
49
|
+
commander_1.program.parse(process.argv);
|
|
48
50
|
//if no arguments were provided, show help and then exit
|
|
49
51
|
if (!process.argv.slice(2).length) {
|
|
50
|
-
program.help();
|
|
52
|
+
commander_1.program.help();
|
|
51
53
|
}
|
|
@@ -477,9 +477,6 @@ header #headerLeftText #headerSponsor #sponsorLogo {
|
|
|
477
477
|
header #headerRightBlock {
|
|
478
478
|
margin-left: auto;
|
|
479
479
|
}
|
|
480
|
-
header #headerRightBlock a {
|
|
481
|
-
padding: 5px 10px;
|
|
482
|
-
}
|
|
483
480
|
|
|
484
481
|
/*
|
|
485
482
|
footer
|
|
@@ -858,7 +855,7 @@ button,
|
|
|
858
855
|
border: 2px solid rgb(46, 113, 225);
|
|
859
856
|
background: rgb(46, 113, 225);
|
|
860
857
|
color: white !important;
|
|
861
|
-
padding: 12px
|
|
858
|
+
padding: 12px 18px;
|
|
862
859
|
text-transform: none;
|
|
863
860
|
text-shadow: none;
|
|
864
861
|
line-height: 1em;
|
|
@@ -897,7 +894,7 @@ button:active,
|
|
|
897
894
|
}
|
|
898
895
|
button .icon,
|
|
899
896
|
.button .icon {
|
|
900
|
-
margin: 0 0 0
|
|
897
|
+
margin: 0 0 0 10px;
|
|
901
898
|
}
|
|
902
899
|
button .icon svg,
|
|
903
900
|
.button .icon svg {
|
package/package.json
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "docgen-tool",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "A tool for creating HTML and PDF documentation",
|
|
5
|
-
"main": "dist/docgen.
|
|
5
|
+
"main": "dist/docgen.ts",
|
|
6
6
|
"bin": {
|
|
7
|
-
"docgen": "dist/docgen.
|
|
7
|
+
"docgen": "dist/docgen.ts"
|
|
8
8
|
},
|
|
9
9
|
"files": [
|
|
10
10
|
"dist/*"
|
|
11
11
|
],
|
|
12
12
|
"scripts": {
|
|
13
13
|
"copy:files": "ncp src/include dist/include",
|
|
14
|
-
"dev": "ts-node src/docgen.
|
|
14
|
+
"dev": "ts-node src/docgen.ts run",
|
|
15
15
|
"build": "rimraf dist && tsc -p tsconfig.json && yarn copy:files",
|
|
16
|
-
"run:build": "dist/docgen.
|
|
17
|
-
"build:docs": "ts-node src/docgen.
|
|
18
|
-
"build:docs:nopdf": "ts-node src/docgen.
|
|
16
|
+
"run:build": "dist/docgen.ts",
|
|
17
|
+
"build:docs": "ts-node src/docgen.ts run -i src/docs -o ./docs -p -m -n -d 40000",
|
|
18
|
+
"build:docs:nopdf": "ts-node src/docgen.ts run -i src/docs -m -n -o ./docs",
|
|
19
19
|
"build:styles": "sass --no-source-map src/styles/main.scss src/include/require/styles/framework.css",
|
|
20
20
|
"test": "npm run prettier:check",
|
|
21
|
-
"test:run": "rimraf src/__test__/test-run-output && ts-node src/docgen.
|
|
22
|
-
"test:prod:run": "rimraf src/__test__/test-run-output && ./dist/docgen.
|
|
23
|
-
"prettier:check": "prettier --check 'src/docgen.
|
|
24
|
-
"prettier:fix": "prettier --write 'src/docgen.
|
|
21
|
+
"test:run": "rimraf src/__test__/test-run-output && ts-node src/docgen.ts run -i src/__test__/test-run -o src/__test__/test-run-output -p -m -n -d 40000",
|
|
22
|
+
"test:prod:run": "rimraf src/__test__/test-run-output && ./dist/docgen.ts run -i src/__test__/test-run -o ../source/__test__/test-run-output -p -m -n -d 40000",
|
|
23
|
+
"prettier:check": "prettier --check 'src/docgen.ts' '*.{js,json,css,less}'",
|
|
24
|
+
"prettier:fix": "prettier --write 'src/docgen.ts' '*.{js,json,css,less}'"
|
|
25
25
|
},
|
|
26
26
|
"husky": {
|
|
27
27
|
"hooks": {
|