vuepress-jsdoc 4.3.1 → 5.0.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/CHANGELOG.md +20 -1
- package/README.md +11 -31
- package/dist/cmds.js +4 -4
- package/dist/constants.js +1 -1
- package/dist/index.d.ts +2 -8
- package/dist/index.js +117 -308
- package/dist/lib/comment-parser.js +12 -12
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.js +16 -0
- package/dist/lib/list-folder.js +54 -170
- package/dist/lib/parser.js +116 -216
- package/dist/lib/utils.js +4 -6
- package/dist/lib/vue-sidebar.d.ts +8 -5
- package/dist/lib/vue-sidebar.js +27 -50
- package/package.json +27 -25
package/dist/lib/parser.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
3
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
4
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -19,58 +8,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
19
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
9
|
});
|
|
21
10
|
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (_) try {
|
|
29
|
-
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;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
50
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
51
|
-
if (!m) return o;
|
|
52
|
-
var i = m.call(o), r, ar = [], e;
|
|
53
|
-
try {
|
|
54
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
55
|
-
}
|
|
56
|
-
catch (error) { e = { error: error }; }
|
|
57
|
-
finally {
|
|
58
|
-
try {
|
|
59
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
60
|
-
}
|
|
61
|
-
finally { if (e) throw e.error; }
|
|
62
|
-
}
|
|
63
|
-
return ar;
|
|
64
|
-
};
|
|
65
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
66
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
67
|
-
if (ar || !(i in from)) {
|
|
68
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
69
|
-
ar[i] = from[i];
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
73
|
-
};
|
|
74
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
75
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
13
|
};
|
|
@@ -82,14 +19,14 @@ exports.writeContentToFile = exports.parseVueFile = exports.parseFile = void 0;
|
|
|
82
19
|
* headline: lib/parser.ts
|
|
83
20
|
* ---
|
|
84
21
|
*/
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
22
|
+
const jsdoc_to_markdown_1 = __importDefault(require("jsdoc-to-markdown"));
|
|
23
|
+
const mkdirp_1 = require("mkdirp");
|
|
24
|
+
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
25
|
+
const node_path_1 = require("node:path");
|
|
26
|
+
const compileTemplates_1 = __importDefault(require("vue-docgen-cli/lib/compileTemplates"));
|
|
27
|
+
const docgen_1 = require("vue-docgen-cli/lib/docgen");
|
|
28
|
+
const constants_1 = require("../constants");
|
|
29
|
+
const comment_parser_1 = require("./comment-parser");
|
|
93
30
|
/**
|
|
94
31
|
* Parse a typescript or javascript file
|
|
95
32
|
* @param file {DirectoryFile}
|
|
@@ -99,69 +36,57 @@ var comment_parser_1 = require("./comment-parser");
|
|
|
99
36
|
* @param partials {string | string[]}
|
|
100
37
|
* @returns {object} file data
|
|
101
38
|
*/
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
_b.trys.push([1, 4, , 5]);
|
|
120
|
-
content = '';
|
|
121
|
-
fileName = file.name;
|
|
122
|
-
if (fileName === '__index__') {
|
|
123
|
-
fileName = 'index';
|
|
124
|
-
}
|
|
125
|
-
return [4 /*yield*/, jsdoc_to_markdown_1.default.render({
|
|
126
|
-
'no-cache': configPath ? true : false,
|
|
127
|
-
files: [(0, path_1.join)(process.cwd(), file.folder, fileName + file.ext)],
|
|
128
|
-
configure: configPath,
|
|
129
|
-
partial: __spreadArray([
|
|
130
|
-
(0, path_1.resolve)(__filename, '../../../template/header.hbs'),
|
|
131
|
-
(0, path_1.resolve)(__filename, '../../../template/main.hbs')
|
|
132
|
-
], __read(partials), false)
|
|
133
|
-
})];
|
|
134
|
-
case 2:
|
|
135
|
-
content = _b.sent();
|
|
136
|
-
_a = comment_parser_1.parseVuepressFileHeader;
|
|
137
|
-
return [4 /*yield*/, promises_1.default.readFile("".concat((0, path_1.join)(folderInSrc, fileName + file.ext)), 'utf-8')];
|
|
138
|
-
case 3:
|
|
139
|
-
fileContent = _a.apply(void 0, [_b.sent(), file]);
|
|
140
|
-
if (content) {
|
|
141
|
-
fileContent += content;
|
|
142
|
-
}
|
|
143
|
-
else {
|
|
144
|
-
empty = true;
|
|
145
|
-
}
|
|
146
|
-
return [3 /*break*/, 5];
|
|
147
|
-
case 4:
|
|
148
|
-
e_1 = _b.sent();
|
|
149
|
-
success = false;
|
|
150
|
-
excluded = true;
|
|
151
|
-
return [3 /*break*/, 5];
|
|
152
|
-
case 5: return [2 /*return*/, {
|
|
153
|
-
success: success,
|
|
154
|
-
file: file,
|
|
155
|
-
empty: empty,
|
|
156
|
-
excluded: excluded,
|
|
157
|
-
relativePathDest: relativePathDest,
|
|
158
|
-
relativePathSrc: file.folder,
|
|
159
|
-
dest: folderInDest,
|
|
160
|
-
content: fileContent
|
|
161
|
-
}];
|
|
39
|
+
const parseFile = (file, srcFolder, destFolder, configPath, partials) => __awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
+
if (!file.folder)
|
|
41
|
+
return null;
|
|
42
|
+
const root = process.cwd();
|
|
43
|
+
const relativePathDest = (0, node_path_1.join)(destFolder, file.folder.replace(srcFolder, ''));
|
|
44
|
+
const folderInDest = (0, node_path_1.join)(root, relativePathDest);
|
|
45
|
+
const folderInSrc = (0, node_path_1.join)(root, file.folder);
|
|
46
|
+
let success = true;
|
|
47
|
+
let empty = false;
|
|
48
|
+
let excluded = false;
|
|
49
|
+
let fileContent = '';
|
|
50
|
+
// parse file
|
|
51
|
+
try {
|
|
52
|
+
let content = '';
|
|
53
|
+
let fileName = file.name;
|
|
54
|
+
if (fileName.endsWith('index')) {
|
|
55
|
+
fileName = 'index';
|
|
162
56
|
}
|
|
163
|
-
|
|
164
|
-
|
|
57
|
+
content = yield jsdoc_to_markdown_1.default.render({
|
|
58
|
+
'no-cache': configPath ? true : false,
|
|
59
|
+
files: [(0, node_path_1.join)(process.cwd(), file.folder, fileName + file.ext)],
|
|
60
|
+
configure: configPath,
|
|
61
|
+
partial: [
|
|
62
|
+
(0, node_path_1.resolve)(__filename, '../../../template/header.hbs'),
|
|
63
|
+
(0, node_path_1.resolve)(__filename, '../../../template/main.hbs'),
|
|
64
|
+
...partials
|
|
65
|
+
]
|
|
66
|
+
});
|
|
67
|
+
fileContent = (0, comment_parser_1.parseVuepressFileHeader)(yield promises_1.default.readFile(`${(0, node_path_1.join)(folderInSrc, fileName + file.ext)}`, 'utf-8'), file);
|
|
68
|
+
if (content) {
|
|
69
|
+
fileContent += content;
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
empty = true;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
catch (e) {
|
|
76
|
+
success = false;
|
|
77
|
+
excluded = true;
|
|
78
|
+
}
|
|
79
|
+
return {
|
|
80
|
+
success,
|
|
81
|
+
file,
|
|
82
|
+
empty,
|
|
83
|
+
excluded,
|
|
84
|
+
relativePathDest,
|
|
85
|
+
relativePathSrc: file.folder,
|
|
86
|
+
dest: folderInDest,
|
|
87
|
+
content: fileContent
|
|
88
|
+
};
|
|
89
|
+
});
|
|
165
90
|
exports.parseFile = parseFile;
|
|
166
91
|
/**
|
|
167
92
|
* Parse a vue file
|
|
@@ -170,59 +95,47 @@ exports.parseFile = parseFile;
|
|
|
170
95
|
* @param {string} destFolder
|
|
171
96
|
* @returns {object} file data
|
|
172
97
|
*/
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
case 1:
|
|
190
|
-
_b.trys.push([1, 4, , 5]);
|
|
191
|
-
fileName = file.name;
|
|
192
|
-
if (fileName === '__index__') {
|
|
193
|
-
fileName = 'index';
|
|
194
|
-
}
|
|
195
|
-
return [4 /*yield*/, (0, compileTemplates_1.default)((0, path_1.join)(config.componentsRoot, fileName + file.ext), config, fileName + file.ext)];
|
|
196
|
-
case 2:
|
|
197
|
-
data = _b.sent();
|
|
198
|
-
_a = comment_parser_1.parseVuepressFileHeader;
|
|
199
|
-
return [4 /*yield*/, promises_1.default.readFile("".concat((0, path_1.join)(folderInSrc, fileName + file.ext)), 'utf-8')];
|
|
200
|
-
case 3:
|
|
201
|
-
fileContent = _a.apply(void 0, [_b.sent(), file]);
|
|
202
|
-
if (data.content) {
|
|
203
|
-
fileContent += data.content;
|
|
204
|
-
}
|
|
205
|
-
else {
|
|
206
|
-
empty = true;
|
|
207
|
-
}
|
|
208
|
-
return [3 /*break*/, 5];
|
|
209
|
-
case 4:
|
|
210
|
-
e_2 = _b.sent();
|
|
211
|
-
console.log(e_2);
|
|
212
|
-
success = false;
|
|
213
|
-
return [3 /*break*/, 5];
|
|
214
|
-
case 5: return [2 /*return*/, {
|
|
215
|
-
success: success,
|
|
216
|
-
file: file,
|
|
217
|
-
empty: empty,
|
|
218
|
-
relativePathDest: relativePathDest,
|
|
219
|
-
relativePathSrc: file.folder,
|
|
220
|
-
dest: folderInDest,
|
|
221
|
-
content: fileContent
|
|
222
|
-
}];
|
|
98
|
+
const parseVueFile = (file, srcFolder, destFolder) => __awaiter(void 0, void 0, void 0, function* () {
|
|
99
|
+
if (!file.folder)
|
|
100
|
+
return null;
|
|
101
|
+
const root = process.cwd();
|
|
102
|
+
const relativePathDest = (0, node_path_1.join)(destFolder, file.folder.replace(srcFolder, ''));
|
|
103
|
+
const folderInDest = (0, node_path_1.join)(root, relativePathDest);
|
|
104
|
+
const folderInSrc = (0, node_path_1.join)(root, file.folder);
|
|
105
|
+
const vueDocGenCliConf = yield (0, docgen_1.extractConfig)((0, node_path_1.join)(root, file.folder));
|
|
106
|
+
const config = Object.assign(Object.assign({}, vueDocGenCliConf), { components: file.name + file.ext });
|
|
107
|
+
let success = true;
|
|
108
|
+
let empty = false;
|
|
109
|
+
let fileContent = '';
|
|
110
|
+
try {
|
|
111
|
+
let fileName = file.name;
|
|
112
|
+
if (fileName.endsWith('index')) {
|
|
113
|
+
fileName = 'index';
|
|
223
114
|
}
|
|
224
|
-
|
|
225
|
-
|
|
115
|
+
// parse file
|
|
116
|
+
const data = yield (0, compileTemplates_1.default)('add', (0, node_path_1.join)(config.componentsRoot, fileName + file.ext), config, fileName + file.ext);
|
|
117
|
+
fileContent = (0, comment_parser_1.parseVuepressFileHeader)(yield promises_1.default.readFile(`${(0, node_path_1.join)(folderInSrc, fileName + file.ext)}`, 'utf-8'), file);
|
|
118
|
+
if (data.content) {
|
|
119
|
+
fileContent += data.content;
|
|
120
|
+
}
|
|
121
|
+
else {
|
|
122
|
+
empty = true;
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
catch (e) {
|
|
126
|
+
console.log(e);
|
|
127
|
+
success = false;
|
|
128
|
+
}
|
|
129
|
+
return {
|
|
130
|
+
success,
|
|
131
|
+
file,
|
|
132
|
+
empty,
|
|
133
|
+
relativePathDest,
|
|
134
|
+
relativePathSrc: file.folder,
|
|
135
|
+
dest: folderInDest,
|
|
136
|
+
content: fileContent
|
|
137
|
+
};
|
|
138
|
+
});
|
|
226
139
|
exports.parseVueFile = parseVueFile;
|
|
227
140
|
/**
|
|
228
141
|
* Write content on disk
|
|
@@ -230,36 +143,23 @@ exports.parseVueFile = parseVueFile;
|
|
|
230
143
|
* @param {string} dest
|
|
231
144
|
* @returns {Promise | null} null or type with some data of the saved file
|
|
232
145
|
*/
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
_b.trys.push([1, 5, , 6]);
|
|
247
|
-
if (!(parseData === null || parseData === void 0 ? void 0 : parseData.content)) return [3 /*break*/, 4];
|
|
248
|
-
path = "".concat((0, path_1.join)(dest, parseData.file.name), ".md");
|
|
249
|
-
return [4 /*yield*/, (0, mkdirp_1.default)(dest)];
|
|
250
|
-
case 2:
|
|
251
|
-
_b.sent();
|
|
252
|
-
return [4 /*yield*/, promises_1.default.writeFile(path, parseData.content, 'utf-8')];
|
|
253
|
-
case 3:
|
|
254
|
-
_b.sent();
|
|
255
|
-
type = (parseData === null || parseData === void 0 ? void 0 : parseData.empty) ? constants_1.StatisticType.EMPTY : constants_1.StatisticType.INCLUDE;
|
|
256
|
-
_b.label = 4;
|
|
257
|
-
case 4: return [2 /*return*/, __assign(__assign({}, parseData), { type: type })];
|
|
258
|
-
case 5:
|
|
259
|
-
_a = _b.sent();
|
|
260
|
-
return [3 /*break*/, 6];
|
|
261
|
-
case 6: return [2 /*return*/, null];
|
|
146
|
+
const writeContentToFile = (parseData, dest) => __awaiter(void 0, void 0, void 0, function* () {
|
|
147
|
+
const root = process.cwd();
|
|
148
|
+
dest = (0, node_path_1.join)(root, dest);
|
|
149
|
+
let type = constants_1.StatisticType.ERROR;
|
|
150
|
+
if (parseData === null || parseData === void 0 ? void 0 : parseData.excluded) {
|
|
151
|
+
type = constants_1.StatisticType.EXCLUDE;
|
|
152
|
+
}
|
|
153
|
+
try {
|
|
154
|
+
if (parseData === null || parseData === void 0 ? void 0 : parseData.content) {
|
|
155
|
+
const path = `${(0, node_path_1.join)(dest, parseData.file.name)}.md`;
|
|
156
|
+
yield (0, mkdirp_1.mkdirp)(dest);
|
|
157
|
+
yield promises_1.default.writeFile(path, parseData.content, 'utf-8');
|
|
158
|
+
type = (parseData === null || parseData === void 0 ? void 0 : parseData.empty) ? constants_1.StatisticType.EMPTY : constants_1.StatisticType.INCLUDE;
|
|
262
159
|
}
|
|
263
|
-
|
|
264
|
-
}
|
|
160
|
+
return Object.assign(Object.assign({}, parseData), { type });
|
|
161
|
+
}
|
|
162
|
+
catch (_a) { }
|
|
163
|
+
return null;
|
|
164
|
+
});
|
|
265
165
|
exports.writeContentToFile = writeContentToFile;
|
package/dist/lib/utils.js
CHANGED
|
@@ -12,9 +12,7 @@ exports.getFilename = exports.checkExtension = exports.getExtension = void 0;
|
|
|
12
12
|
* @param {string} path
|
|
13
13
|
* @returns {string} extension of file
|
|
14
14
|
*/
|
|
15
|
-
|
|
16
|
-
return path && typeof path === 'string' ? path.substring(path.length, path.lastIndexOf('.')) : '';
|
|
17
|
-
};
|
|
15
|
+
const getExtension = (path) => path && typeof path === 'string' ? path.substring(path.length, path.lastIndexOf('.')) : '';
|
|
18
16
|
exports.getExtension = getExtension;
|
|
19
17
|
/**
|
|
20
18
|
* Check if extension ist correct
|
|
@@ -22,7 +20,7 @@ exports.getExtension = getExtension;
|
|
|
22
20
|
* @param {string[]} extensions
|
|
23
21
|
* @returns {boolean}
|
|
24
22
|
*/
|
|
25
|
-
|
|
23
|
+
const checkExtension = (path, extensions) => {
|
|
26
24
|
if (!extensions || !path || typeof path !== 'string')
|
|
27
25
|
return false;
|
|
28
26
|
return extensions.indexOf((0, exports.getExtension)(path)) >= 0;
|
|
@@ -33,11 +31,11 @@ exports.checkExtension = checkExtension;
|
|
|
33
31
|
* @param {string} path
|
|
34
32
|
* @returns {string} filename
|
|
35
33
|
*/
|
|
36
|
-
|
|
34
|
+
const getFilename = (path) => {
|
|
37
35
|
var _a;
|
|
38
36
|
if (!path || (path && typeof path !== 'string'))
|
|
39
37
|
return '';
|
|
40
|
-
|
|
38
|
+
const splitted = (_a = path.split('/').pop()) !== null && _a !== void 0 ? _a : path;
|
|
41
39
|
return splitted.substring(0, splitted.lastIndexOf('.'));
|
|
42
40
|
};
|
|
43
41
|
exports.getFilename = getFilename;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Runs through the given tree structure and creates a vuepress config
|
|
3
|
-
* @param {object} data
|
|
4
|
-
* @param {array} data.fileTree tree
|
|
3
|
+
* @param {object} data Information to build config
|
|
4
|
+
* @param {array} data.fileTree tree structure
|
|
5
5
|
* @param {string} data.codeFolder ./code/ folder
|
|
6
6
|
* @param {string} data.srcFolder ./src/ folder
|
|
7
7
|
* @param {string} data.docsFolder ./documentation/ folder
|
|
8
8
|
* @param {string} data.title title string
|
|
9
|
-
* @returns {object} returns the vuepress menu
|
|
9
|
+
* @returns {object} returns the vuepress menu structure
|
|
10
10
|
*/
|
|
11
11
|
export declare const generateVueSidebar: ({ fileTree, codeFolder, srcFolder, docsFolder, title }: {
|
|
12
12
|
fileTree: any;
|
|
@@ -16,8 +16,11 @@ export declare const generateVueSidebar: ({ fileTree, codeFolder, srcFolder, doc
|
|
|
16
16
|
title: string;
|
|
17
17
|
}) => {
|
|
18
18
|
[x: string]: {
|
|
19
|
-
|
|
19
|
+
text: string;
|
|
20
20
|
collapsable: boolean;
|
|
21
|
-
children:
|
|
21
|
+
children: {
|
|
22
|
+
link: string;
|
|
23
|
+
text: string;
|
|
24
|
+
}[];
|
|
22
25
|
}[];
|
|
23
26
|
};
|
package/dist/lib/vue-sidebar.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __values = (this && this.__values) || function(o) {
|
|
3
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
4
|
-
if (m) return m.call(o);
|
|
5
|
-
if (o && typeof o.length === "number") return {
|
|
6
|
-
next: function () {
|
|
7
|
-
if (o && i >= o.length) o = void 0;
|
|
8
|
-
return { value: o && o[i++], done: !o };
|
|
9
|
-
}
|
|
10
|
-
};
|
|
11
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
12
|
-
};
|
|
13
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
4
|
};
|
|
@@ -21,62 +10,50 @@ exports.generateVueSidebar = void 0;
|
|
|
21
10
|
* headline: lib/vue-sidebar.ts
|
|
22
11
|
* ---
|
|
23
12
|
*/
|
|
24
|
-
|
|
25
|
-
|
|
13
|
+
const node_fs_1 = __importDefault(require("node:fs"));
|
|
14
|
+
const node_path_1 = require("node:path");
|
|
26
15
|
/**
|
|
27
16
|
* Runs through the given tree structure and creates a vuepress config
|
|
28
|
-
* @param {object} data
|
|
29
|
-
* @param {array} data.fileTree tree
|
|
17
|
+
* @param {object} data Information to build config
|
|
18
|
+
* @param {array} data.fileTree tree structure
|
|
30
19
|
* @param {string} data.codeFolder ./code/ folder
|
|
31
20
|
* @param {string} data.srcFolder ./src/ folder
|
|
32
21
|
* @param {string} data.docsFolder ./documentation/ folder
|
|
33
22
|
* @param {string} data.title title string
|
|
34
|
-
* @returns {object} returns the vuepress menu
|
|
23
|
+
* @returns {object} returns the vuepress menu structure
|
|
35
24
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
try {
|
|
46
|
-
for (var children_1 = __values(children), children_1_1 = children_1.next(); !children_1_1.done; children_1_1 = children_1.next()) {
|
|
47
|
-
var child = children_1_1.value;
|
|
48
|
-
if (child.children && child.children.length > 0) {
|
|
49
|
-
newChildren = newChildren.concat(buildChildren(child.children, child.name, depth + 1));
|
|
50
|
-
}
|
|
51
|
-
else if (child.fullPath) {
|
|
52
|
-
if (fs_1.default.existsSync((0, path_1.join)(docsFolder, child.fullPath.replace(srcFolder, '')) + '.md')) {
|
|
53
|
-
newChildren.push(child.fullPath.replace("".concat(srcFolder, "/"), ''));
|
|
54
|
-
}
|
|
55
|
-
}
|
|
25
|
+
const generateVueSidebar = ({ fileTree, codeFolder, srcFolder, docsFolder, title }) => {
|
|
26
|
+
let rootFiles = [{ link: `/${codeFolder}/`, text: '::vuepress-jsdoc-title::' }];
|
|
27
|
+
rootFiles = rootFiles.concat(fileTree.filter((file) => !file.children).map((file) => `/${(0, node_path_1.join)(codeFolder, file.name)}`));
|
|
28
|
+
const rootFolder = fileTree.filter((file) => file.children && file.children.length > 0);
|
|
29
|
+
const buildChildren = (children, name, depth) => {
|
|
30
|
+
let newChildren = [];
|
|
31
|
+
for (const child of children) {
|
|
32
|
+
if (child.children && child.children.length > 0) {
|
|
33
|
+
newChildren = newChildren.concat(buildChildren(child.children, child.name, depth + 1));
|
|
56
34
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
35
|
+
else if (child.fullPath) {
|
|
36
|
+
const path = child.fullPath.replace(srcFolder, '');
|
|
37
|
+
if (node_fs_1.default.existsSync(`${(0, node_path_1.join)(docsFolder, path)}.md`)) {
|
|
38
|
+
newChildren.push(`/${(0, node_path_1.join)(codeFolder, path)}`);
|
|
39
|
+
}
|
|
62
40
|
}
|
|
63
|
-
finally { if (e_1) throw e_1.error; }
|
|
64
41
|
}
|
|
65
42
|
return newChildren;
|
|
66
43
|
};
|
|
67
|
-
|
|
68
|
-
|
|
44
|
+
const tree = rootFolder.map((folder) => ({
|
|
45
|
+
text: folder.name,
|
|
69
46
|
collapsable: false,
|
|
70
47
|
children: buildChildren(folder.children, folder.name, 0)
|
|
71
|
-
})
|
|
72
|
-
return
|
|
73
|
-
|
|
48
|
+
}));
|
|
49
|
+
return {
|
|
50
|
+
[`/${codeFolder}/`]: [
|
|
74
51
|
{
|
|
75
|
-
|
|
52
|
+
text: title,
|
|
76
53
|
collapsable: false,
|
|
77
54
|
children: rootFiles
|
|
78
55
|
}
|
|
79
|
-
].concat(tree)
|
|
80
|
-
|
|
56
|
+
].concat(tree)
|
|
57
|
+
};
|
|
81
58
|
};
|
|
82
59
|
exports.generateVueSidebar = generateVueSidebar;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vuepress-jsdoc",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0",
|
|
4
4
|
"description": "Generate jsdoc markdown files for vuepress",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -14,8 +14,8 @@
|
|
|
14
14
|
"prepare": "husky install",
|
|
15
15
|
"version": "conventional-changelog -p karma -i CHANGELOG.md -s -r 0 && git add .",
|
|
16
16
|
"docs": "./bin/vuepress-jsdoc.js --source=./dist --partials=./example/partials/*.hbs --readme ./README.md --include=\"**/*.(ts|js)\" --exclude=\"**/*.d.ts,**/interfaces.*,**/constants.*\"",
|
|
17
|
-
"docs:dev": "npx concurrently --kill-others \"npm run dev\" \"npm run docs -- -w\" \"
|
|
18
|
-
"docs:build": "npm run build && npm run docs &&
|
|
17
|
+
"docs:dev": "npx concurrently --kill-others \"npm run dev\" \"npm run docs -- -w\" \"vuepress dev documentation\"",
|
|
18
|
+
"docs:build": "npm run build && npm run docs && vuepress build documentation"
|
|
19
19
|
},
|
|
20
20
|
"keywords": [
|
|
21
21
|
"jsdoc",
|
|
@@ -79,37 +79,39 @@
|
|
|
79
79
|
"vuepress-jsdoc": "bin/vuepress-jsdoc.js"
|
|
80
80
|
},
|
|
81
81
|
"dependencies": {
|
|
82
|
-
"chalk": "^4.1.2",
|
|
83
82
|
"chokidar": "^3.5.3",
|
|
84
|
-
"commander": "^
|
|
83
|
+
"commander": "^11.1.0",
|
|
85
84
|
"del": "^6.0.0",
|
|
86
85
|
"front-matter": "^4.0.2",
|
|
87
|
-
"jsdoc-to-markdown": "^
|
|
86
|
+
"jsdoc-to-markdown": "^8.0.0",
|
|
87
|
+
"kleur": "^4.1.5",
|
|
88
88
|
"micromatch": "^4.0.5",
|
|
89
|
-
"mkdirp": "^
|
|
90
|
-
"vue-docgen-cli": "^4.
|
|
89
|
+
"mkdirp": "^3.0.1",
|
|
90
|
+
"vue-docgen-cli": "^4.67.0"
|
|
91
91
|
},
|
|
92
92
|
"devDependencies": {
|
|
93
|
-
"@types/jest": "^29.
|
|
94
|
-
"@types/jsdoc-to-markdown": "^7.0.
|
|
95
|
-
"@types/micromatch": "^4.0.
|
|
93
|
+
"@types/jest": "^29.5.10",
|
|
94
|
+
"@types/jsdoc-to-markdown": "^7.0.6",
|
|
95
|
+
"@types/micromatch": "^4.0.6",
|
|
96
96
|
"@types/mkdirp": "^1.0.2",
|
|
97
|
-
"@typescript-eslint/eslint-plugin": "^
|
|
98
|
-
"@typescript-eslint/parser": "^
|
|
99
|
-
"
|
|
97
|
+
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
98
|
+
"@typescript-eslint/parser": "^6.12.0",
|
|
99
|
+
"@vuepress/client": "^2.0.0-rc.0",
|
|
100
|
+
"babel-jest": "^29.7.0",
|
|
100
101
|
"cross-env": "^7.0.3",
|
|
101
|
-
"eslint": "^8.
|
|
102
|
-
"eslint-config-prettier": "^
|
|
103
|
-
"eslint-plugin-import": "^2.
|
|
104
|
-
"eslint-plugin-jest": "^27.
|
|
102
|
+
"eslint": "^8.54.0",
|
|
103
|
+
"eslint-config-prettier": "^9.0.0",
|
|
104
|
+
"eslint-plugin-import": "^2.29.0",
|
|
105
|
+
"eslint-plugin-jest": "^27.6.0",
|
|
105
106
|
"eslint-plugin-prefer-arrow": "^1.2.3",
|
|
106
|
-
"husky": "^8.0.
|
|
107
|
-
"jest": "^29.
|
|
108
|
-
"lint-staged": "^
|
|
109
|
-
"memfs": "^
|
|
110
|
-
"ts-jest": "^29.
|
|
111
|
-
"typescript": "^
|
|
112
|
-
"vue": "^
|
|
107
|
+
"husky": "^8.0.3",
|
|
108
|
+
"jest": "^29.7.0",
|
|
109
|
+
"lint-staged": "^15.1.0",
|
|
110
|
+
"memfs": "^4.6.0",
|
|
111
|
+
"ts-jest": "^29.1.1",
|
|
112
|
+
"typescript": "^5.3.2",
|
|
113
|
+
"vue": "^3.3.8",
|
|
114
|
+
"vuepress": "^2.0.0-rc.0"
|
|
113
115
|
},
|
|
114
116
|
"lint-staged": {
|
|
115
117
|
"src/**/*.{css,scss,json}": [
|