vuepress-jsdoc 4.3.1 ā 5.0.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/CHANGELOG.md +20 -1
- package/README.md +11 -31
- package/dist/cmds.js +4 -4
- package/dist/constants.js +1 -1
- package/dist/index.d.ts +2 -8
- package/dist/index.js +117 -308
- package/dist/lib/comment-parser.js +12 -12
- package/dist/lib/index.d.ts +6 -0
- package/dist/lib/index.js +16 -0
- package/dist/lib/list-folder.js +54 -170
- package/dist/lib/parser.js +116 -216
- package/dist/lib/utils.js +4 -6
- package/dist/lib/vue-sidebar.d.ts +8 -5
- package/dist/lib/vue-sidebar.js +27 -50
- package/package.json +27 -25
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,25 @@
|
|
|
1
|
+
## 5.0.0 (2023-11-23)
|
|
2
|
+
|
|
3
|
+
* feat(vuepress): switch to vuepress 2 ([351af08](https://github.com/ph1p/vuepress-jsdoc/commit/351af08))
|
|
4
|
+
* build(deps): update dependencies ([2e85188](https://github.com/ph1p/vuepress-jsdoc/commit/2e85188))
|
|
5
|
+
* build(deps): update example ([c9529fe](https://github.com/ph1p/vuepress-jsdoc/commit/c9529fe))
|
|
6
|
+
* build(workflow): set node 16 in github action ([4822a0a](https://github.com/ph1p/vuepress-jsdoc/commit/4822a0a))
|
|
7
|
+
* Make sidebar config compatible with Vuepress 2 ([592a7b5](https://github.com/ph1p/vuepress-jsdoc/commit/592a7b5))
|
|
8
|
+
* Wait for async `extractConfig()` call to complete ([6ddb19f](https://github.com/ph1p/vuepress-jsdoc/commit/6ddb19f))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### BREAKING CHANGE
|
|
12
|
+
|
|
13
|
+
* no vuepress 1 support anymore, drop older node versions
|
|
14
|
+
|
|
15
|
+
Switch from chalk to kleur
|
|
16
|
+
Fix some bugs
|
|
17
|
+
|
|
18
|
+
|
|
1
19
|
## <small>4.3.1 (2022-10-06)</small>
|
|
2
20
|
|
|
3
|
-
*
|
|
21
|
+
* 4.3.1 ([8b596fb](https://github.com/ph1p/vuepress-jsdoc/commit/8b596fb))
|
|
22
|
+
* build(deps): update dependencies and fix an npm script ([82a5b93](https://github.com/ph1p/vuepress-jsdoc/commit/82a5b93))
|
|
4
23
|
* build(deps): update dependencies and rename success to include ([dd5b6c4](https://github.com/ph1p/vuepress-jsdoc/commit/dd5b6c4))
|
|
5
24
|
* chore: audit example dependencies ([21823a1](https://github.com/ph1p/vuepress-jsdoc/commit/21823a1))
|
|
6
25
|
* chore: drop node 14 ([ae30caf](https://github.com/ph1p/vuepress-jsdoc/commit/ae30caf))
|
package/README.md
CHANGED
|
@@ -4,10 +4,14 @@
|
|
|
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
|
+
## Vuepress support
|
|
12
|
+
|
|
13
|
+
This npm package is compatible with VuePress 2; however, it requires a version lower than `5.0.0` for proper functionality with VuePress 1.
|
|
14
|
+
|
|
11
15
|
## How to
|
|
12
16
|
|
|
13
17
|
```bash
|
|
@@ -24,29 +28,6 @@ vuepress-jsdoc --source ./src --dist ./documentation --folder code --title API -
|
|
|
24
28
|
|
|
25
29
|
You can also use `npx vuepress-jsdoc`, if you want.
|
|
26
30
|
|
|
27
|
-
#### Plugin (Dev-Mode) `alpha`
|
|
28
|
-
|
|
29
|
-
You can use `vuepress-jsdoc` also as plugin.
|
|
30
|
-
This plugin watches you generated files.
|
|
31
|
-
|
|
32
|
-
```javascript
|
|
33
|
-
// ./documentation/.vuepress/config.js
|
|
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
31
|
#### Watch-Mode `alpha`
|
|
51
32
|
|
|
52
33
|
If you do not want to run`vuepress-jsdoc` again and again and again.
|
|
@@ -137,12 +118,13 @@ module.exports = {
|
|
|
137
118
|
|
|
138
119
|
## Custom readme
|
|
139
120
|
|
|
140
|
-
|
|
141
|
-
|
|
121
|
+
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.
|
|
122
|
+
|
|
123
|
+
For setting the title, provide it as an argument to the `sidebarTree('Mainpage title')` function within your `./.vuepress/config.js` file.
|
|
142
124
|
|
|
143
125
|
## @vuepress comment block
|
|
144
126
|
|
|
145
|
-
|
|
127
|
+
Enhance your page customization by incorporating custom metadata through the `@vuepress` block:
|
|
146
128
|
|
|
147
129
|
```javascript
|
|
148
130
|
/*
|
|
@@ -160,15 +142,13 @@ Use `headline` to add a custom `h1` title.
|
|
|
160
142
|
|
|
161
143
|
## Typescript
|
|
162
144
|
|
|
163
|
-
To
|
|
145
|
+
To integrate TypeScript support, install the following dev-dependencies with the following command:
|
|
164
146
|
|
|
165
147
|
```bash
|
|
166
148
|
npm install -D typescript jsdoc-babel @babel/cli @babel/core @babel/preset-env @babel/preset-typescript jsdoc-to-markdown
|
|
167
149
|
```
|
|
168
150
|
|
|
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`.
|
|
151
|
+
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
152
|
|
|
173
153
|
## Example
|
|
174
154
|
|
package/dist/cmds.js
CHANGED
|
@@ -6,15 +6,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
* headline: cmds.ts
|
|
7
7
|
* ---
|
|
8
8
|
*/
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
const commander_1 = require("commander");
|
|
10
|
+
const _1 = require(".");
|
|
11
11
|
/**
|
|
12
12
|
* This method builds the cli interface and is necessary because
|
|
13
13
|
* we need the version from the package.json here. We do not import
|
|
14
14
|
* this here, because otherwise the folder structure in the dist folder would get mixed up.
|
|
15
15
|
* @param {string} version a version string
|
|
16
16
|
*/
|
|
17
|
-
exports.default = (
|
|
17
|
+
exports.default = (version) => {
|
|
18
18
|
commander_1.program.version(version).description('a CLI Tool to generate markdown files for vuepress');
|
|
19
19
|
commander_1.program
|
|
20
20
|
.description('Generate the md files')
|
|
@@ -31,4 +31,4 @@ exports.default = (function (version) {
|
|
|
31
31
|
.option('-c, --jsDocConfigPath <string>', 'Path to jsdoc config')
|
|
32
32
|
.action(_1.generate);
|
|
33
33
|
commander_1.program.parse(process.argv);
|
|
34
|
-
}
|
|
34
|
+
};
|
package/dist/constants.js
CHANGED
|
@@ -7,4 +7,4 @@ var StatisticType;
|
|
|
7
7
|
StatisticType["ERROR"] = "ERROR";
|
|
8
8
|
StatisticType["INCLUDE"] = "INCLUDE";
|
|
9
9
|
StatisticType["EXCLUDE"] = "EXCLUDE";
|
|
10
|
-
})(StatisticType
|
|
10
|
+
})(StatisticType || (exports.StatisticType = StatisticType = {}));
|
package/dist/index.d.ts
CHANGED
|
@@ -5,13 +5,7 @@ import { CLIArguments } from './interfaces';
|
|
|
5
5
|
*/
|
|
6
6
|
export declare const generate: (argv: CLIArguments) => Promise<void>;
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Watch files in source folder
|
|
9
9
|
* @param {CLIArguments} argv
|
|
10
|
-
* @param {object} ctx
|
|
11
|
-
* @returns {object}
|
|
12
10
|
*/
|
|
13
|
-
declare const
|
|
14
|
-
name: string;
|
|
15
|
-
ready: () => Promise<void>;
|
|
16
|
-
};
|
|
17
|
-
export default plugin;
|
|
11
|
+
export declare const watchFiles: (argv: CLIArguments) => void;
|
package/dist/index.js
CHANGED
|
@@ -8,74 +8,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
8
8
|
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
9
|
});
|
|
10
10
|
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (_) try {
|
|
18
|
-
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;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
var __read = (this && this.__read) || function (o, n) {
|
|
39
|
-
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
40
|
-
if (!m) return o;
|
|
41
|
-
var i = m.call(o), r, ar = [], e;
|
|
42
|
-
try {
|
|
43
|
-
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
44
|
-
}
|
|
45
|
-
catch (error) { e = { error: error }; }
|
|
46
|
-
finally {
|
|
47
|
-
try {
|
|
48
|
-
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
49
|
-
}
|
|
50
|
-
finally { if (e) throw e.error; }
|
|
51
|
-
}
|
|
52
|
-
return ar;
|
|
53
|
-
};
|
|
54
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
55
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
56
|
-
if (ar || !(i in from)) {
|
|
57
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
58
|
-
ar[i] = from[i];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
62
|
-
};
|
|
63
|
-
var __values = (this && this.__values) || function(o) {
|
|
64
|
-
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
|
|
65
|
-
if (m) return m.call(o);
|
|
66
|
-
if (o && typeof o.length === "number") return {
|
|
67
|
-
next: function () {
|
|
68
|
-
if (o && i >= o.length) o = void 0;
|
|
69
|
-
return { value: o && o[i++], done: !o };
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
|
-
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
|
|
73
|
-
};
|
|
74
11
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
75
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
76
13
|
};
|
|
77
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
78
|
-
exports.generate = void 0;
|
|
15
|
+
exports.watchFiles = exports.generate = void 0;
|
|
79
16
|
/*
|
|
80
17
|
* @vuepress
|
|
81
18
|
* ---
|
|
@@ -83,32 +20,30 @@ exports.generate = void 0;
|
|
|
83
20
|
* headline: The Main File
|
|
84
21
|
* ---
|
|
85
22
|
*/
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
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");
|
|
96
33
|
/**
|
|
97
34
|
* Create the sidebar
|
|
98
35
|
* @param {object} options
|
|
99
36
|
* @returns {Promise}
|
|
100
37
|
*/
|
|
101
|
-
|
|
102
|
-
return promises_1.default.writeFile("".concat(options.docsFolder, "/config.js"), "exports.fileTree=".concat(JSON.stringify(options.fileTree), ";exports.sidebarTree = (title = 'Mainpage') => (").concat(JSON.stringify((0, vue_sidebar_1.generateVueSidebar)(options)).replace('::vuepress-jsdoc-title::', '"+title+"'), ");"));
|
|
103
|
-
};
|
|
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+"')});`);
|
|
104
39
|
/**
|
|
105
40
|
* Parse file
|
|
106
41
|
* @param {DirectoryFile} file
|
|
107
42
|
* @param {CLIArguments} argv
|
|
108
43
|
* @returns {Promise}
|
|
109
44
|
*/
|
|
110
|
-
|
|
111
|
-
|
|
45
|
+
const parseDirectoryFile = (file, argv) => {
|
|
46
|
+
const { srcFolder, docsFolder, partials } = parseArguments(argv);
|
|
112
47
|
if (!file.isDir && file.folder) {
|
|
113
48
|
if (['.jsx', '.tsx', '.ts', '.js'].includes(file.ext || '')) {
|
|
114
49
|
return (0, parser_1.parseFile)(file, srcFolder, docsFolder, argv.jsDocConfigPath, partials);
|
|
@@ -124,47 +59,33 @@ var parseDirectoryFile = function (file, argv) {
|
|
|
124
59
|
* @param {string} deletedPaths
|
|
125
60
|
* @returns {void}
|
|
126
61
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
_b.label = 1;
|
|
136
|
-
case 1:
|
|
137
|
-
_b.trys.push([1, 3, , 4]);
|
|
138
|
-
return [4 /*yield*/, promises_1.default.readFile(readmePath, 'utf-8')];
|
|
139
|
-
case 2:
|
|
140
|
-
readMeContent = _b.sent();
|
|
141
|
-
if (deletedPaths === null || deletedPaths === void 0 ? void 0 : deletedPaths.some(function (p) { return p.indexOf("".concat(codeFolder, "/README.md")) !== -1; })) {
|
|
142
|
-
console.log("\n".concat(chalk_1.default.white.bgBlack(' README '), " ").concat(chalk_1.default.dim(readmePath.replace('README.md', ''))).concat(chalk_1.default.bold('README.md'), " \u2192 ").concat(chalk_1.default.dim(docsFolder)).concat(chalk_1.default.bold('/README.md')));
|
|
143
|
-
}
|
|
144
|
-
return [3 /*break*/, 4];
|
|
145
|
-
case 3:
|
|
146
|
-
e_1 = _b.sent();
|
|
147
|
-
console.log("\n".concat(chalk_1.default.white.bgBlack(' README '), " Add default README.md"));
|
|
148
|
-
return [3 /*break*/, 4];
|
|
149
|
-
case 4: return [4 /*yield*/, promises_1.default.writeFile("".concat(docsFolder, "/README.md"), readMeContent)];
|
|
150
|
-
case 5:
|
|
151
|
-
_b.sent();
|
|
152
|
-
return [2 /*return*/];
|
|
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`;
|
|
66
|
+
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')}`);
|
|
153
70
|
}
|
|
154
|
-
}
|
|
155
|
-
|
|
71
|
+
}
|
|
72
|
+
catch (e) {
|
|
73
|
+
console.log(`\n${kleur_1.default.white().bgBlack(' README ')} Add default README.md`);
|
|
74
|
+
}
|
|
75
|
+
yield promises_1.default.writeFile(`${docsFolder}/README.md`, readMeContent);
|
|
76
|
+
});
|
|
156
77
|
/**
|
|
157
78
|
* Parse all CLI arguments
|
|
158
79
|
* @param {CLIArguments} argv
|
|
159
80
|
* @returns {object} all arguments
|
|
160
81
|
*/
|
|
161
|
-
|
|
82
|
+
const parseArguments = (argv) => {
|
|
162
83
|
return {
|
|
163
84
|
include: (argv.include || '').split(',').filter(Boolean),
|
|
164
85
|
exclude: (argv.exclude || '').split(',').filter(Boolean),
|
|
165
86
|
srcFolder: argv.source.replace('./', ''),
|
|
166
87
|
codeFolder: argv.folder,
|
|
167
|
-
docsFolder:
|
|
88
|
+
docsFolder: `${argv.dist}/${argv.folder}`,
|
|
168
89
|
title: argv.title,
|
|
169
90
|
readme: argv.readme,
|
|
170
91
|
rmPattern: argv.rmPattern || [],
|
|
@@ -175,217 +96,105 @@ var parseArguments = function (argv) {
|
|
|
175
96
|
* Default command that generate md files
|
|
176
97
|
* @param {object} argv passed arguments
|
|
177
98
|
*/
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
case 3:
|
|
194
|
-
_q.sent();
|
|
195
|
-
parsePromises = [];
|
|
196
|
-
_q.label = 4;
|
|
197
|
-
case 4:
|
|
198
|
-
_q.trys.push([4, 9, 10, 11]);
|
|
199
|
-
_b = __values(lsFolder.paths), _c = _b.next();
|
|
200
|
-
_q.label = 5;
|
|
201
|
-
case 5:
|
|
202
|
-
if (!!_c.done) return [3 /*break*/, 8];
|
|
203
|
-
file = _c.value;
|
|
204
|
-
if (!!file.isDir) return [3 /*break*/, 7];
|
|
205
|
-
readline_1.default.clearLine(process.stdout, 0);
|
|
206
|
-
readline_1.default.cursorTo(process.stdout, 0);
|
|
207
|
-
process.stdout.write(chalk_1.default.dim(" ".concat(file.path, " ")));
|
|
208
|
-
return [4 /*yield*/, new Promise(function (resolve) { return setTimeout(resolve, 20); })];
|
|
209
|
-
case 6:
|
|
210
|
-
_q.sent();
|
|
211
|
-
_q.label = 7;
|
|
212
|
-
case 7:
|
|
213
|
-
_c = _b.next();
|
|
214
|
-
return [3 /*break*/, 5];
|
|
215
|
-
case 8: return [3 /*break*/, 11];
|
|
216
|
-
case 9:
|
|
217
|
-
e_2_1 = _q.sent();
|
|
218
|
-
e_2 = { error: e_2_1 };
|
|
219
|
-
return [3 /*break*/, 11];
|
|
220
|
-
case 10:
|
|
221
|
-
try {
|
|
222
|
-
if (_c && !_c.done && (_k = _b.return)) _k.call(_b);
|
|
223
|
-
}
|
|
224
|
-
finally { if (e_2) throw e_2.error; }
|
|
225
|
-
return [7 /*endfinally*/];
|
|
226
|
-
case 11:
|
|
227
|
-
readline_1.default.clearLine(process.stdout, 0);
|
|
228
|
-
readline_1.default.cursorTo(process.stdout, 0);
|
|
229
|
-
_loop_1 = function (file) {
|
|
230
|
-
parsePromises.push((function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
231
|
-
var data;
|
|
232
|
-
return __generator(this, function (_a) {
|
|
233
|
-
switch (_a.label) {
|
|
234
|
-
case 0: return [4 /*yield*/, parseDirectoryFile(file, argv)];
|
|
235
|
-
case 1:
|
|
236
|
-
data = _a.sent();
|
|
237
|
-
if (data && (data === null || data === void 0 ? void 0 : data.relativePathDest)) {
|
|
238
|
-
return [2 /*return*/, (0, parser_1.writeContentToFile)(data, data.relativePathDest)];
|
|
239
|
-
}
|
|
240
|
-
return [2 /*return*/];
|
|
241
|
-
}
|
|
242
|
-
});
|
|
243
|
-
}); })());
|
|
244
|
-
};
|
|
245
|
-
try {
|
|
246
|
-
// iterate through files and parse them
|
|
247
|
-
for (_d = __values(lsFolder.paths), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
248
|
-
file = _e.value;
|
|
249
|
-
_loop_1(file);
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
253
|
-
finally {
|
|
254
|
-
try {
|
|
255
|
-
if (_e && !_e.done && (_l = _d.return)) _l.call(_d);
|
|
256
|
-
}
|
|
257
|
-
finally { if (e_3) throw e_3.error; }
|
|
258
|
-
}
|
|
259
|
-
return [4 /*yield*/, Promise.all(parsePromises)];
|
|
260
|
-
case 12:
|
|
261
|
-
result = _q.sent();
|
|
262
|
-
result = result.filter(Boolean);
|
|
263
|
-
// write vuepress sidebar
|
|
264
|
-
return [4 /*yield*/, createVuepressSidebar({
|
|
265
|
-
fileTree: lsFolder.tree,
|
|
266
|
-
srcFolder: srcFolder,
|
|
267
|
-
docsFolder: docsFolder,
|
|
268
|
-
codeFolder: codeFolder,
|
|
269
|
-
title: title
|
|
270
|
-
})];
|
|
271
|
-
case 13:
|
|
272
|
-
// write vuepress sidebar
|
|
273
|
-
_q.sent();
|
|
274
|
-
try {
|
|
275
|
-
// print stats
|
|
276
|
-
for (_f = __values(lsFolder.excluded), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
277
|
-
file = _g.value;
|
|
278
|
-
console.log(chalk_1.default.reset.inverse.bold.blue(' EXCLUDE '), "".concat(chalk_1.default.dim(file.folder)).concat(chalk_1.default.bold(file.name + file.ext)));
|
|
279
|
-
}
|
|
280
|
-
}
|
|
281
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
282
|
-
finally {
|
|
283
|
-
try {
|
|
284
|
-
if (_g && !_g.done && (_m = _f.return)) _m.call(_f);
|
|
285
|
-
}
|
|
286
|
-
finally { if (e_4) throw e_4.error; }
|
|
287
|
-
}
|
|
288
|
-
console.log();
|
|
289
|
-
try {
|
|
290
|
-
for (_h = __values(result.flat()), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
291
|
-
entry = _j.value;
|
|
292
|
-
if (!entry.file)
|
|
293
|
-
continue;
|
|
294
|
-
color = (_p = {},
|
|
295
|
-
_p[constants_1.StatisticType.INCLUDE] = 'green',
|
|
296
|
-
_p[constants_1.StatisticType.ERROR] = 'red',
|
|
297
|
-
_p[constants_1.StatisticType.EMPTY] = 'yellow',
|
|
298
|
-
_p[constants_1.StatisticType.EXCLUDE] = 'blue',
|
|
299
|
-
_p)[entry.type];
|
|
300
|
-
console.log(chalk_1.default.reset.inverse.bold[color](" ".concat(entry.type, " ")), "".concat(chalk_1.default.dim(entry.relativePathSrc)).concat(chalk_1.default.bold(entry.file.name + entry.file.ext), " \u2192 ").concat(chalk_1.default.dim(entry.relativePathDest)).concat(chalk_1.default.bold(entry.file.name + '.md')));
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
304
|
-
finally {
|
|
305
|
-
try {
|
|
306
|
-
if (_j && !_j.done && (_o = _h.return)) _o.call(_h);
|
|
307
|
-
}
|
|
308
|
-
finally { if (e_5) throw e_5.error; }
|
|
309
|
-
}
|
|
310
|
-
// create README.md
|
|
311
|
-
return [4 /*yield*/, createReadmeFile(argv, deletedPaths)];
|
|
312
|
-
case 14:
|
|
313
|
-
// create README.md
|
|
314
|
-
_q.sent();
|
|
315
|
-
resultTime = (Math.abs(startTime - +new Date()) / 1000).toFixed(2);
|
|
316
|
-
console.log("\n\u23F0 Time: ".concat(resultTime, "s"));
|
|
317
|
-
watchFiles(argv);
|
|
318
|
-
return [2 /*return*/];
|
|
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));
|
|
319
114
|
}
|
|
115
|
+
}
|
|
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
|
+
}))());
|
|
126
|
+
}
|
|
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
|
|
320
137
|
});
|
|
321
|
-
|
|
138
|
+
// print stats
|
|
139
|
+
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)}`);
|
|
141
|
+
}
|
|
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')}`);
|
|
153
|
+
}
|
|
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
|
+
});
|
|
322
160
|
exports.generate = generate;
|
|
323
161
|
/**
|
|
324
162
|
* Watch files in source folder
|
|
325
163
|
* @param {CLIArguments} argv
|
|
326
164
|
*/
|
|
327
|
-
|
|
328
|
-
|
|
165
|
+
const watchFiles = (argv) => {
|
|
166
|
+
const { exclude, include, srcFolder, codeFolder, docsFolder, title } = parseArguments(argv);
|
|
329
167
|
if (argv.watch) {
|
|
330
168
|
console.log('\n---\n\nš watching files...');
|
|
331
|
-
|
|
169
|
+
const watcher = chokidar_1.default.watch([srcFolder, argv.readme, `${srcFolder}/README.md`].filter(Boolean), {
|
|
332
170
|
ignored: /(^|[\/\\])\../,
|
|
333
171
|
persistent: true
|
|
334
172
|
});
|
|
335
|
-
watcher.on('change',
|
|
336
|
-
var lsFolder, file;
|
|
173
|
+
watcher.on('change', (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
337
174
|
var _a;
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
docsFolder: docsFolder,
|
|
362
|
-
codeFolder: codeFolder,
|
|
363
|
-
title: title
|
|
364
|
-
});
|
|
365
|
-
});
|
|
366
|
-
}
|
|
367
|
-
return [2 /*return*/];
|
|
368
|
-
}
|
|
369
|
-
});
|
|
370
|
-
}); });
|
|
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);
|
|
181
|
+
}
|
|
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
|
+
});
|
|
196
|
+
}
|
|
197
|
+
}));
|
|
371
198
|
}
|
|
372
199
|
};
|
|
373
|
-
|
|
374
|
-
* The vuepress plugins
|
|
375
|
-
* @param {CLIArguments} argv
|
|
376
|
-
* @param {object} ctx
|
|
377
|
-
* @returns {object}
|
|
378
|
-
*/
|
|
379
|
-
var plugin = function (argv, ctx) { return ({
|
|
380
|
-
name: 'vuepress-plugin-jsdoc',
|
|
381
|
-
ready: function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
382
|
-
return __generator(this, function (_a) {
|
|
383
|
-
if (!ctx.isProd) {
|
|
384
|
-
argv.watch = true;
|
|
385
|
-
watchFiles(argv);
|
|
386
|
-
}
|
|
387
|
-
return [2 /*return*/];
|
|
388
|
-
});
|
|
389
|
-
}); }
|
|
390
|
-
}); };
|
|
391
|
-
exports.default = plugin;
|
|
200
|
+
exports.watchFiles = watchFiles;
|