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.
@@ -0,0 +1,48 @@
1
+ import { CLIArguments } from '../interfaces.js';
2
+ export interface VuepressJsdocPluginOptions extends Omit<CLIArguments, 'dist' | 'watch' | 'format' | 'config'> {
3
+ /**
4
+ * Add the generated sidebar to all generated pages (frontmatter `sidebar`).
5
+ * Disable it, if you configure the sidebar in your theme.
6
+ * @default true
7
+ */
8
+ sidebar?: boolean;
9
+ /**
10
+ * Text of the first sidebar entry, which links to the readme
11
+ * @default 'Readme'
12
+ */
13
+ sidebarTitle?: string;
14
+ }
15
+ /** Minimal parts of the vuepress app, which are used by the plugin */
16
+ interface App {
17
+ dir: {
18
+ source: (...args: string[]) => string;
19
+ };
20
+ env: {
21
+ isDev: boolean;
22
+ };
23
+ }
24
+ interface Page {
25
+ path: string;
26
+ frontmatter: Record<string, unknown>;
27
+ }
28
+ /**
29
+ * VuePress 2 plugin, which generates the documentation when vuepress starts and
30
+ * updates it while `vuepress dev` is running. No separate CLI call is needed.
31
+ * @example
32
+ * import { vuepressJsdocPlugin } from 'vuepress-jsdoc';
33
+ *
34
+ * export default defineUserConfig({
35
+ * plugins: [vuepressJsdocPlugin({ source: './src', folder: 'code' })]
36
+ * });
37
+ * @param {VuepressJsdocPluginOptions} pluginOptions
38
+ * @returns {Function} vuepress plugin
39
+ */
40
+ export declare const vuepressJsdocPlugin: ({ sidebar, sidebarTitle, ...pluginOptions }?: VuepressJsdocPluginOptions) => (app: App) => {
41
+ name: string;
42
+ extendsMarkdownOptions: () => Promise<void>;
43
+ extendsPage: (page: Page) => Promise<void>;
44
+ onWatched: (_app: App, watchers: {
45
+ close: () => Promise<void> | void;
46
+ }[]) => void;
47
+ };
48
+ export {};
@@ -0,0 +1,63 @@
1
+ /*
2
+ * @vuepress
3
+ * ---
4
+ * headline: lib/vuepress-plugin.ts
5
+ * ---
6
+ */
7
+ import path from 'node:path';
8
+ import { generate, getSidebarOptions, parseArguments, watchFiles } from '../index.js';
9
+ import { listFolder } from './list-folder.js';
10
+ import { generateVueSidebar, getSidebarBase } from './vue-sidebar.js';
11
+ /**
12
+ * VuePress 2 plugin, which generates the documentation when vuepress starts and
13
+ * updates it while `vuepress dev` is running. No separate CLI call is needed.
14
+ * @example
15
+ * import { vuepressJsdocPlugin } from 'vuepress-jsdoc';
16
+ *
17
+ * export default defineUserConfig({
18
+ * plugins: [vuepressJsdocPlugin({ source: './src', folder: 'code' })]
19
+ * });
20
+ * @param {VuepressJsdocPluginOptions} pluginOptions
21
+ * @returns {Function} vuepress plugin
22
+ */
23
+ export const vuepressJsdocPlugin = ({ sidebar = true, sidebarTitle = 'Readme', ...pluginOptions } = {}) => (app) => {
24
+ // generated files are written into the source folder of vuepress
25
+ const argv = {
26
+ ...pluginOptions,
27
+ dist: path.relative(process.cwd(), app.dir.source()) || '.',
28
+ format: 'vuepress',
29
+ watch: false
30
+ };
31
+ const options = parseArguments(argv);
32
+ const base = getSidebarBase(options.codeFolder);
33
+ let generated = null;
34
+ // the promise is cached, because all pages are extended at the same time
35
+ let sidebarCache = null;
36
+ const buildSidebar = async () => {
37
+ const { tree } = await listFolder(options.srcFolder, options.exclude, options.include);
38
+ return generateVueSidebar({ ...getSidebarOptions(options, tree), readmeTitle: sidebarTitle });
39
+ };
40
+ return {
41
+ name: 'vuepress-plugin-jsdoc',
42
+ // this hook runs before the pages are resolved, so the generated files become pages
43
+ extendsMarkdownOptions: async () => {
44
+ generated ??= generate(argv);
45
+ await generated;
46
+ },
47
+ extendsPage: async (page) => {
48
+ if (!sidebar || !page.path.startsWith(base) || page.frontmatter.sidebar !== undefined)
49
+ return;
50
+ sidebarCache ??= buildSidebar();
51
+ page.frontmatter.sidebar = await sidebarCache;
52
+ },
53
+ onWatched: (_app, watchers) => {
54
+ const watcher = watchFiles(argv);
55
+ // changed files can create or remove a page, which changes the sidebar
56
+ watcher.on('all', (event) => {
57
+ if (event !== 'addDir')
58
+ sidebarCache = null;
59
+ });
60
+ watchers.push(watcher);
61
+ }
62
+ };
63
+ };
package/package.json CHANGED
@@ -1,21 +1,16 @@
1
1
  {
2
2
  "name": "vuepress-jsdoc",
3
- "version": "5.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "Generate jsdoc markdown files for vuepress",
5
+ "type": "module",
5
6
  "main": "dist/index.js",
6
- "scripts": {
7
- "test": "jest",
8
- "test-coverage": "cross-env NODE_ENV=test jest --coverage",
9
- "test-watch": "cross-env NODE_ENV=test jest --watchAll",
10
- "lint": "eslint --ext .tsx,.ts,.json,.js src/ --fix",
11
- "dev": "npm run build -- -w",
12
- "build": "tsc",
13
- "prepublishOnly": "npm i && npm run build",
14
- "prepare": "husky install",
15
- "version": "conventional-changelog -p karma -i CHANGELOG.md -s -r 0 && git add .",
16
- "docs": "./bin/vuepress-jsdoc.js --source=./dist --partials=./example/partials/*.hbs --readme ./README.md --include=\"**/*.(ts|js)\" --exclude=\"**/*.d.ts,**/interfaces.*,**/constants.*\"",
17
- "docs:dev": "npx concurrently --kill-others \"npm run dev\" \"npm run docs -- -w\" \"vuepress dev documentation\"",
18
- "docs:build": "npm run build && npm run docs && vuepress build documentation"
7
+ "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "default": "./dist/index.js"
12
+ },
13
+ "./package.json": "./package.json"
19
14
  },
20
15
  "keywords": [
21
16
  "jsdoc",
@@ -25,7 +20,7 @@
25
20
  "vuepress"
26
21
  ],
27
22
  "engines": {
28
- "node": ">=14"
23
+ "node": ">=22.22.0"
29
24
  },
30
25
  "license": "MIT",
31
26
  "author": "Philip Stapelfeldt <me@ph1p.dev>",
@@ -40,118 +35,74 @@
40
35
  "printWidth": 120,
41
36
  "trailingComma": "none"
42
37
  },
43
- "jest": {
44
- "coverageThreshold": {
45
- "global": {
46
- "branches": 95,
47
- "functions": 60,
48
- "lines": 75,
49
- "statements": -10
50
- }
51
- },
52
- "roots": [
53
- "<rootDir>/src"
54
- ],
55
- "transform": {
56
- "^.+\\.tsx?$": "ts-jest"
57
- },
58
- "testRegex": "(/__tests__/.*|(\\.|/)(test|spec))\\.tsx?$",
59
- "moduleFileExtensions": [
60
- "ts",
61
- "tsx",
62
- "js",
63
- "jsx",
64
- "json",
65
- "node"
66
- ],
67
- "bail": true,
68
- "verbose": true,
69
- "collectCoverageFrom": [
70
- "**/*.{js,jsx,ts,tsx}",
71
- "!**/node_modules/**",
72
- "!**/coverage/**",
73
- "!**/example/**",
74
- "!**/vendor/**"
75
- ],
76
- "coverageDirectory": "./coverage"
77
- },
38
+ "files": [
39
+ "bin",
40
+ "dist",
41
+ "template"
42
+ ],
78
43
  "bin": {
79
44
  "vuepress-jsdoc": "bin/vuepress-jsdoc.js"
80
45
  },
81
46
  "dependencies": {
82
- "chokidar": "^3.5.3",
83
- "commander": "^11.1.0",
84
- "del": "^6.0.0",
47
+ "chokidar": "^6.0.0",
48
+ "commander": "^15.1.0",
49
+ "del": "^9.0.1",
85
50
  "front-matter": "^4.0.2",
86
- "jsdoc-to-markdown": "^8.0.0",
51
+ "jsdoc-to-markdown": "^9.1.3",
87
52
  "kleur": "^4.1.5",
88
- "micromatch": "^4.0.5",
89
- "mkdirp": "^3.0.1",
90
- "vue-docgen-cli": "^4.67.0"
53
+ "micromatch": "^4.0.8",
54
+ "vue-docgen-cli": "^4.79.0"
55
+ },
56
+ "peerDependencies": {
57
+ "typescript": "*"
58
+ },
59
+ "peerDependenciesMeta": {
60
+ "typescript": {
61
+ "optional": true
62
+ }
91
63
  },
92
64
  "devDependencies": {
93
- "@types/jest": "^29.5.10",
65
+ "@eslint/js": "^10.0.1",
94
66
  "@types/jsdoc-to-markdown": "^7.0.6",
95
- "@types/micromatch": "^4.0.6",
96
- "@types/mkdirp": "^1.0.2",
97
- "@typescript-eslint/eslint-plugin": "^6.12.0",
98
- "@typescript-eslint/parser": "^6.12.0",
99
- "@vuepress/client": "^2.0.0-rc.0",
100
- "babel-jest": "^29.7.0",
101
- "cross-env": "^7.0.3",
102
- "eslint": "^8.54.0",
103
- "eslint-config-prettier": "^9.0.0",
104
- "eslint-plugin-import": "^2.29.0",
105
- "eslint-plugin-jest": "^27.6.0",
106
- "eslint-plugin-prefer-arrow": "^1.2.3",
107
- "husky": "^8.0.3",
108
- "jest": "^29.7.0",
109
- "lint-staged": "^15.1.0",
110
- "memfs": "^4.6.0",
111
- "ts-jest": "^29.1.1",
112
- "typescript": "^5.3.2",
113
- "vue": "^3.3.8",
114
- "vuepress": "^2.0.0-rc.0"
67
+ "@types/micromatch": "^4.0.10",
68
+ "@types/node": "^26.6.6",
69
+ "@typescript/native": "npm:typescript@^7.0.2",
70
+ "@vitest/coverage-v8": "^5.1.0",
71
+ "conventional-changelog": "^8.1.3",
72
+ "conventional-changelog-conventionalcommits": "^10.4.1",
73
+ "eslint": "^10.14.0",
74
+ "eslint-config-prettier": "^10.1.8",
75
+ "globals": "^17.14.0",
76
+ "husky": "^9.1.7",
77
+ "lint-staged": "^17.6.0",
78
+ "memfs": "^4.80.0",
79
+ "prettier": "^3.9.10",
80
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
81
+ "typescript-eslint": "^8.72.1",
82
+ "vitepress": "^1.6.4",
83
+ "vitest": "^5.1.0"
115
84
  },
116
85
  "lint-staged": {
117
- "src/**/*.{css,scss,json}": [
118
- "prettier --write",
119
- "git add"
86
+ "src/**/*.{js,ts}": [
87
+ "eslint --fix",
88
+ "prettier --write"
120
89
  ],
121
- "src/**/*.{js,jsx,ts,tsx}": [
122
- "eslint",
123
- "prettier --write",
124
- "git add"
90
+ "src/**/*.json": [
91
+ "prettier --write"
125
92
  ]
126
93
  },
127
- "eslintConfig": {
128
- "env": {
129
- "commonjs": true,
130
- "es6": true,
131
- "node": true,
132
- "jest": true
133
- },
134
- "extends": "eslint:recommended",
135
- "globals": {
136
- "Atomics": "readonly",
137
- "SharedArrayBuffer": "readonly"
138
- },
139
- "parserOptions": {
140
- "ecmaVersion": 2018
141
- },
142
- "rules": {
143
- "quotes": [
144
- "error",
145
- "single",
146
- {
147
- "allowTemplateLiterals": true
148
- }
149
- ],
150
- "no-console": 0,
151
- "arrow-parens": [
152
- "error",
153
- "as-needed"
154
- ]
155
- }
94
+ "scripts": {
95
+ "test": "vitest run",
96
+ "test-coverage": "vitest run --coverage",
97
+ "test-watch": "vitest",
98
+ "typecheck": "tsc -p tsconfig.test.json",
99
+ "lint": "eslint src",
100
+ "lint:fix": "eslint src --fix",
101
+ "dev": "tsc -w",
102
+ "build": "node -e \"fs.rmSync('dist',{recursive:true,force:true})\" && tsc",
103
+ "version": "conventional-changelog -p conventionalcommits -i CHANGELOG.md -s && git add CHANGELOG.md",
104
+ "docs": "./bin/vuepress-jsdoc.js --source=./src --partials=./example/partials/*.hbs --readme=./README.md --format=vitepress --exclude=\"**/__tests__/**\"",
105
+ "docs:dev": "pnpm run build && pnpm run docs && vitepress dev documentation",
106
+ "docs:build": "pnpm run build && pnpm run docs && vitepress build documentation"
156
107
  }
157
- }
108
+ }