vuepress-jsdoc 5.0.0 → 6.1.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/README.md +168 -69
- package/bin/vuepress-jsdoc.js +7 -4
- package/dist/cmds.d.ts +4 -2
- package/dist/cmds.js +44 -17
- package/dist/constants.d.ts +16 -0
- package/dist/constants.js +18 -5
- package/dist/index.d.ts +46 -6
- package/dist/index.js +211 -163
- package/dist/interfaces.d.ts +45 -19
- package/dist/interfaces.js +1 -2
- package/dist/lib/comment-parser.d.ts +15 -9
- package/dist/lib/comment-parser.js +46 -52
- package/dist/lib/config.d.ts +21 -0
- package/dist/lib/config.js +57 -0
- package/dist/lib/list-folder.d.ts +30 -12
- package/dist/lib/list-folder.js +100 -70
- package/dist/lib/parser.d.ts +46 -30
- package/dist/lib/parser.js +199 -141
- package/dist/lib/vue-sidebar.d.ts +61 -21
- package/dist/lib/vue-sidebar.js +109 -43
- package/dist/lib/vuepress-plugin.d.ts +48 -0
- package/dist/lib/vuepress-plugin.js +63 -0
- package/package.json +66 -115
- package/CHANGELOG.md +0 -507
- package/dist/lib/index.d.ts +0 -6
- package/dist/lib/index.js +0 -16
- package/dist/lib/utils.d.ts +0 -19
- package/dist/lib/utils.js +0 -41
package/dist/index.js
CHANGED
|
@@ -1,18 +1,3 @@
|
|
|
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 __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
-
};
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.watchFiles = exports.generate = void 0;
|
|
16
1
|
/*
|
|
17
2
|
* @vuepress
|
|
18
3
|
* ---
|
|
@@ -20,181 +5,244 @@ exports.watchFiles = exports.generate = void 0;
|
|
|
20
5
|
* headline: The Main File
|
|
21
6
|
* ---
|
|
22
7
|
*/
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
8
|
+
import chokidar from 'chokidar';
|
|
9
|
+
import { deleteAsync } from 'del';
|
|
10
|
+
import kleur from 'kleur';
|
|
11
|
+
import fs from 'node:fs/promises';
|
|
12
|
+
import os from 'node:os';
|
|
13
|
+
import path from 'node:path';
|
|
14
|
+
import { StatisticType } from './constants.js';
|
|
15
|
+
import { getPageName, listFolder, normalizePath } from './lib/list-folder.js';
|
|
16
|
+
import { getDestFolder, parseFile, writeContentToFile } from './lib/parser.js';
|
|
17
|
+
import { createSidebarConfig } from './lib/vue-sidebar.js';
|
|
18
|
+
export { listFolder } from './lib/list-folder.js';
|
|
19
|
+
export { parseFile, writeContentToFile } from './lib/parser.js';
|
|
20
|
+
export { createSidebarConfig, generateVitepressSidebar, generateVueSidebar } from './lib/vue-sidebar.js';
|
|
21
|
+
export { parseComment, parseVuepressFileHeader } from './lib/comment-parser.js';
|
|
22
|
+
export { defineConfig, loadConfig } from './lib/config.js';
|
|
23
|
+
export { vuepressJsdocPlugin } from './lib/vuepress-plugin.js';
|
|
24
|
+
export { StatisticType } from './constants.js';
|
|
33
25
|
/**
|
|
34
|
-
*
|
|
35
|
-
* @param {
|
|
36
|
-
* @returns {
|
|
26
|
+
* Split a comma separated string or a list of strings into a list
|
|
27
|
+
* @param {string|string[]} value
|
|
28
|
+
* @returns {string[]}
|
|
37
29
|
*/
|
|
38
|
-
const
|
|
30
|
+
const toList = (value) => (Array.isArray(value) ? value : (value || '').split(','))
|
|
31
|
+
.flatMap((v) => v.split(','))
|
|
32
|
+
.map((v) => v.trim())
|
|
33
|
+
.filter(Boolean);
|
|
39
34
|
/**
|
|
40
|
-
* Parse
|
|
41
|
-
* @param {DirectoryFile} file
|
|
35
|
+
* Parse all CLI arguments
|
|
42
36
|
* @param {CLIArguments} argv
|
|
43
|
-
* @returns {
|
|
37
|
+
* @returns {object} all arguments
|
|
44
38
|
*/
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
export const parseArguments = (argv) => {
|
|
40
|
+
const codeFolder = normalizePath(argv.folder || 'code');
|
|
41
|
+
const dist = normalizePath(argv.dist || './documentation');
|
|
42
|
+
const srcFolder = normalizePath(argv.source || './src');
|
|
43
|
+
return {
|
|
44
|
+
include: toList(argv.include),
|
|
45
|
+
exclude: toList(argv.exclude),
|
|
46
|
+
srcFolder,
|
|
47
|
+
codeFolder,
|
|
48
|
+
docsFolder: path.posix.join(dist, codeFolder),
|
|
49
|
+
title: argv.title || 'API',
|
|
50
|
+
readme: argv.readme,
|
|
51
|
+
readmePath: argv.readme || path.join(srcFolder, 'README.md'),
|
|
52
|
+
rmPattern: toList(argv.rmPattern),
|
|
53
|
+
partials: toList(argv.partials),
|
|
54
|
+
jsDocConfigPath: argv.jsDocConfigPath,
|
|
55
|
+
collapsible: Boolean(argv.collapsible),
|
|
56
|
+
format: argv.format === 'vitepress' ? 'vitepress' : 'vuepress'
|
|
57
|
+
};
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* Run async tasks with a limited concurrency, because every jsdoc call spawns a child process.
|
|
61
|
+
* @param {T[]} items
|
|
62
|
+
* @param {Function} fn
|
|
63
|
+
* @returns {Promise<R[]>} results in the order of the items
|
|
64
|
+
*/
|
|
65
|
+
const mapLimit = async (items, fn, limit = os.availableParallelism()) => {
|
|
66
|
+
const results = new Array(items.length);
|
|
67
|
+
let index = 0;
|
|
68
|
+
const worker = async () => {
|
|
69
|
+
while (index < items.length) {
|
|
70
|
+
const i = index++;
|
|
71
|
+
results[i] = await fn(items[i]);
|
|
53
72
|
}
|
|
54
|
-
}
|
|
73
|
+
};
|
|
74
|
+
await Promise.all(Array.from({ length: Math.max(1, Math.min(limit, items.length)) }, worker));
|
|
75
|
+
return results;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* Get the sidebar options of the given file tree
|
|
79
|
+
* @param {Options} options
|
|
80
|
+
* @param {FileTree[]} fileTree created by `listFolder`
|
|
81
|
+
* @returns {SidebarOptions}
|
|
82
|
+
*/
|
|
83
|
+
export const getSidebarOptions = (options, fileTree) => ({
|
|
84
|
+
fileTree,
|
|
85
|
+
srcFolder: options.srcFolder,
|
|
86
|
+
docsFolder: options.docsFolder,
|
|
87
|
+
codeFolder: options.codeFolder,
|
|
88
|
+
title: options.title,
|
|
89
|
+
format: options.format,
|
|
90
|
+
collapsible: options.collapsible
|
|
91
|
+
});
|
|
92
|
+
/**
|
|
93
|
+
* Write the config.js with the file tree and sidebar
|
|
94
|
+
* @param {Options} options
|
|
95
|
+
* @param {FileTree[]} fileTree created by `listFolder`
|
|
96
|
+
* @returns {Promise<void>}
|
|
97
|
+
*/
|
|
98
|
+
const createVuepressSidebar = (options, fileTree) => fs.writeFile(path.join(options.docsFolder, 'config.js'), createSidebarConfig(getSidebarOptions(options, fileTree)));
|
|
99
|
+
/**
|
|
100
|
+
* Parse a file and write the markdown file
|
|
101
|
+
* @param {DirectoryFile} file
|
|
102
|
+
* @param {Options} options
|
|
103
|
+
* @returns {Promise<ParseReturn>}
|
|
104
|
+
*/
|
|
105
|
+
const processFile = async (file, options) => {
|
|
106
|
+
const parseOptions = {
|
|
107
|
+
srcFolder: options.srcFolder,
|
|
108
|
+
destFolder: options.docsFolder,
|
|
109
|
+
jsDocConfigPath: options.jsDocConfigPath,
|
|
110
|
+
partials: options.partials
|
|
111
|
+
};
|
|
112
|
+
const result = await parseFile(file, parseOptions);
|
|
113
|
+
await writeContentToFile(result);
|
|
114
|
+
return result;
|
|
55
115
|
};
|
|
56
116
|
/**
|
|
57
117
|
* Create the readme file. First page when entering the documentation.
|
|
58
|
-
* @param {
|
|
59
|
-
* @
|
|
60
|
-
* @returns {void}
|
|
118
|
+
* @param {Options} options
|
|
119
|
+
* @returns {Promise<void>}
|
|
61
120
|
*/
|
|
62
|
-
const createReadmeFile = (
|
|
63
|
-
const {
|
|
64
|
-
|
|
65
|
-
const
|
|
121
|
+
const createReadmeFile = async (options) => {
|
|
122
|
+
const { readmePath } = options;
|
|
123
|
+
// vitepress uses index.md as the page of a folder
|
|
124
|
+
const target = options.format === 'vitepress' ? 'index.md' : 'README.md';
|
|
125
|
+
let content = `# ${options.title}\n`;
|
|
66
126
|
try {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
console.log(`\n${kleur_1.default.white().bgBlack(' README ')} ${kleur_1.default.dim(readmePath.replace('README.md', ''))}${kleur_1.default.bold('README.md')} \u2192 ${kleur_1.default.dim(docsFolder)}${kleur_1.default.bold('/README.md')}`);
|
|
70
|
-
}
|
|
127
|
+
content = await fs.readFile(readmePath, 'utf-8');
|
|
128
|
+
console.log(`${kleur.white().bgBlack(' README ')} ${kleur.dim(readmePath)} → ${kleur.dim(options.docsFolder)}/${target}`);
|
|
71
129
|
}
|
|
72
|
-
catch
|
|
73
|
-
console.log(
|
|
130
|
+
catch {
|
|
131
|
+
console.log(`${kleur.white().bgBlack(' README ')} no README.md found, a default one was created`);
|
|
74
132
|
}
|
|
75
|
-
|
|
76
|
-
}
|
|
133
|
+
await fs.writeFile(path.join(options.docsFolder, target), content);
|
|
134
|
+
};
|
|
135
|
+
const STATUS_COLORS = {
|
|
136
|
+
[StatisticType.INCLUDE]: kleur.green,
|
|
137
|
+
[StatisticType.ERROR]: kleur.red,
|
|
138
|
+
[StatisticType.EMPTY]: kleur.yellow,
|
|
139
|
+
[StatisticType.EXCLUDE]: kleur.blue
|
|
140
|
+
};
|
|
77
141
|
/**
|
|
78
|
-
*
|
|
79
|
-
* @param {
|
|
80
|
-
* @
|
|
142
|
+
* Print a status line
|
|
143
|
+
* @param {StatisticType} type
|
|
144
|
+
* @param {string} message
|
|
81
145
|
*/
|
|
82
|
-
const
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
srcFolder: argv.source.replace('./', ''),
|
|
87
|
-
codeFolder: argv.folder,
|
|
88
|
-
docsFolder: `${argv.dist}/${argv.folder}`,
|
|
89
|
-
title: argv.title,
|
|
90
|
-
readme: argv.readme,
|
|
91
|
-
rmPattern: argv.rmPattern || [],
|
|
92
|
-
partials: argv.partials || []
|
|
93
|
-
};
|
|
146
|
+
const printStatus = (type, message) => {
|
|
147
|
+
console.log(STATUS_COLORS[type]()
|
|
148
|
+
.inverse()
|
|
149
|
+
.bold(` ${type.padEnd(7)} `), message);
|
|
94
150
|
};
|
|
95
151
|
/**
|
|
96
|
-
*
|
|
97
|
-
* @param {
|
|
152
|
+
* Print the result of a parsed file
|
|
153
|
+
* @param {ParseReturn} entry
|
|
98
154
|
*/
|
|
99
|
-
const
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
if (
|
|
110
|
-
|
|
111
|
-
node_readline_1.default.cursorTo(process.stdout, 0);
|
|
112
|
-
process.stdout.write(kleur_1.default.dim(` ${file.path} `));
|
|
113
|
-
yield new Promise((resolve) => setTimeout(resolve, 20));
|
|
155
|
+
const printResult = (entry) => {
|
|
156
|
+
const source = `${kleur.dim(entry.file.folder)}${kleur.bold(path.basename(entry.file.path))}`;
|
|
157
|
+
if (entry.type === StatisticType.INCLUDE) {
|
|
158
|
+
printStatus(entry.type, `${source} → ${kleur.dim(entry.dest + '/')}${kleur.bold(entry.file.name + '.md')}`);
|
|
159
|
+
}
|
|
160
|
+
else if (entry.type === StatisticType.EMPTY) {
|
|
161
|
+
printStatus(entry.type, `${source} ${kleur.dim('(no documentation found)')}`);
|
|
162
|
+
}
|
|
163
|
+
else {
|
|
164
|
+
printStatus(entry.type, source);
|
|
165
|
+
if (entry.error) {
|
|
166
|
+
console.log(kleur.red(entry.error.replace(/^/gm, ' ')));
|
|
114
167
|
}
|
|
115
168
|
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
169
|
+
};
|
|
170
|
+
/**
|
|
171
|
+
* Default command that generates the markdown files
|
|
172
|
+
* @param {CLIArguments} argv passed arguments
|
|
173
|
+
* @returns {Promise<ParseReturn[]>} results of all parsed files
|
|
174
|
+
*/
|
|
175
|
+
export const generate = async (argv) => {
|
|
176
|
+
const options = parseArguments(argv);
|
|
177
|
+
const startTime = performance.now();
|
|
178
|
+
// the generated folder is always recreated
|
|
179
|
+
await fs.rm(options.docsFolder, { recursive: true, force: true });
|
|
180
|
+
if (options.rmPattern.length) {
|
|
181
|
+
await deleteAsync(options.rmPattern);
|
|
126
182
|
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
result = result.filter(Boolean);
|
|
130
|
-
// write vuepress sidebar
|
|
131
|
-
yield createVuepressSidebar({
|
|
132
|
-
fileTree: lsFolder.tree,
|
|
133
|
-
srcFolder,
|
|
134
|
-
docsFolder,
|
|
135
|
-
codeFolder,
|
|
136
|
-
title
|
|
137
|
-
});
|
|
138
|
-
// print stats
|
|
183
|
+
await fs.mkdir(options.docsFolder, { recursive: true });
|
|
184
|
+
const lsFolder = await listFolder(options.srcFolder, options.exclude, options.include);
|
|
139
185
|
for (const file of lsFolder.excluded) {
|
|
140
|
-
|
|
186
|
+
printStatus(StatisticType.EXCLUDE, `${kleur.dim(file.folder)}${kleur.bold(path.basename(file.path))}`);
|
|
141
187
|
}
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
188
|
+
const results = await mapLimit(lsFolder.paths, async (file) => {
|
|
189
|
+
const result = await processFile(file, options);
|
|
190
|
+
printResult(result);
|
|
191
|
+
return result;
|
|
192
|
+
});
|
|
193
|
+
await Promise.all([createVuepressSidebar(options, lsFolder.tree), createReadmeFile(options)]);
|
|
194
|
+
const count = (type) => results.filter((r) => r.type === type).length;
|
|
195
|
+
const resultTime = ((performance.now() - startTime) / 1000).toFixed(2);
|
|
196
|
+
console.log(`\n${kleur.green(`${count(StatisticType.INCLUDE)} generated`)}, ${kleur.yellow(`${count(StatisticType.EMPTY)} empty`)}, ${kleur.red(`${count(StatisticType.ERROR)} failed`)}, ${kleur.blue(`${lsFolder.excluded.length} excluded`)}`);
|
|
197
|
+
console.log(`⏰ Time: ${resultTime}s`);
|
|
198
|
+
if (argv.watch) {
|
|
199
|
+
watchFiles(argv);
|
|
153
200
|
}
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
const resultTime = (Math.abs(startTime - +new Date()) / 1000).toFixed(2);
|
|
157
|
-
console.log(`\n⏰ Time: ${resultTime}s`);
|
|
158
|
-
(0, exports.watchFiles)(argv);
|
|
159
|
-
});
|
|
160
|
-
exports.generate = generate;
|
|
201
|
+
return results;
|
|
202
|
+
};
|
|
161
203
|
/**
|
|
162
|
-
* Watch files in source folder
|
|
204
|
+
* Watch files in source folder and update the generated markdown files
|
|
163
205
|
* @param {CLIArguments} argv
|
|
206
|
+
* @returns {object} chokidar watcher
|
|
164
207
|
*/
|
|
165
|
-
const watchFiles = (argv) => {
|
|
166
|
-
const
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
208
|
+
export const watchFiles = (argv) => {
|
|
209
|
+
const options = parseArguments(argv);
|
|
210
|
+
const readmePath = path.resolve(options.readmePath);
|
|
211
|
+
console.log('\n---\n\n👀 watching files...');
|
|
212
|
+
const watcher = chokidar.watch([options.srcFolder, options.readme].filter((p) => Boolean(p)), {
|
|
213
|
+
ignored: (p) => /(^|[/\\])\.[^/\\]/.test(p) || p.includes('node_modules'),
|
|
214
|
+
ignoreInitial: true
|
|
215
|
+
});
|
|
216
|
+
let queue = Promise.resolve();
|
|
217
|
+
const update = (event, changedPath) => {
|
|
218
|
+
queue = queue.then(async () => {
|
|
219
|
+
try {
|
|
220
|
+
if (path.resolve(changedPath) === readmePath) {
|
|
221
|
+
await createReadmeFile(options);
|
|
222
|
+
return;
|
|
223
|
+
}
|
|
224
|
+
const { paths, tree } = await listFolder(options.srcFolder, options.exclude, options.include);
|
|
225
|
+
const file = paths.find((p) => path.resolve(p.path) === path.resolve(changedPath));
|
|
226
|
+
if (event === 'unlink') {
|
|
227
|
+
const dir = normalizePath(path.dirname(changedPath));
|
|
228
|
+
const name = getPageName(dir, path.basename(changedPath, path.extname(changedPath)));
|
|
229
|
+
const dest = getDestFolder({ folder: dir }, options.srcFolder, options.docsFolder);
|
|
230
|
+
await fs.rm(path.join(dest, `${name}.md`), { force: true });
|
|
231
|
+
console.log(kleur.dim(`removed ${changedPath}`));
|
|
232
|
+
}
|
|
233
|
+
else if (file) {
|
|
234
|
+
printResult(await processFile(file, options));
|
|
235
|
+
}
|
|
236
|
+
await createVuepressSidebar(options, tree);
|
|
181
237
|
}
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
(_a = parseDirectoryFile(file, argv)) === null || _a === void 0 ? void 0 : _a.then((data) => {
|
|
185
|
-
if (data) {
|
|
186
|
-
(0, parser_1.writeContentToFile)(data, data.relativePathDest);
|
|
187
|
-
}
|
|
188
|
-
createVuepressSidebar({
|
|
189
|
-
fileTree: lsFolder.tree,
|
|
190
|
-
srcFolder,
|
|
191
|
-
docsFolder,
|
|
192
|
-
codeFolder,
|
|
193
|
-
title
|
|
194
|
-
});
|
|
195
|
-
});
|
|
238
|
+
catch (e) {
|
|
239
|
+
console.error(e);
|
|
196
240
|
}
|
|
197
|
-
})
|
|
198
|
-
}
|
|
241
|
+
});
|
|
242
|
+
};
|
|
243
|
+
watcher.on('all', (event, p) => {
|
|
244
|
+
if (event === 'add' || event === 'change' || event === 'unlink')
|
|
245
|
+
update(event, p);
|
|
246
|
+
});
|
|
247
|
+
return watcher;
|
|
199
248
|
};
|
|
200
|
-
exports.watchFiles = watchFiles;
|
package/dist/interfaces.d.ts
CHANGED
|
@@ -1,32 +1,58 @@
|
|
|
1
|
+
import { StatisticType } from './constants.js';
|
|
1
2
|
export interface DirectoryFile {
|
|
3
|
+
/** Path of the file relative to the working directory, e.g. `src/lib/foo.ts` */
|
|
2
4
|
path: string;
|
|
3
|
-
|
|
4
|
-
ext?: string;
|
|
5
|
+
/** Name of the generated page without extension. `index` files are prefixed with their folder. */
|
|
5
6
|
name: string;
|
|
6
|
-
|
|
7
|
+
/** File extension, e.g. `.ts` */
|
|
8
|
+
ext: string;
|
|
9
|
+
/** Folder of the file relative to the working directory with a trailing slash, e.g. `src/lib/` */
|
|
10
|
+
folder: string;
|
|
7
11
|
}
|
|
8
12
|
export interface CLIArguments {
|
|
9
|
-
include
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
13
|
+
/** Pattern to include files/folders (comma separated or list) */
|
|
14
|
+
include?: string | string[];
|
|
15
|
+
/** Pattern to exclude files/folders (comma separated or list) */
|
|
16
|
+
exclude?: string | string[];
|
|
17
|
+
/** jsdoc2markdown partial templates */
|
|
18
|
+
partials?: string[] | string;
|
|
19
|
+
/** Additional glob patterns of files to remove before generating */
|
|
20
|
+
rmPattern?: string[] | string;
|
|
21
|
+
/** Folder inside the destination folder, default `code` */
|
|
22
|
+
folder?: string;
|
|
23
|
+
/** Path to a jsdoc config */
|
|
24
|
+
jsDocConfigPath?: string;
|
|
25
|
+
/** Source folder, default `./src` */
|
|
26
|
+
source?: string;
|
|
27
|
+
/** Destination folder, default `./documentation` */
|
|
28
|
+
dist?: string;
|
|
29
|
+
/** Title of the documentation, default `API` */
|
|
30
|
+
title?: string;
|
|
31
|
+
/** Path to a custom readme */
|
|
32
|
+
readme?: string;
|
|
33
|
+
/** Watch the source files */
|
|
34
|
+
watch?: boolean;
|
|
35
|
+
/** Make the top level sidebar groups collapsible, default `false` */
|
|
36
|
+
collapsible?: boolean;
|
|
37
|
+
/** Sidebar format of the generated `config.js`, default `vuepress` */
|
|
38
|
+
format?: 'vuepress' | 'vitepress';
|
|
39
|
+
/** Path to a config file */
|
|
40
|
+
config?: string;
|
|
20
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* Options of a `vuepress-jsdoc.config.js` file
|
|
44
|
+
*/
|
|
45
|
+
export type UserConfig = Omit<CLIArguments, 'config'>;
|
|
21
46
|
export interface ParseReturn {
|
|
22
|
-
|
|
47
|
+
/** Result of parsing */
|
|
48
|
+
type: StatisticType;
|
|
49
|
+
/** Destination folder relative to the working directory */
|
|
23
50
|
dest: string;
|
|
24
51
|
file: DirectoryFile;
|
|
52
|
+
/** Rendered markdown (including the frontmatter) */
|
|
25
53
|
content: string;
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
relativePathSrc: string;
|
|
29
|
-
relativePathDest: string;
|
|
54
|
+
/** Error message, if the file could not be parsed */
|
|
55
|
+
error?: string;
|
|
30
56
|
}
|
|
31
57
|
export interface FileTree {
|
|
32
58
|
name: string;
|
package/dist/interfaces.js
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,17 +1,23 @@
|
|
|
1
|
-
import { DirectoryFile } from '../interfaces';
|
|
1
|
+
import { DirectoryFile } from '../interfaces.js';
|
|
2
|
+
interface ParsedComment {
|
|
3
|
+
/** raw frontmatter string */
|
|
4
|
+
frontmatter: string | null;
|
|
5
|
+
/** parsed frontmatter attributes */
|
|
6
|
+
attributes: Record<string, any> | null;
|
|
7
|
+
}
|
|
2
8
|
/**
|
|
3
|
-
* Search in file for
|
|
9
|
+
* Search in file for a `@vuepress` comment block and parse its frontmatter
|
|
4
10
|
* @param {string} fileContent content of given file
|
|
5
11
|
* @returns {object} object of found frontmatter data
|
|
6
12
|
*/
|
|
7
|
-
export declare const parseComment: (fileContent: string) =>
|
|
8
|
-
frontmatter: null;
|
|
9
|
-
attributes: null;
|
|
10
|
-
};
|
|
13
|
+
export declare const parseComment: (fileContent: string) => ParsedComment;
|
|
11
14
|
/**
|
|
12
|
-
* Helper function to get header as structured markdown
|
|
15
|
+
* Helper function to get the header of a page as structured markdown.
|
|
16
|
+
* It contains the frontmatter and a headline (`# headline`).
|
|
17
|
+
* The headline is omitted for vue files, because vue-docgen-cli renders its own.
|
|
13
18
|
* @param {string} content file content
|
|
14
|
-
* @param {
|
|
19
|
+
* @param {DirectoryFile} file file object
|
|
15
20
|
* @returns {string} markdown header
|
|
16
21
|
*/
|
|
17
|
-
export declare const parseVuepressFileHeader: (content: string, file: DirectoryFile) => string;
|
|
22
|
+
export declare const parseVuepressFileHeader: (content: string, file: Pick<DirectoryFile, 'name' | 'ext'>) => string;
|
|
23
|
+
export {};
|