vuepress-jsdoc 4.3.1 → 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.
@@ -1,265 +1,223 @@
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
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
- return new (P || (P = Promise))(function (resolve, reject) {
16
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
- step((generator = generator.apply(thisArg, _arguments || [])).next());
20
- });
21
- };
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 };
1
+ /*
2
+ * @vuepress
3
+ * ---
4
+ * headline: lib/parser.ts
5
+ * ---
6
+ */
7
+ import jsdoc2md from 'jsdoc-to-markdown';
8
+ import fs from 'node:fs/promises';
9
+ import nodeModule, { createRequire } from 'node:module';
10
+ import path from 'node:path';
11
+ import { fileURLToPath } from 'node:url';
12
+ import { StatisticType, TYPESCRIPT_EXTENSIONS, VUE_EXTENSIONS } from '../constants.js';
13
+ import { parseVuepressFileHeader } from './comment-parser.js';
14
+ const require = createRequire(import.meta.url);
15
+ const TEMPLATE_FOLDER = fileURLToPath(new URL('../../template/', import.meta.url));
16
+ /**
17
+ * Get the folder of the generated markdown file
18
+ * @param {DirectoryFile} file
19
+ * @param {string} srcFolder
20
+ * @param {string} destFolder
21
+ * @returns {string} destination folder
22
+ */
23
+ export const getDestFolder = (file, srcFolder, destFolder) => path.join(destFolder, path.relative(path.resolve(srcFolder), path.resolve(file.folder)));
24
+ /**
25
+ * Get a readable error message
26
+ * @param {unknown} error
27
+ * @returns {string}
28
+ */
29
+ const getErrorMessage = (error) => (error instanceof Error ? error.message : String(error)).split('\n').filter(Boolean).slice(0, 3).join('\n');
30
+ /**
31
+ * Remove TypeScript types from source code, so jsdoc is able to parse it.
32
+ * Types are replaced with whitespace, so all comments and line numbers stay intact.
33
+ * @param {string} code TypeScript code
34
+ * @returns {string} JavaScript code
35
+ */
36
+ export const stripTypes = (code) => {
37
+ const { stripTypeScriptTypes } = nodeModule;
38
+ if (typeof stripTypeScriptTypes !== 'function') {
39
+ throw new Error('TypeScript files need Node.js >= 22.13 or a jsdoc config (--jsDocConfigPath)');
47
40
  }
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;
41
+ // stripTypeScriptTypes is still experimental and would print a warning
42
+ const emitWarning = process.emitWarning;
43
+ process.emitWarning = () => { };
53
44
  try {
54
- while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
45
+ return stripTypeScriptTypes(code, { mode: 'strip' });
46
+ }
47
+ catch (e) {
48
+ throw new Error(getErrorMessage(e), { cause: e });
55
49
  }
56
- catch (error) { e = { error: error }; }
57
50
  finally {
58
- try {
59
- if (r && !r.done && (m = i["return"])) m.call(i);
60
- }
61
- finally { if (e) throw e.error; }
51
+ process.emitWarning = emitWarning;
62
52
  }
63
- return ar;
64
53
  };
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];
54
+ /**
55
+ * Load the TypeScript compiler API. The project of the user is preferred over the bundled one.
56
+ * `typescript` >= 7 has no JavaScript API anymore, so `@typescript/typescript6` is tried as well.
57
+ * The result is cached, because it is used for every TypeScript file.
58
+ * @returns {TypeScriptApi | null} TypeScript module or null if it is not installed
59
+ */
60
+ let typescript;
61
+ const loadTypeScript = () => {
62
+ if (typescript !== undefined)
63
+ return typescript;
64
+ const requires = [createRequire(path.join(process.cwd(), 'package.json')), require];
65
+ for (const req of requires) {
66
+ for (const name of ['typescript', '@typescript/typescript6']) {
67
+ try {
68
+ const ts = req(name);
69
+ if (typeof ts?.transpileModule === 'function')
70
+ return (typescript = ts);
71
+ }
72
+ catch {
73
+ // try the next one
74
+ }
70
75
  }
71
76
  }
72
- return to.concat(ar || Array.prototype.slice.call(from));
77
+ return (typescript = null);
73
78
  };
74
- var __importDefault = (this && this.__importDefault) || function (mod) {
75
- return (mod && mod.__esModule) ? mod : { "default": mod };
76
- };
77
- Object.defineProperty(exports, "__esModule", { value: true });
78
- exports.writeContentToFile = exports.parseVueFile = exports.parseFile = void 0;
79
- /*
80
- * @vuepress
81
- * ---
82
- * headline: lib/parser.ts
83
- * ---
79
+ /**
80
+ * Transpile TypeScript with the TypeScript compiler. Comments and JSX are preserved.
81
+ * This supports syntax that type stripping can not handle: `enum`, `namespace`, parameter properties and JSX.
82
+ * @param {string} code TypeScript code
83
+ * @param {string} fileName used to detect `.tsx`
84
+ * @returns {string | null} JavaScript code or null if TypeScript is not installed
84
85
  */
85
- var promises_1 = __importDefault(require("fs/promises"));
86
- var jsdoc_to_markdown_1 = __importDefault(require("jsdoc-to-markdown"));
87
- var mkdirp_1 = __importDefault(require("mkdirp"));
88
- var path_1 = require("path");
89
- var compileTemplates_1 = __importDefault(require("vue-docgen-cli/lib/compileTemplates"));
90
- var docgen_1 = require("vue-docgen-cli/lib/docgen");
91
- var constants_1 = require("../constants");
92
- var comment_parser_1 = require("./comment-parser");
86
+ const transpileTypes = (code, fileName) => {
87
+ const ts = loadTypeScript();
88
+ if (!ts)
89
+ return null;
90
+ return ts.transpileModule(code, {
91
+ fileName,
92
+ reportDiagnostics: false,
93
+ compilerOptions: {
94
+ target: ts.ScriptTarget.ESNext,
95
+ module: ts.ModuleKind.ESNext,
96
+ jsx: ts.JsxEmit.Preserve,
97
+ removeComments: false,
98
+ verbatimModuleSyntax: false,
99
+ isolatedModules: true
100
+ }
101
+ }).outputText;
102
+ };
93
103
  /**
94
- * Parse a typescript or javascript file
95
- * @param file {DirectoryFile}
96
- * @param srcFolder {string}
97
- * @param destFolder {string}
98
- * @param configPath {string}
99
- * @param partials {string | string[]}
100
- * @returns {object} file data
104
+ * Convert TypeScript to JavaScript. Type stripping of Node.js is used first, because it keeps all line numbers.
105
+ * If the file contains syntax which needs a transformation, the TypeScript compiler is used.
106
+ * @param {string} code TypeScript code
107
+ * @param {string} fileName
108
+ * @returns {string} JavaScript code
101
109
  */
102
- var parseFile = function (file, srcFolder, destFolder, configPath, partials) { return __awaiter(void 0, void 0, void 0, function () {
103
- var root, relativePathDest, folderInDest, folderInSrc, success, empty, excluded, fileContent, content, fileName, _a, e_1;
104
- return __generator(this, function (_b) {
105
- switch (_b.label) {
106
- case 0:
107
- if (!file.folder)
108
- return [2 /*return*/, null];
109
- root = process.cwd();
110
- relativePathDest = (0, path_1.join)(destFolder, file.folder.replace(srcFolder, ''));
111
- folderInDest = (0, path_1.join)(root, relativePathDest);
112
- folderInSrc = (0, path_1.join)(root, file.folder);
113
- success = true;
114
- empty = false;
115
- excluded = false;
116
- fileContent = '';
117
- _b.label = 1;
118
- case 1:
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
- }];
110
+ export const typescriptToJavaScript = (code, fileName) => {
111
+ let reason = 'JSX can not be stripped';
112
+ if (!fileName.endsWith('.tsx')) {
113
+ try {
114
+ return stripTypes(code);
162
115
  }
163
- });
164
- }); };
165
- exports.parseFile = parseFile;
116
+ catch (e) {
117
+ reason = getErrorMessage(e);
118
+ }
119
+ }
120
+ const transpiled = transpileTypes(code, fileName);
121
+ if (transpiled !== null)
122
+ return transpiled;
123
+ throw new Error(`${reason}\nInstall typescript or use a jsdoc config with babel (--jsDocConfigPath) for this file.`);
124
+ };
125
+ /**
126
+ * Escape vue interpolations (`{{ }}`) outside of code, because VuePress compiles every page as a vue template.
127
+ * @param {string} markdown
128
+ * @returns {string} escaped markdown
129
+ */
130
+ export const escapeVueInterpolation = (markdown) => markdown
131
+ // split by fenced code blocks, <code> and <pre> tags and inline code
132
+ .split(/(```[\s\S]*?```|<pre[\s\S]*?<\/pre>|<code>[\s\S]*?<\/code>|`[^`\n]*`)/)
133
+ // odd parts are code, which is kept. Inside <code> tags vue still interpolates.
134
+ .map((part, i) => i % 2 === 1 && !part.startsWith('<code>')
135
+ ? part
136
+ : part.replace(/\{\{/g, '&#123;&#123;').replace(/\}\}/g, '&#125;&#125;'))
137
+ .join('');
166
138
  /**
167
- * Parse a vue file
139
+ * Render a javascript or typescript file with jsdoc-to-markdown
168
140
  * @param {DirectoryFile} file
169
- * @param {string} srcFolder
170
- * @param {string} destFolder
171
- * @returns {object} file data
141
+ * @param {ParseOptions} options
142
+ * @param {string} source content of the file
143
+ * @returns {Promise<string>} markdown
172
144
  */
173
- var parseVueFile = function (file, srcFolder, destFolder) { return __awaiter(void 0, void 0, void 0, function () {
174
- var root, relativePathDest, folderInDest, folderInSrc, config, success, empty, fileContent, fileName, data, _a, e_2;
175
- return __generator(this, function (_b) {
176
- switch (_b.label) {
177
- case 0:
178
- if (!file.folder)
179
- return [2 /*return*/, null];
180
- root = process.cwd();
181
- relativePathDest = (0, path_1.join)(destFolder, file.folder.replace(srcFolder, ''));
182
- folderInDest = (0, path_1.join)(root, relativePathDest);
183
- folderInSrc = (0, path_1.join)(root, file.folder);
184
- config = __assign(__assign({}, (0, docgen_1.extractConfig)((0, path_1.join)(root, file.folder))), { components: file.name + file.ext });
185
- success = true;
186
- empty = false;
187
- fileContent = '';
188
- _b.label = 1;
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
- }];
223
- }
224
- });
225
- }); };
226
- exports.parseVueFile = parseVueFile;
145
+ const renderScript = async (file, options, source) => {
146
+ const absolutePath = path.resolve(file.path);
147
+ const jsdocOptions = {
148
+ partial: [
149
+ path.join(TEMPLATE_FOLDER, 'header.hbs'),
150
+ path.join(TEMPLATE_FOLDER, 'main.hbs'),
151
+ ...(options.partials || [])
152
+ ]
153
+ };
154
+ if (options.jsDocConfigPath) {
155
+ // the user config takes care of the file (e.g. typescript via jsdoc-babel)
156
+ jsdocOptions.files = [absolutePath];
157
+ jsdocOptions.configure = path.resolve(options.jsDocConfigPath);
158
+ jsdocOptions['no-cache'] = true;
159
+ }
160
+ else if (TYPESCRIPT_EXTENSIONS.includes(file.ext)) {
161
+ jsdocOptions.source = typescriptToJavaScript(source, file.path);
162
+ }
163
+ else {
164
+ jsdocOptions.files = [absolutePath];
165
+ }
166
+ return jsdoc2md.render(jsdocOptions);
167
+ };
227
168
  /**
228
- * Write content on disk
229
- * @param {ParseReturn | null} parseData
230
- * @param {string} dest
231
- * @returns {Promise | null} null or type with some data of the saved file
169
+ * Render a vue file with vue-docgen-cli
170
+ * @param {DirectoryFile} file
171
+ * @returns {Promise<string>} markdown
232
172
  */
233
- var writeContentToFile = function (parseData, dest) { return __awaiter(void 0, void 0, void 0, function () {
234
- var root, type, path, _a;
235
- return __generator(this, function (_b) {
236
- switch (_b.label) {
237
- case 0:
238
- root = process.cwd();
239
- dest = (0, path_1.join)(root, dest);
240
- type = constants_1.StatisticType.ERROR;
241
- if (parseData === null || parseData === void 0 ? void 0 : parseData.excluded) {
242
- type = constants_1.StatisticType.EXCLUDE;
243
- }
244
- _b.label = 1;
245
- case 1:
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];
262
- }
263
- });
264
- }); };
265
- exports.writeContentToFile = writeContentToFile;
173
+ const renderVue = async (file) => {
174
+ const { default: compileTemplates } = require('vue-docgen-cli/lib/compileTemplates');
175
+ const { extractConfig } = require('vue-docgen-cli/lib/docgen');
176
+ const fileName = path.basename(file.path);
177
+ const config = await extractConfig(path.resolve(file.folder));
178
+ const { content } = await compileTemplates('add', path.join(config.componentsRoot, fileName), config, fileName);
179
+ return content;
180
+ };
181
+ /**
182
+ * Parse a javascript, typescript or vue file and create the markdown content
183
+ * @param {DirectoryFile} file
184
+ * @param {ParseOptions} options
185
+ * @returns {Promise<ParseReturn>} file data
186
+ */
187
+ export const parseFile = async (file, options) => {
188
+ const dest = getDestFolder(file, options.srcFolder, options.destFolder);
189
+ const empty = { type: StatisticType.EMPTY, file, dest, content: '' };
190
+ try {
191
+ const source = await fs.readFile(file.path, 'utf-8');
192
+ const isVue = VUE_EXTENSIONS.includes(file.ext);
193
+ const content = isVue ? await renderVue(file) : await renderScript(file, options, source);
194
+ if (!content?.trim())
195
+ return empty;
196
+ return {
197
+ type: StatisticType.INCLUDE,
198
+ file,
199
+ dest,
200
+ content: parseVuepressFileHeader(source, file) + escapeVueInterpolation(content.trim()) + '\n'
201
+ };
202
+ }
203
+ catch (e) {
204
+ const error = getErrorMessage(e);
205
+ // the file is excluded by the jsdoc config (source.excludePattern)
206
+ if (/no input files to process/i.test(error))
207
+ return empty;
208
+ return { ...empty, type: StatisticType.ERROR, error };
209
+ }
210
+ };
211
+ /**
212
+ * Write the parsed content to disk. Files without content are skipped.
213
+ * @param {ParseReturn} parseData
214
+ * @returns {Promise<string | null>} path of the written file or null
215
+ */
216
+ export const writeContentToFile = async (parseData) => {
217
+ if (parseData.type !== StatisticType.INCLUDE || !parseData.content)
218
+ return null;
219
+ const filePath = path.join(parseData.dest, `${parseData.file.name}.md`);
220
+ await fs.mkdir(parseData.dest, { recursive: true });
221
+ await fs.writeFile(filePath, parseData.content, 'utf-8');
222
+ return filePath;
223
+ };
@@ -1,23 +1,66 @@
1
- /**
2
- * Runs through the given tree structure and creates a vuepress config
3
- * @param {object} data Informations to build config
4
- * @param {array} data.fileTree tree strcture
5
- * @param {string} data.codeFolder ./code/ folder
6
- * @param {string} data.srcFolder ./src/ folder
7
- * @param {string} data.docsFolder ./documentation/ folder
8
- * @param {string} data.title title string
9
- * @returns {object} returns the vuepress menu strcture
10
- */
11
- export declare const generateVueSidebar: ({ fileTree, codeFolder, srcFolder, docsFolder, title }: {
12
- fileTree: any;
1
+ import { FileTree } from '../interfaces.js';
2
+ export interface SidebarGroup {
3
+ text: string;
4
+ collapsible: boolean;
5
+ children: SidebarItem[];
6
+ }
7
+ export type SidebarItem = string | {
8
+ text: string;
9
+ link: string;
10
+ } | SidebarGroup;
11
+ export interface SidebarOptions {
12
+ /** tree structure, created by `listFolder` */
13
+ fileTree: FileTree[];
14
+ /** name of the folder inside the vuepress folder, e.g. `code` */
13
15
  codeFolder: string;
16
+ /** source folder, e.g. `src` */
14
17
  srcFolder: string;
18
+ /** folder of the generated markdown files, e.g. `documentation/code` */
15
19
  docsFolder: string;
20
+ /** title of the first sidebar group */
16
21
  title: string;
17
- }) => {
18
- [x: string]: {
19
- title: string;
20
- collapsable: boolean;
21
- children: string[][];
22
- }[];
22
+ /** sidebar format of the generated `config.js` */
23
+ format?: SiteFormat;
24
+ /** text of the first entry, which links to the readme */
25
+ readmeTitle?: string;
26
+ /** make the top level groups collapsible. Nested folders are always collapsible. */
27
+ collapsible?: boolean;
28
+ }
29
+ export type SiteFormat = 'vuepress' | 'vitepress';
30
+ /**
31
+ * Get the route of the generated folder, e.g. `/code/`
32
+ * @param {string} codeFolder
33
+ * @returns {string}
34
+ */
35
+ export declare const getSidebarBase: (codeFolder: string) => string;
36
+ export interface VitepressSidebarItem {
37
+ text: string;
38
+ link?: string;
39
+ collapsed?: boolean;
40
+ items?: VitepressSidebarItem[];
41
+ }
42
+ /**
43
+ * Runs through the given tree structure and creates a vuepress 2 sidebar config.
44
+ * Only pages that were generated are linked. Folders become nested sidebar groups.
45
+ * @param {SidebarOptions} data Information to build config
46
+ * @returns {object} returns the vuepress sidebar structure
47
+ */
48
+ export declare const generateVueSidebar: ({ fileTree, codeFolder, srcFolder, docsFolder, title, readmeTitle, collapsible }: SidebarOptions) => {
49
+ [x: string]: SidebarGroup[];
23
50
  };
51
+ /**
52
+ * Runs through the given tree structure and creates a vitepress sidebar config.
53
+ * Vitepress needs the text of every link, so it is read from the generated page.
54
+ * @param {SidebarOptions} data Information to build config
55
+ * @returns {object} returns the vitepress sidebar structure
56
+ */
57
+ export declare const generateVitepressSidebar: (data: SidebarOptions) => {
58
+ [x: string]: VitepressSidebarItem[];
59
+ };
60
+ /**
61
+ * Create the content of the `config.js`, which is placed into the generated folder.
62
+ * It exports the file tree and a `sidebarTree(title)` function, which returns the vuepress or vitepress sidebar.
63
+ * @param {SidebarOptions} options
64
+ * @returns {string} javascript code (ES module)
65
+ */
66
+ export declare const createSidebarConfig: (options: SidebarOptions) => string;