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.
- package/README.md +175 -96
- package/bin/vuepress-jsdoc.js +7 -4
- package/dist/cmds.d.ts +4 -2
- package/dist/cmds.js +45 -18
- package/dist/constants.d.ts +16 -0
- package/dist/constants.js +18 -5
- package/dist/index.d.ts +46 -12
- package/dist/index.js +215 -358
- 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 +105 -191
- package/dist/lib/parser.d.ts +46 -30
- package/dist/lib/parser.js +205 -247
- package/dist/lib/vue-sidebar.d.ts +61 -18
- package/dist/lib/vue-sidebar.js +111 -68
- package/dist/lib/vuepress-plugin.d.ts +48 -0
- package/dist/lib/vuepress-plugin.js +63 -0
- package/package.json +68 -115
- package/CHANGELOG.md +0 -488
- package/dist/lib/utils.d.ts +0 -19
- package/dist/lib/utils.js +0 -43
package/README.md
CHANGED
|
@@ -4,96 +4,132 @@
|
|
|
4
4
|
[](https://www.npmjs.com/package/vuepress-jsdoc)
|
|
5
5
|
[](https://vuepress-jsdoc-example.vercel.app)
|
|
6
6
|
|
|
7
|
-
This npm package
|
|
7
|
+
This npm package serves as a command line script designed to analyze your JavaScript, Vue, or TypeScript source code. Leveraging [jsdoc-to-markdown](https://github.com/jsdoc2md/jsdoc-to-markdown) and [vue-docgen-cli](https://github.com/vue-styleguidist/vue-styleguidist/tree/dev/packages/vue-docgen-cli), it dynamically generates markdown files tailored for VuePress.
|
|
8
8
|
|
|
9
9
|

|
|
10
10
|
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Node.js `>= 22.22`
|
|
14
|
+
- VuePress 2 (use a version lower than `5.0.0` for VuePress 1)
|
|
15
|
+
|
|
11
16
|
## How to
|
|
12
17
|
|
|
13
18
|
```bash
|
|
14
|
-
|
|
15
|
-
|
|
19
|
+
npm i -D vuepress-jsdoc
|
|
20
|
+
# or
|
|
21
|
+
pnpm add -D vuepress-jsdoc
|
|
16
22
|
```
|
|
17
23
|
|
|
18
24
|
**Example:**
|
|
19
25
|
|
|
20
26
|
```bash
|
|
21
27
|
# search code in src and move it to code (./documentation/code) in your vuepress folder (./documentation)
|
|
22
|
-
vuepress-jsdoc --source ./src --dist ./documentation --folder code --title API --exclude="
|
|
28
|
+
vuepress-jsdoc --source ./src --dist ./documentation --folder code --title API --exclude="**/*.test.js"
|
|
23
29
|
```
|
|
24
30
|
|
|
25
|
-
You can also
|
|
31
|
+
You can also run it without installing via `pnpm dlx vuepress-jsdoc` or `npx vuepress-jsdoc`.
|
|
26
32
|
|
|
27
|
-
|
|
33
|
+
Every `.js`, `.jsx`, `.mjs`, `.cjs`, `.ts`, `.mts`, `.cts`, `.tsx` and `.vue` file is parsed. Files without any documentation are skipped, so they do not create empty pages. Files which can not be parsed are reported as `ERROR` with the reason and the command exits with code `1`.
|
|
28
34
|
|
|
29
|
-
|
|
30
|
-
This plugin watches you generated files.
|
|
35
|
+
#### Watch-Mode
|
|
31
36
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
plugins: [
|
|
35
|
-
[
|
|
36
|
-
require('vuepress-jsdoc').default,
|
|
37
|
-
{
|
|
38
|
-
folder: 'code',
|
|
39
|
-
source: './dist',
|
|
40
|
-
dist: './documentation',
|
|
41
|
-
title: 'API',
|
|
42
|
-
partials: ['./example/partials/*.hbs'],
|
|
43
|
-
readme: './README.md',
|
|
44
|
-
exclude: '**/*.d.ts,**/interfaces.*,**/constants.*,**/cmds.*'
|
|
45
|
-
}
|
|
46
|
-
]
|
|
47
|
-
];
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
#### Watch-Mode `alpha`
|
|
51
|
-
|
|
52
|
-
If you do not want to run`vuepress-jsdoc` again and again and again.
|
|
53
|
-
You can simply pass `--watch` or `-w`.
|
|
37
|
+
If you do not want to run `vuepress-jsdoc` again and again and again.
|
|
38
|
+
You can simply pass `--watch` or `-w`. Added, changed and removed files update the markdown files and the sidebar.
|
|
54
39
|
|
|
55
40
|
### Command-Options
|
|
56
41
|
|
|
57
42
|
Use these options after `vuepress-jsdoc`.
|
|
58
43
|
|
|
59
|
-
| Name | Alias | Default | Description
|
|
60
|
-
| ----------------- | ----- | --------------- |
|
|
61
|
-
| --source | -s | ./src | Source folder with .js or .
|
|
62
|
-
| --dist | -d | ./documentation | Destination folder
|
|
63
|
-
| --folder | -f |
|
|
64
|
-
| --title | -t | API | Title of your documentation
|
|
65
|
-
| --help | -h | | Show help
|
|
66
|
-
| --version | -
|
|
67
|
-
| --readme | -r | | Path to custom readme file
|
|
68
|
-
| --exclude | -e | | Pattern to exclude files/folders (
|
|
69
|
-
| --include | -
|
|
70
|
-
| --rmPattern |
|
|
71
|
-
| --partials | -p | | jsdoc2markdown partial templates (overwrites default ones)
|
|
72
|
-
| --jsDocConfigPath | -c | | Path to [JsDoc Config](
|
|
73
|
-
| --watch | -w | | Watch changes and update markdown files
|
|
44
|
+
| Name | Alias | Default | Description |
|
|
45
|
+
| ----------------- | ----- | --------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
46
|
+
| --source | -s | ./src | Source folder with .js, .ts or .vue files |
|
|
47
|
+
| --dist | -d | ./documentation | Destination folder |
|
|
48
|
+
| --folder | -f | code | Folder inside destination folder. Gets overwritten everytime |
|
|
49
|
+
| --title | -t | API | Title of your documentation |
|
|
50
|
+
| --help | -h | | Show help |
|
|
51
|
+
| --version | -V | | Show current version |
|
|
52
|
+
| --readme | -r | | Path to custom readme file |
|
|
53
|
+
| --exclude | -e | | Pattern to exclude files/folders (comma separated) - \*\*/\*.test.js,exclude.js [more information](https://github.com/micromatch/micromatch#ismatch) |
|
|
54
|
+
| --include | -i | | Pattern to include files/folders (comma separated) - \*\*/\*.js,include.js [more information](https://github.com/micromatch/micromatch#ismatch) |
|
|
55
|
+
| --rmPattern | --rm | | Additional glob patterns of files to remove before generating |
|
|
56
|
+
| --partials | -p | | jsdoc2markdown partial templates (overwrites default ones) |
|
|
57
|
+
| --jsDocConfigPath | -c | | Path to [JsDoc Config](https://jsdoc.app/about-configuring-jsdoc.html) |
|
|
58
|
+
| --watch | -w | | Watch changes and update markdown files |
|
|
59
|
+
| --collapsible | | | Make the top level sidebar groups collapsible (nested folders are always collapsible) |
|
|
60
|
+
| --format | | vuepress | Sidebar format of the generated `config.js`: `vuepress` or `vitepress` |
|
|
61
|
+
| --config | | | Path to a config file (default: `vuepress-jsdoc.config.{js,mjs,cjs,json}`) |
|
|
62
|
+
|
|
63
|
+
Patterns are matched relative to the source folder. Folders can be excluded as a whole, e.g. `--exclude="**/__tests__"`.
|
|
64
|
+
|
|
65
|
+
### Config file
|
|
66
|
+
|
|
67
|
+
Instead of command options, you can add a `vuepress-jsdoc.config.js` (or `.mjs`, `.cjs`, `.json`) to your project. It is loaded automatically, or use `--config ./path/to/config.js`. Command options win over the config file.
|
|
68
|
+
|
|
69
|
+
```javascript
|
|
70
|
+
// vuepress-jsdoc.config.js
|
|
71
|
+
import { defineConfig } from 'vuepress-jsdoc';
|
|
72
|
+
|
|
73
|
+
export default defineConfig({
|
|
74
|
+
source: './src',
|
|
75
|
+
dist: './documentation',
|
|
76
|
+
title: 'API',
|
|
77
|
+
exclude: ['**/__tests__', '**/*.test.js']
|
|
78
|
+
});
|
|
79
|
+
```
|
|
74
80
|
|
|
75
81
|
### config.js
|
|
76
82
|
|
|
77
|
-
Inside your generated folder, you can find a `config.js
|
|
78
|
-
|
|
83
|
+
Inside your generated folder, you can find a `config.js` (ES module).
|
|
84
|
+
It exports the complete `fileTree` and a `sidebarTree(title)` function, which returns a VuePress 2 sidebar. Every folder becomes a sidebar group.
|
|
85
|
+
|
|
86
|
+
## VuePress plugin
|
|
87
|
+
|
|
88
|
+
The easiest way: add the plugin to your VuePress config. It generates the documentation when VuePress starts, updates it during `vuepress dev` and adds the sidebar to all generated pages. No separate CLI call is needed.
|
|
89
|
+
|
|
90
|
+
```javascript
|
|
91
|
+
// documentation/.vuepress/config.js
|
|
92
|
+
import { viteBundler } from '@vuepress/bundler-vite';
|
|
93
|
+
import { defaultTheme } from '@vuepress/theme-default';
|
|
94
|
+
import { defineUserConfig } from 'vuepress';
|
|
95
|
+
import { vuepressJsdocPlugin } from 'vuepress-jsdoc';
|
|
96
|
+
|
|
97
|
+
export default defineUserConfig({
|
|
98
|
+
bundler: viteBundler(),
|
|
99
|
+
theme: defaultTheme({
|
|
100
|
+
navbar: [{ text: 'Code', link: '/code/' }]
|
|
101
|
+
}),
|
|
102
|
+
plugins: [
|
|
103
|
+
vuepressJsdocPlugin({
|
|
104
|
+
source: './src',
|
|
105
|
+
folder: 'code',
|
|
106
|
+
exclude: ['**/__tests__'],
|
|
107
|
+
// text of the readme link in the sidebar
|
|
108
|
+
sidebarTitle: 'Readme'
|
|
109
|
+
})
|
|
110
|
+
]
|
|
111
|
+
});
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
The plugin accepts the same options as the config file, except `dist` (the VuePress source folder is used), `watch` and `format`. Set `sidebar: false` if you configure the sidebar in your theme yourself. Paths are relative to the working directory.
|
|
79
115
|
|
|
80
116
|
## How to configure vuepress
|
|
81
117
|
|
|
82
|
-
[
|
|
118
|
+
[VuePress](https://vuepress.vuejs.org/) is a static site generator.
|
|
83
119
|
You can add all generated documentation files to your existing vuepress project or create a new one.
|
|
84
120
|
|
|
85
121
|
```bash
|
|
86
122
|
# First install vuepress
|
|
87
|
-
|
|
123
|
+
pnpm add -D vuepress@next @vuepress/bundler-vite@next @vuepress/theme-default@next sass-embedded
|
|
88
124
|
|
|
89
125
|
# Run the CLI
|
|
90
|
-
vuepress-jsdoc
|
|
126
|
+
pnpm exec vuepress-jsdoc
|
|
91
127
|
|
|
92
128
|
# Run vuepress dev server
|
|
93
|
-
vuepress dev ./documentation
|
|
129
|
+
pnpm exec vuepress dev ./documentation
|
|
94
130
|
|
|
95
131
|
# Run vuepress build, if you want to ship it
|
|
96
|
-
vuepress build ./documentation
|
|
132
|
+
pnpm exec vuepress build ./documentation
|
|
97
133
|
```
|
|
98
134
|
|
|
99
135
|
**Access it via:** [http://localhost:8080/code/](http://localhost:8080/code/)
|
|
@@ -104,45 +140,63 @@ Create a `.vuepress` folder inside the `documentation` folder and add the follow
|
|
|
104
140
|
**config.js:**
|
|
105
141
|
|
|
106
142
|
```javascript
|
|
143
|
+
import { viteBundler } from '@vuepress/bundler-vite';
|
|
144
|
+
import { defaultTheme } from '@vuepress/theme-default';
|
|
145
|
+
import { defineUserConfig } from 'vuepress';
|
|
146
|
+
|
|
107
147
|
// auto generated sidebar
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
148
|
+
import { sidebarTree } from '../code/config.js';
|
|
149
|
+
|
|
150
|
+
export default defineUserConfig({
|
|
151
|
+
bundler: viteBundler(),
|
|
152
|
+
title: 'vuepress-jsdoc',
|
|
153
|
+
description: 'Generate jsdoc markdown files for vuepress',
|
|
154
|
+
theme: defaultTheme({
|
|
155
|
+
navbar: [
|
|
156
|
+
{ text: 'Home', link: '/' },
|
|
157
|
+
{ text: 'Code', link: '/code/' }
|
|
158
|
+
],
|
|
159
|
+
// Add the generated sidebar
|
|
160
|
+
sidebar: {
|
|
161
|
+
...sidebarTree('Mainpage title')
|
|
116
162
|
}
|
|
117
|
-
}
|
|
163
|
+
})
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## VitePress
|
|
168
|
+
|
|
169
|
+
Use `--format vitepress` to generate a [VitePress](https://vitepress.dev/) sidebar. The readme is written to `index.md`, because VitePress uses it as the page of a folder.
|
|
170
|
+
|
|
171
|
+
The documentation of this project is a VitePress site generated this way, see [`documentation/.vitepress/config.mjs`](./documentation/.vitepress/config.mjs).
|
|
172
|
+
|
|
173
|
+
```bash
|
|
174
|
+
vuepress-jsdoc --source ./src --dist ./docs --folder code --format vitepress
|
|
175
|
+
```
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
// docs/.vitepress/config.mjs
|
|
179
|
+
import { defineConfig } from 'vitepress';
|
|
180
|
+
|
|
181
|
+
import { sidebarTree } from '../code/config.js';
|
|
182
|
+
|
|
183
|
+
export default defineConfig({
|
|
118
184
|
themeConfig: {
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
docsDir: 'code',
|
|
122
|
-
locales: {
|
|
123
|
-
'/': {
|
|
124
|
-
nav: [
|
|
125
|
-
{
|
|
126
|
-
text: 'Home',
|
|
127
|
-
link: '/'
|
|
128
|
-
}
|
|
129
|
-
],
|
|
130
|
-
// Add the generated sidebar
|
|
131
|
-
sidebar: Object.assign({}, sidebarTree('Mainpage title'))
|
|
132
|
-
}
|
|
133
|
-
}
|
|
185
|
+
nav: [{ text: 'Code', link: '/code/' }],
|
|
186
|
+
sidebar: sidebarTree('Overview')
|
|
134
187
|
}
|
|
135
|
-
};
|
|
188
|
+
});
|
|
136
189
|
```
|
|
137
190
|
|
|
138
191
|
## Custom readme
|
|
139
192
|
|
|
140
|
-
|
|
141
|
-
|
|
193
|
+
To include a custom path for your readme, simply utilize the `--readme ./path/to/file.md` parameter. If you relocate a `README.md` file into your source folder, the system will automatically resolve it.
|
|
194
|
+
|
|
195
|
+
For setting the title, provide it as an argument to the `sidebarTree('Mainpage title')` function within your `./.vuepress/config.js` file.
|
|
142
196
|
|
|
143
197
|
## @vuepress comment block
|
|
144
198
|
|
|
145
|
-
|
|
199
|
+
Enhance your page customization by incorporating custom metadata through the `@vuepress` block:
|
|
146
200
|
|
|
147
201
|
```javascript
|
|
148
202
|
/*
|
|
@@ -156,41 +210,66 @@ You can add custom meta data to your pages by using the `@vuepress` block:
|
|
|
156
210
|
|
|
157
211
|
Use `headline` to add a custom `h1` title.
|
|
158
212
|
|
|
159
|
-
[More information](https://vuepress.vuejs.org/guide/
|
|
213
|
+
[More information](https://vuepress.vuejs.org/guide/page.html#frontmatter)
|
|
160
214
|
|
|
161
215
|
## Typescript
|
|
162
216
|
|
|
163
|
-
|
|
217
|
+
TypeScript files work out of the box. The types are removed with the type stripping of Node.js before the file is passed to jsdoc, so all comments and line numbers stay intact.
|
|
218
|
+
|
|
219
|
+
Syntax which has to be transformed (`enum`, `namespace`, parameter properties) and `.tsx` files are transpiled with the TypeScript compiler of your project. `typescript` 6 or lower (or `@typescript/typescript6`) has to be installed for this, because `typescript` 7 has no JavaScript API.
|
|
220
|
+
|
|
221
|
+
If you need more control, use babel instead. Install the following dev-dependencies:
|
|
164
222
|
|
|
165
223
|
```bash
|
|
166
|
-
|
|
224
|
+
pnpm add -D jsdoc-babel @babel/core @babel/preset-env @babel/preset-typescript
|
|
167
225
|
```
|
|
168
226
|
|
|
169
|
-
|
|
170
|
-
You can find a full working example with all settings inside the `./example` folder.
|
|
171
|
-
The example shows also how to use babel-`plugins`.
|
|
227
|
+
After installation, include a `jsdoc.json` file in your project with specific settings, and reference it using the `-c` parameter. For a comprehensive example with all the necessary configurations, refer to the `./example` folder. The example also demonstrates the usage of Babel plugins.
|
|
172
228
|
|
|
173
229
|
## Example
|
|
174
230
|
|
|
175
|
-
The `./example` folder includes a full working vuepress-jsdoc example.
|
|
231
|
+
The `./example` folder includes a full working vuepress-jsdoc example. It is part of the pnpm workspace and uses the local build of `vuepress-jsdoc`.
|
|
176
232
|
|
|
177
233
|
```bash
|
|
178
|
-
# Install dependencies
|
|
179
|
-
|
|
234
|
+
# Install dependencies (from the repository root)
|
|
235
|
+
pnpm install
|
|
236
|
+
pnpm build
|
|
180
237
|
|
|
181
|
-
|
|
182
|
-
vuepress-jsdoc
|
|
238
|
+
cd example
|
|
183
239
|
|
|
184
240
|
# Generate docs
|
|
185
|
-
|
|
241
|
+
pnpm run docs
|
|
186
242
|
|
|
187
|
-
#
|
|
188
|
-
|
|
243
|
+
# Generate docs and run the dev server
|
|
244
|
+
pnpm run dev
|
|
189
245
|
|
|
190
|
-
# Generate dist folder
|
|
191
|
-
|
|
246
|
+
# Generate docs and build the dist folder
|
|
247
|
+
pnpm run build:local
|
|
192
248
|
```
|
|
193
249
|
|
|
250
|
+
## Migrating from 5.x
|
|
251
|
+
|
|
252
|
+
- Node.js `>= 22.22` is required.
|
|
253
|
+
- The generated `config.js` is an ES module. Import it with `import { sidebarTree } from '../code/config.js'`.
|
|
254
|
+
- VuePress 2 needs a bundler in your config: `bundler: viteBundler()` from `@vuepress/bundler-vite`.
|
|
255
|
+
- Sidebar groups use `collapsible` instead of `collapsable`.
|
|
256
|
+
- `--rmPattern` is also available as `--rm`. The generated folder is always recreated.
|
|
257
|
+
- Files without documentation no longer create empty pages.
|
|
258
|
+
|
|
194
259
|
## Contribute
|
|
195
260
|
|
|
196
261
|
PRs are always welcome (:
|
|
262
|
+
|
|
263
|
+
This project uses [pnpm](https://pnpm.io/).
|
|
264
|
+
|
|
265
|
+
```bash
|
|
266
|
+
pnpm install
|
|
267
|
+
pnpm test # vitest
|
|
268
|
+
pnpm lint # eslint (pnpm lint:fix to fix)
|
|
269
|
+
pnpm typecheck # tsc
|
|
270
|
+
pnpm build # compile to ./dist
|
|
271
|
+
pnpm run docs:dev # VitePress dev server for the documentation of this project
|
|
272
|
+
pnpm run docs:build # build it to ./public
|
|
273
|
+
```
|
|
274
|
+
|
|
275
|
+
Use `pnpm run docs` instead of `pnpm docs`, because `pnpm docs` is a builtin pnpm command.
|
package/bin/vuepress-jsdoc.js
CHANGED
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import { readFileSync } from 'node:fs';
|
|
3
|
+
|
|
4
|
+
import cli from '../dist/cmds.js';
|
|
5
|
+
|
|
6
|
+
const { version } = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf-8'));
|
|
7
|
+
|
|
8
|
+
cli(version);
|
package/dist/cmds.d.ts
CHANGED
|
@@ -3,6 +3,8 @@
|
|
|
3
3
|
* we need the version from the package.json here. We do not import
|
|
4
4
|
* this here, because otherwise the folder structure in the dist folder would get mixed up.
|
|
5
5
|
* @param {string} version a version string
|
|
6
|
+
* @param {string[]} argv process arguments
|
|
7
|
+
* @returns {Promise<void>}
|
|
6
8
|
*/
|
|
7
|
-
declare const
|
|
8
|
-
export default
|
|
9
|
+
export declare const cli: (version: string, argv?: string[]) => Promise<void>;
|
|
10
|
+
export default cli;
|
package/dist/cmds.js
CHANGED
|
@@ -1,34 +1,61 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
1
|
/*
|
|
4
2
|
* @vuepress
|
|
5
3
|
* ---
|
|
6
|
-
*
|
|
4
|
+
* title: CLI
|
|
5
|
+
* headline: Command line interface
|
|
7
6
|
* ---
|
|
8
7
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import { Command, Option } from 'commander';
|
|
9
|
+
import { generate } from './index.js';
|
|
10
|
+
import { loadConfig } from './lib/config.js';
|
|
11
|
+
import { StatisticType } from './constants.js';
|
|
11
12
|
/**
|
|
12
13
|
* This method builds the cli interface and is necessary because
|
|
13
14
|
* we need the version from the package.json here. We do not import
|
|
14
15
|
* this here, because otherwise the folder structure in the dist folder would get mixed up.
|
|
15
16
|
* @param {string} version a version string
|
|
17
|
+
* @param {string[]} argv process arguments
|
|
18
|
+
* @returns {Promise<void>}
|
|
16
19
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
.
|
|
21
|
-
.
|
|
20
|
+
export const cli = async (version, argv = process.argv) => {
|
|
21
|
+
const program = new Command();
|
|
22
|
+
program
|
|
23
|
+
.name('vuepress-jsdoc')
|
|
24
|
+
.version(version)
|
|
25
|
+
.description('Generate markdown files for VuePress out of your JSDoc comments')
|
|
26
|
+
.option('-s, --source <string>', 'Source folder with .js, .ts or .vue files', './src')
|
|
22
27
|
.option('-d, --dist <string>', 'Destination folder', './documentation')
|
|
23
28
|
.option('-f, --folder <string>', 'Folder inside destination folder. Gets overwritten everytime', 'code')
|
|
24
29
|
.option('-t, --title <string>', 'Title of your documentation', 'API')
|
|
25
30
|
.option('-r, --readme <string>', 'Path to your custom readme')
|
|
26
|
-
.option('-i, --include <string>', 'Pattern to include files/folders (
|
|
27
|
-
.option('-e, --exclude <string>', 'Pattern to exclude files/folders (
|
|
28
|
-
.option('-w, --watch', '
|
|
29
|
-
.option('
|
|
30
|
-
.option('
|
|
31
|
+
.option('-i, --include <string>', 'Pattern to include files/folders (comma separated) - **/*.js,include.js')
|
|
32
|
+
.option('-e, --exclude <string>', 'Pattern to exclude files/folders (comma separated) - **/*.test.js,exclude.js')
|
|
33
|
+
.option('-w, --watch', 'Watch your source files and update the documentation')
|
|
34
|
+
.option('--collapsible', 'Make the top level sidebar groups collapsible')
|
|
35
|
+
.option('--rm, --rmPattern [files...]', 'Additional glob patterns of files to remove before generating')
|
|
36
|
+
.option('-p, --partials [files...]', 'jsdoc2markdown partial templates (overwrites default ones)')
|
|
31
37
|
.option('-c, --jsDocConfigPath <string>', 'Path to jsdoc config')
|
|
32
|
-
.
|
|
33
|
-
|
|
34
|
-
|
|
38
|
+
.addOption(new Option('--format <format>', 'Sidebar format of the generated config.js')
|
|
39
|
+
.choices(['vuepress', 'vitepress'])
|
|
40
|
+
.default('vuepress'))
|
|
41
|
+
.option('--config <path>', 'Path to a config file (default: vuepress-jsdoc.config.{js,mjs,cjs,json})')
|
|
42
|
+
.action(async (cliOptions) => {
|
|
43
|
+
const loaded = await loadConfig(cliOptions.config);
|
|
44
|
+
const options = { ...cliOptions };
|
|
45
|
+
if (loaded) {
|
|
46
|
+
console.log(`Using config ${loaded.path}`);
|
|
47
|
+
// options of the command line win over the config file, the config file wins over the defaults
|
|
48
|
+
for (const [key, value] of Object.entries(loaded.config)) {
|
|
49
|
+
if (program.getOptionValueSource(key) !== 'cli') {
|
|
50
|
+
options[key] = value;
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
const results = await generate(options);
|
|
55
|
+
if (!options.watch && results.some((r) => r.type === StatisticType.ERROR)) {
|
|
56
|
+
process.exitCode = 1;
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
await program.parseAsync(argv);
|
|
60
|
+
};
|
|
61
|
+
export default cli;
|
package/dist/constants.d.ts
CHANGED
|
@@ -4,3 +4,19 @@ export declare enum StatisticType {
|
|
|
4
4
|
INCLUDE = "INCLUDE",
|
|
5
5
|
EXCLUDE = "EXCLUDE"
|
|
6
6
|
}
|
|
7
|
+
/**
|
|
8
|
+
* File extensions which are parsed with jsdoc-to-markdown
|
|
9
|
+
*/
|
|
10
|
+
export declare const SCRIPT_EXTENSIONS: string[];
|
|
11
|
+
/**
|
|
12
|
+
* File extensions which are parsed with vue-docgen-cli
|
|
13
|
+
*/
|
|
14
|
+
export declare const VUE_EXTENSIONS: string[];
|
|
15
|
+
/**
|
|
16
|
+
* TypeScript extensions. These need their types stripped before jsdoc can read them.
|
|
17
|
+
*/
|
|
18
|
+
export declare const TYPESCRIPT_EXTENSIONS: string[];
|
|
19
|
+
/**
|
|
20
|
+
* Placeholder inside the generated sidebar, which gets replaced with the title passed to `sidebarTree(title)`
|
|
21
|
+
*/
|
|
22
|
+
export declare const SIDEBAR_TITLE_PLACEHOLDER = "::vuepress-jsdoc-title::";
|
package/dist/constants.js
CHANGED
|
@@ -1,10 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.StatisticType = void 0;
|
|
4
|
-
var StatisticType;
|
|
1
|
+
export var StatisticType;
|
|
5
2
|
(function (StatisticType) {
|
|
6
3
|
StatisticType["EMPTY"] = "EMPTY";
|
|
7
4
|
StatisticType["ERROR"] = "ERROR";
|
|
8
5
|
StatisticType["INCLUDE"] = "INCLUDE";
|
|
9
6
|
StatisticType["EXCLUDE"] = "EXCLUDE";
|
|
10
|
-
})(StatisticType
|
|
7
|
+
})(StatisticType || (StatisticType = {}));
|
|
8
|
+
/**
|
|
9
|
+
* File extensions which are parsed with jsdoc-to-markdown
|
|
10
|
+
*/
|
|
11
|
+
export const SCRIPT_EXTENSIONS = ['.js', '.jsx', '.mjs', '.cjs', '.ts', '.tsx', '.mts', '.cts'];
|
|
12
|
+
/**
|
|
13
|
+
* File extensions which are parsed with vue-docgen-cli
|
|
14
|
+
*/
|
|
15
|
+
export const VUE_EXTENSIONS = ['.vue'];
|
|
16
|
+
/**
|
|
17
|
+
* TypeScript extensions. These need their types stripped before jsdoc can read them.
|
|
18
|
+
*/
|
|
19
|
+
export const TYPESCRIPT_EXTENSIONS = ['.ts', '.tsx', '.mts', '.cts'];
|
|
20
|
+
/**
|
|
21
|
+
* Placeholder inside the generated sidebar, which gets replaced with the title passed to `sidebarTree(title)`
|
|
22
|
+
*/
|
|
23
|
+
export const SIDEBAR_TITLE_PLACEHOLDER = '::vuepress-jsdoc-title::';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,17 +1,51 @@
|
|
|
1
|
-
import { CLIArguments } from './interfaces';
|
|
1
|
+
import { CLIArguments, ParseReturn } from './interfaces.js';
|
|
2
|
+
import { FileTree } from './interfaces.js';
|
|
3
|
+
import { SidebarOptions } from './lib/vue-sidebar.js';
|
|
4
|
+
export { listFolder } from './lib/list-folder.js';
|
|
5
|
+
export { parseFile, writeContentToFile } from './lib/parser.js';
|
|
6
|
+
export { createSidebarConfig, generateVitepressSidebar, generateVueSidebar } from './lib/vue-sidebar.js';
|
|
7
|
+
export { parseComment, parseVuepressFileHeader } from './lib/comment-parser.js';
|
|
8
|
+
export { defineConfig, loadConfig } from './lib/config.js';
|
|
9
|
+
export { vuepressJsdocPlugin } from './lib/vuepress-plugin.js';
|
|
10
|
+
export { StatisticType } from './constants.js';
|
|
11
|
+
export type { CLIArguments, DirectoryFile, FileTree, ParseReturn, UserConfig } from './interfaces.js';
|
|
2
12
|
/**
|
|
3
|
-
*
|
|
4
|
-
* @param {
|
|
13
|
+
* Parse all CLI arguments
|
|
14
|
+
* @param {CLIArguments} argv
|
|
15
|
+
* @returns {object} all arguments
|
|
16
|
+
*/
|
|
17
|
+
export declare const parseArguments: (argv: CLIArguments) => {
|
|
18
|
+
include: string[];
|
|
19
|
+
exclude: string[];
|
|
20
|
+
srcFolder: string;
|
|
21
|
+
codeFolder: string;
|
|
22
|
+
docsFolder: string;
|
|
23
|
+
title: string;
|
|
24
|
+
readme: string | undefined;
|
|
25
|
+
readmePath: string;
|
|
26
|
+
rmPattern: string[];
|
|
27
|
+
partials: string[];
|
|
28
|
+
jsDocConfigPath: string | undefined;
|
|
29
|
+
collapsible: boolean;
|
|
30
|
+
format: "vitepress" | "vuepress";
|
|
31
|
+
};
|
|
32
|
+
export type Options = ReturnType<typeof parseArguments>;
|
|
33
|
+
/**
|
|
34
|
+
* Get the sidebar options of the given file tree
|
|
35
|
+
* @param {Options} options
|
|
36
|
+
* @param {FileTree[]} fileTree created by `listFolder`
|
|
37
|
+
* @returns {SidebarOptions}
|
|
5
38
|
*/
|
|
6
|
-
export declare const
|
|
39
|
+
export declare const getSidebarOptions: (options: Options, fileTree: FileTree[]) => SidebarOptions;
|
|
7
40
|
/**
|
|
8
|
-
*
|
|
41
|
+
* Default command that generates the markdown files
|
|
42
|
+
* @param {CLIArguments} argv passed arguments
|
|
43
|
+
* @returns {Promise<ParseReturn[]>} results of all parsed files
|
|
44
|
+
*/
|
|
45
|
+
export declare const generate: (argv: CLIArguments) => Promise<ParseReturn[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Watch files in source folder and update the generated markdown files
|
|
9
48
|
* @param {CLIArguments} argv
|
|
10
|
-
* @
|
|
11
|
-
* @returns {object}
|
|
49
|
+
* @returns {object} chokidar watcher
|
|
12
50
|
*/
|
|
13
|
-
declare const
|
|
14
|
-
name: string;
|
|
15
|
-
ready: () => Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
export default plugin;
|
|
51
|
+
export declare const watchFiles: (argv: CLIArguments) => import("chokidar").FSWatcher;
|