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/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
- const chokidar_1 = __importDefault(require("chokidar"));
24
- const del_1 = __importDefault(require("del"));
25
- const kleur_1 = __importDefault(require("kleur"));
26
- const mkdirp_1 = require("mkdirp");
27
- const promises_1 = __importDefault(require("node:fs/promises"));
28
- const node_readline_1 = __importDefault(require("node:readline"));
29
- const constants_1 = require("./constants");
30
- const list_folder_1 = require("./lib/list-folder");
31
- const parser_1 = require("./lib/parser");
32
- const vue_sidebar_1 = require("./lib/vue-sidebar");
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
- * Create the sidebar
35
- * @param {object} options
36
- * @returns {Promise}
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 createVuepressSidebar = (options) => promises_1.default.writeFile(`${options.docsFolder}/config.js`, `exports.fileTree=${JSON.stringify(options.fileTree)};exports.sidebarTree = (title = 'Mainpage') => (${JSON.stringify((0, vue_sidebar_1.generateVueSidebar)(options)).replace('::vuepress-jsdoc-title::', '"+title+"')});`);
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 file
41
- * @param {DirectoryFile} file
35
+ * Parse all CLI arguments
42
36
  * @param {CLIArguments} argv
43
- * @returns {Promise}
37
+ * @returns {object} all arguments
44
38
  */
45
- const parseDirectoryFile = (file, argv) => {
46
- const { srcFolder, docsFolder, partials } = parseArguments(argv);
47
- if (!file.isDir && file.folder) {
48
- if (['.jsx', '.tsx', '.ts', '.js'].includes(file.ext || '')) {
49
- return (0, parser_1.parseFile)(file, srcFolder, docsFolder, argv.jsDocConfigPath, partials);
50
- }
51
- if (file.ext === '.vue') {
52
- return (0, parser_1.parseVueFile)(file, srcFolder, docsFolder);
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 {CLIArguments} argv
59
- * @param {string} deletedPaths
60
- * @returns {void}
118
+ * @param {Options} options
119
+ * @returns {Promise<void>}
61
120
  */
62
- const createReadmeFile = (argv, deletedPaths) => __awaiter(void 0, void 0, void 0, function* () {
63
- const { srcFolder, codeFolder, docsFolder, title, readme } = parseArguments(argv);
64
- let readMeContent = `### Welcome to ${title}`;
65
- const readmePath = readme || `${srcFolder}/README.md`;
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
- readMeContent = yield promises_1.default.readFile(readmePath, 'utf-8');
68
- if (deletedPaths === null || deletedPaths === void 0 ? void 0 : deletedPaths.some((p) => p.indexOf(`${codeFolder}/README.md`) !== -1)) {
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 (e) {
73
- console.log(`\n${kleur_1.default.white().bgBlack(' README ')} Add default README.md`);
130
+ catch {
131
+ console.log(`${kleur.white().bgBlack(' README ')} no README.md found, a default one was created`);
74
132
  }
75
- yield promises_1.default.writeFile(`${docsFolder}/README.md`, readMeContent);
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
- * Parse all CLI arguments
79
- * @param {CLIArguments} argv
80
- * @returns {object} all arguments
142
+ * Print a status line
143
+ * @param {StatisticType} type
144
+ * @param {string} message
81
145
  */
82
- const parseArguments = (argv) => {
83
- return {
84
- include: (argv.include || '').split(',').filter(Boolean),
85
- exclude: (argv.exclude || '').split(',').filter(Boolean),
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
- * Default command that generate md files
97
- * @param {object} argv passed arguments
152
+ * Print the result of a parsed file
153
+ * @param {ParseReturn} entry
98
154
  */
99
- const generate = (argv) => __awaiter(void 0, void 0, void 0, function* () {
100
- const { exclude, include, srcFolder, codeFolder, docsFolder, title, rmPattern } = parseArguments(argv);
101
- const startTime = +new Date();
102
- // remove docs folder, except README.md
103
- const deletedPaths = yield (0, del_1.default)([`${docsFolder}/**/*`, ...rmPattern]);
104
- const lsFolder = yield (0, list_folder_1.listFolder)(srcFolder, exclude, include);
105
- yield (0, mkdirp_1.mkdirp)(docsFolder);
106
- const parsePromises = [];
107
- // print out all files
108
- for (const file of lsFolder.paths) {
109
- if (!file.isDir) {
110
- node_readline_1.default.clearLine(process.stdout, 0);
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
- node_readline_1.default.clearLine(process.stdout, 0);
117
- node_readline_1.default.cursorTo(process.stdout, 0);
118
- // iterate through files and parse them
119
- for (const file of lsFolder.paths) {
120
- parsePromises.push((() => __awaiter(void 0, void 0, void 0, function* () {
121
- const data = yield parseDirectoryFile(file, argv);
122
- if (data && (data === null || data === void 0 ? void 0 : data.relativePathDest)) {
123
- return (0, parser_1.writeContentToFile)(data, data.relativePathDest);
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
- // wait unitl all files resolved
128
- let result = yield Promise.all(parsePromises);
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
- console.log(kleur_1.default.reset().inverse().bold().blue(' EXCLUDE '), `${kleur_1.default.dim(file.folder)}${kleur_1.default.bold(file.name + file.ext)}`);
186
+ printStatus(StatisticType.EXCLUDE, `${kleur.dim(file.folder)}${kleur.bold(path.basename(file.path))}`);
141
187
  }
142
- console.log();
143
- for (const entry of result.flat()) {
144
- if (!entry.file)
145
- continue;
146
- const color = {
147
- [constants_1.StatisticType.INCLUDE]: kleur_1.default.reset().inverse().bold().green,
148
- [constants_1.StatisticType.ERROR]: kleur_1.default.reset().inverse().bold().red,
149
- [constants_1.StatisticType.EMPTY]: kleur_1.default.reset().inverse().bold().yellow,
150
- [constants_1.StatisticType.EXCLUDE]: kleur_1.default.reset().inverse().bold().blue
151
- }[entry.type];
152
- console.log(color(` ${entry.type} `), `${kleur_1.default.dim(entry.relativePathSrc)}${kleur_1.default.bold(entry.file.name + entry.file.ext)} \u2192 ${kleur_1.default.dim(entry.relativePathDest)}${kleur_1.default.bold(entry.file.name + '.md')}`);
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
- // create README.md
155
- yield createReadmeFile(argv, deletedPaths);
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 { exclude, include, srcFolder, codeFolder, docsFolder, title } = parseArguments(argv);
167
- if (argv.watch) {
168
- console.log('\n---\n\n👀 watching files...');
169
- const watcher = chokidar_1.default.watch([srcFolder, argv.readme, `${srcFolder}/README.md`].filter(Boolean), {
170
- ignored: /(^|[\/\\])\../,
171
- persistent: true
172
- });
173
- watcher.on('change', (path) => __awaiter(void 0, void 0, void 0, function* () {
174
- var _a;
175
- const lsFolder = yield (0, list_folder_1.listFolder)(srcFolder, exclude, include);
176
- const file = lsFolder.paths.find((p) => p.path === path);
177
- node_readline_1.default.clearLine(process.stdout, 0);
178
- node_readline_1.default.cursorTo(process.stdout, 0);
179
- if (path === 'README.md' || path === `${srcFolder}/README.md`) {
180
- yield createReadmeFile(argv);
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
- if (file) {
183
- process.stdout.write(kleur_1.default.dim(`update ${file.name + file.ext}`));
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;
@@ -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
- isDir: boolean;
4
- ext?: string;
5
+ /** Name of the generated page without extension. `index` files are prefixed with their folder. */
5
6
  name: string;
6
- folder?: string;
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: string;
10
- exclude: string;
11
- partials: string[];
12
- rmPattern: string[];
13
- folder: string;
14
- jsDocConfigPath: string;
15
- source: string;
16
- dist: string;
17
- title: string;
18
- readme: string;
19
- watch: boolean;
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
- success: boolean;
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
- empty: boolean;
27
- excluded?: boolean;
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;
@@ -1,2 +1 @@
1
- "use strict";
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 @vuepress comment
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) => import("front-matter").FrontMatterResult<Record<string, 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 {object} file file object
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 {};