UNPKG

2.18 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const ts = require("typescript");
4const declaration_1 = require("./declaration");
5function getParameterHelp(options, scope) {
6 const parameters = options.getDeclarationsByScope(scope);
7 parameters.sort((a, b) => a.name.localeCompare(b.name, undefined, { sensitivity: 'base' }));
8 const names = [];
9 const helps = [];
10 let margin = 0;
11 for (let i = 0; i < parameters.length; i++) {
12 const parameter = parameters[i];
13 if (!parameter.help) {
14 continue;
15 }
16 let name = ' ';
17 if (parameter.short) {
18 name += '-' + parameter.short;
19 if (typeof parameter.hint !== 'undefined') {
20 name += ' ' + declaration_1.ParameterHint[parameter.hint].toUpperCase();
21 }
22 name += ', ';
23 }
24 name += '--' + parameter.name;
25 if (parameter.hint) {
26 name += ' ' + declaration_1.ParameterHint[parameter.hint].toUpperCase();
27 }
28 names.push(name);
29 helps.push(parameter.help);
30 margin = Math.max(name.length, margin);
31 }
32 return { names: names, helps: helps, margin: margin };
33}
34function getOptionsHelp(options) {
35 const typeDoc = getParameterHelp(options, declaration_1.ParameterScope.TypeDoc);
36 const output = [];
37 output.push('Usage:');
38 output.push(' typedoc --mode modules --out path/to/documentation path/to/sourcefiles');
39 output.push('', 'TypeDoc options:');
40 pushHelp(typeDoc);
41 output.push('', 'TypeScript options:');
42 output.push('See https://www.typescriptlang.org/docs/handbook/compiler-options.html');
43 output.push('');
44 return output.join(ts.sys.newLine);
45 function pushHelp(columns) {
46 for (let i = 0; i < columns.names.length; i++) {
47 const usage = columns.names[i];
48 const description = columns.helps[i];
49 output.push(usage + padding(typeDoc.margin - usage.length + 2) + description);
50 }
51 }
52 function padding(length) {
53 return Array(length + 1).join(' ');
54 }
55}
56exports.getOptionsHelp = getOptionsHelp;
57//# sourceMappingURL=help.js.map
\No newline at end of file