jsdoc-builder 0.0.1 → 0.0.3
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/LICENSE +21 -0
- package/README.MD +2 -2
- package/dist/cli.js +0 -0
- package/dist/index.js +11 -25
- package/example/example.js +18 -0
- package/example/example.ts +18 -0
- package/package.json +21 -8
- package/dist/example/example.js +0 -2
- package/dist/generate.js +0 -37
- package/dist/parse.js +0 -20
- package/dist/parser.js +0 -38
- package/dist/src/cli.js +0 -12
- package/dist/src/index.js +0 -56
- package/dist/src/parser.js +0 -61
- package/dist/src/utils.js +0 -64
- package/dist/utils.js +0 -41
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 dori
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.MD
CHANGED
|
@@ -61,7 +61,7 @@ jsdoc-builder example.ts
|
|
|
61
61
|
|
|
62
62
|
```typescript
|
|
63
63
|
/**
|
|
64
|
-
* @description Function add
|
|
64
|
+
* @description Press Your { Function add } Description
|
|
65
65
|
* @param {number} a
|
|
66
66
|
* @param {number} b
|
|
67
67
|
* @returns {void}
|
|
@@ -71,7 +71,7 @@ function add(a: number, b: number) {
|
|
|
71
71
|
}
|
|
72
72
|
|
|
73
73
|
/**
|
|
74
|
-
* @description Function multiply
|
|
74
|
+
* @description Press Your { Function multiply } Description
|
|
75
75
|
* @param {number} a
|
|
76
76
|
* @param {number} b
|
|
77
77
|
* @returns {number}
|
package/dist/cli.js
CHANGED
|
File without changes
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateJSDoc =
|
|
3
|
+
exports.generateJSDoc = generateJSDoc;
|
|
4
4
|
const ts = require("typescript");
|
|
5
5
|
const fs = require("fs");
|
|
6
6
|
/**
|
|
@@ -11,7 +11,8 @@ function generateJSDoc(filePath) {
|
|
|
11
11
|
const sourceCode = fs.readFileSync(filePath, "utf-8");
|
|
12
12
|
const sourceFile = ts.createSourceFile(filePath, sourceCode, ts.ScriptTarget.Latest, true);
|
|
13
13
|
const printer = ts.createPrinter({ newLine: ts.NewLineKind.LineFeed });
|
|
14
|
-
function
|
|
14
|
+
// Visit function that processes each node
|
|
15
|
+
function visit(node, context) {
|
|
15
16
|
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
16
17
|
const jsDoc = createJSDoc(node.name.text, node.parameters, node.type);
|
|
17
18
|
ts.addSyntheticLeadingComment(node, ts.SyntaxKind.MultiLineCommentTrivia, jsDoc.comment, true);
|
|
@@ -30,35 +31,20 @@ function generateJSDoc(filePath) {
|
|
|
30
31
|
}
|
|
31
32
|
return node;
|
|
32
33
|
}
|
|
33
|
-
return ts.visitEachChild(node, visit, context);
|
|
34
|
+
return ts.visitEachChild(node, (child) => visit(child, context), context); // Pass context to visit
|
|
34
35
|
}
|
|
35
|
-
// Create
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
suspendLexicalEnvironment: () => { },
|
|
41
|
-
resumeLexicalEnvironment: () => { },
|
|
42
|
-
requestEmitHelper: () => { },
|
|
43
|
-
readEmitHelpers: () => undefined,
|
|
44
|
-
enableSubstitution: () => { },
|
|
45
|
-
isSubstitutionEnabled: () => false,
|
|
46
|
-
onSubstituteNode: (hint, node) => node,
|
|
47
|
-
enableEmitNotification: () => { },
|
|
48
|
-
isEmitNotificationEnabled: () => false,
|
|
49
|
-
onEmitNode: (hint, node, emitCallback) => emitCallback(hint, node),
|
|
50
|
-
getCompilerOptions: () => ({}),
|
|
51
|
-
hoistFunctionDeclaration: () => { },
|
|
52
|
-
hoistVariableDeclaration: () => { },
|
|
36
|
+
// Create the transformer
|
|
37
|
+
const transformer = (context) => {
|
|
38
|
+
return (sourceFile) => {
|
|
39
|
+
return ts.visitNode(sourceFile, (node) => visit(node, context)); // Pass context to visit
|
|
40
|
+
};
|
|
53
41
|
};
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
]);
|
|
42
|
+
// Apply the transformer
|
|
43
|
+
const result = ts.transform(sourceFile, [transformer]);
|
|
57
44
|
const transformedSourceFile = result.transformed[0];
|
|
58
45
|
const updatedCode = printer.printFile(transformedSourceFile);
|
|
59
46
|
fs.writeFileSync(filePath, updatedCode, "utf-8");
|
|
60
47
|
}
|
|
61
|
-
exports.generateJSDoc = generateJSDoc;
|
|
62
48
|
/**
|
|
63
49
|
* Creates a JSDoc comment.
|
|
64
50
|
* @param functionName - The name of the function.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Press Your { Function add } Description
|
|
3
|
+
* @param {any} a
|
|
4
|
+
* @param {any} b
|
|
5
|
+
* @returns {void}
|
|
6
|
+
*/
|
|
7
|
+
function add(a, b) {
|
|
8
|
+
return a + b;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @description Press Your { Function multiply } Description
|
|
12
|
+
* @param {any} a
|
|
13
|
+
* @param {any} b
|
|
14
|
+
* @returns {void}
|
|
15
|
+
*/
|
|
16
|
+
const multiply = (a, b) => {
|
|
17
|
+
return a * b;
|
|
18
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description Press Your { Function add } Description
|
|
3
|
+
* @param {number} a
|
|
4
|
+
* @param {number} b
|
|
5
|
+
* @returns {void}
|
|
6
|
+
*/
|
|
7
|
+
function add(a: number, b: number) {
|
|
8
|
+
return a + b;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* @description Press Your { Function multiply } Description
|
|
12
|
+
* @param {number} a
|
|
13
|
+
* @param {number} b
|
|
14
|
+
* @returns {number}
|
|
15
|
+
*/
|
|
16
|
+
const multiply = (a: number, b: number): number => {
|
|
17
|
+
return a * b;
|
|
18
|
+
};
|
package/package.json
CHANGED
|
@@ -1,23 +1,36 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "jsdoc-builder",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.3",
|
|
4
4
|
"author": "dori",
|
|
5
5
|
"description": "Generate JSDoc comments for JavaScript and TypeScript files.",
|
|
6
|
+
"publishConfig": {
|
|
7
|
+
"access": "public"
|
|
8
|
+
},
|
|
9
|
+
"repository": {
|
|
10
|
+
"type": "git",
|
|
11
|
+
"url": "https://github.com/klmhyeonwoo/jsdoc-builder"
|
|
12
|
+
},
|
|
13
|
+
"homepage": "https://github.com/klmhyeonwoo/jsdoc-builder#readme",
|
|
14
|
+
"bugs": {
|
|
15
|
+
"url": "https://github.com/klmhyeonwoo/jsdoc-builder/issues"
|
|
16
|
+
},
|
|
6
17
|
"bin": {
|
|
7
18
|
"jsdoc-builder": "./dist/cli.js"
|
|
8
19
|
},
|
|
9
20
|
"files": [
|
|
10
|
-
"dist"
|
|
21
|
+
"dist",
|
|
22
|
+
"example"
|
|
11
23
|
],
|
|
12
24
|
"license": "MIT",
|
|
13
25
|
"keywords": [
|
|
14
26
|
"jsdoc-generator",
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
27
|
+
"documentation-generator",
|
|
28
|
+
"auto-jsdoc",
|
|
29
|
+
"typescript-docs",
|
|
30
|
+
"typescript-jsdoc",
|
|
31
|
+
"javascript-documentation",
|
|
32
|
+
"cli-tool",
|
|
33
|
+
"developer-tools"
|
|
21
34
|
],
|
|
22
35
|
"scripts": {
|
|
23
36
|
"build": "tsc",
|
package/dist/example/example.js
DELETED
package/dist/generate.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import ts from "typescript";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
export function generateJSDoc(filePath) {
|
|
4
|
-
const fileContent = fs.readFileSync(filePath, "utf-8");
|
|
5
|
-
const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest);
|
|
6
|
-
const functions = [];
|
|
7
|
-
function visit(node) {
|
|
8
|
-
if (ts.isFunctionDeclaration(node) ||
|
|
9
|
-
ts.isFunctionExpression(node) ||
|
|
10
|
-
ts.isArrowFunction(node)) {
|
|
11
|
-
const functionName = node.name?.text || "Anonymous";
|
|
12
|
-
const params = node.parameters
|
|
13
|
-
.map((param) => {
|
|
14
|
-
const paramName = param.name?.getText(sourceFile) || "unknown";
|
|
15
|
-
const paramType = param.type ? param.type.getText(sourceFile) : "any";
|
|
16
|
-
return `@param {${paramType}} ${paramName}`;
|
|
17
|
-
})
|
|
18
|
-
.join("\n");
|
|
19
|
-
const returnType = node.type
|
|
20
|
-
? `@returns {${node.type.getText(sourceFile)}}`
|
|
21
|
-
: "@returns {any}";
|
|
22
|
-
const jsDoc = `
|
|
23
|
-
/**
|
|
24
|
-
* @function ${functionName}
|
|
25
|
-
* ${params}
|
|
26
|
-
* ${returnType}
|
|
27
|
-
*/
|
|
28
|
-
`;
|
|
29
|
-
functions.push(jsDoc);
|
|
30
|
-
}
|
|
31
|
-
ts.forEachChild(node, visit);
|
|
32
|
-
}
|
|
33
|
-
visit(sourceFile);
|
|
34
|
-
// JSDoc을 원본 파일 상단에 삽입
|
|
35
|
-
const updatedContent = functions.join("\n") + "\n\n" + fileContent;
|
|
36
|
-
fs.writeFileSync(filePath, updatedContent, "utf-8");
|
|
37
|
-
}
|
package/dist/parse.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.generateJSDoc = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
const ts = require("typescript");
|
|
6
|
-
function generateJSDoc(filePath) {
|
|
7
|
-
const fileContent = fs.readFileSync(filePath, "utf-8");
|
|
8
|
-
const sourceFile = ts.createSourceFile(filePath, fileContent, ts.ScriptTarget.Latest, true);
|
|
9
|
-
// Example: Traverse the AST and insert JSDoc
|
|
10
|
-
ts.forEachChild(sourceFile, (node) => {
|
|
11
|
-
if (ts.isFunctionDeclaration(node) && node.name) {
|
|
12
|
-
const functionName = node.name.text;
|
|
13
|
-
console.log(`Found function: ${functionName}`);
|
|
14
|
-
// Add logic to generate JSDoc comments
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
// Save the updated file (placeholder)
|
|
18
|
-
console.log(`Generated JSDoc for: ${filePath}`);
|
|
19
|
-
}
|
|
20
|
-
exports.generateJSDoc = generateJSDoc;
|
package/dist/parser.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseFile = void 0;
|
|
4
|
-
const ts = require("typescript");
|
|
5
|
-
/**
|
|
6
|
-
* Parse a TypeScript or JavaScript file to extract functions
|
|
7
|
-
* @param content File content
|
|
8
|
-
* @returns Array of FunctionInfo
|
|
9
|
-
*/
|
|
10
|
-
function parseFile(content) {
|
|
11
|
-
const sourceFile = ts.createSourceFile("temp.ts", content, ts.ScriptTarget.ESNext, true);
|
|
12
|
-
const functions = [];
|
|
13
|
-
function visit(node) {
|
|
14
|
-
if (ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node)) {
|
|
15
|
-
const name = node.name ? node.name.text : "anonymous";
|
|
16
|
-
const params = node.parameters.map((param) => ({
|
|
17
|
-
name: param.name.getText(),
|
|
18
|
-
type: param.type ? param.type.getText() : "any",
|
|
19
|
-
description: "",
|
|
20
|
-
}));
|
|
21
|
-
const returns = {
|
|
22
|
-
type: node.type ? node.type.getText() : "void",
|
|
23
|
-
description: "",
|
|
24
|
-
};
|
|
25
|
-
functions.push({
|
|
26
|
-
name,
|
|
27
|
-
description: `Function ${name}`,
|
|
28
|
-
params,
|
|
29
|
-
returns,
|
|
30
|
-
start: node.pos,
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
ts.forEachChild(node, visit);
|
|
34
|
-
}
|
|
35
|
-
visit(sourceFile);
|
|
36
|
-
return functions;
|
|
37
|
-
}
|
|
38
|
-
exports.parseFile = parseFile;
|
package/dist/src/cli.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env node
|
|
2
|
-
"use strict";
|
|
3
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
-
const commander_1 = require("commander");
|
|
5
|
-
const index_1 = require("./index");
|
|
6
|
-
commander_1.program
|
|
7
|
-
.command("generate <file>")
|
|
8
|
-
.description("Generate JSDoc comments for the given TypeScript or JavaScript file")
|
|
9
|
-
.action((file) => {
|
|
10
|
-
(0, index_1.generateJSDoc)(file);
|
|
11
|
-
});
|
|
12
|
-
commander_1.program.parse(process.argv);
|
package/dist/src/index.js
DELETED
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.generateJSDoc = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
const parser_1 = require("./parser");
|
|
29
|
-
const utils_1 = require("./utils");
|
|
30
|
-
const utils_2 = require("./utils");
|
|
31
|
-
/**
|
|
32
|
-
* Main function to generate JSDoc for a file
|
|
33
|
-
* @param filePath Path to the file
|
|
34
|
-
*/
|
|
35
|
-
function generateJSDoc(filePath) {
|
|
36
|
-
if (!(0, utils_1.fileExists)(filePath)) {
|
|
37
|
-
console.error(`File not found: ${filePath}`);
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
const content = fs.readFileSync(filePath, "utf-8");
|
|
41
|
-
const functions = (0, parser_1.parseFile)(content);
|
|
42
|
-
let updatedContent = content;
|
|
43
|
-
functions.forEach((func) => {
|
|
44
|
-
const jsdoc = (0, utils_2.formatJSDoc)(func.description, func.params, func.returns);
|
|
45
|
-
// 삽입할 위치 찾기
|
|
46
|
-
const insertPosition = func.start;
|
|
47
|
-
updatedContent =
|
|
48
|
-
updatedContent.slice(0, insertPosition) +
|
|
49
|
-
jsdoc +
|
|
50
|
-
"\n" +
|
|
51
|
-
updatedContent.slice(insertPosition);
|
|
52
|
-
});
|
|
53
|
-
(0, utils_1.writeFile)(filePath, updatedContent);
|
|
54
|
-
console.log(`JSDoc comments added to ${filePath}`);
|
|
55
|
-
}
|
|
56
|
-
exports.generateJSDoc = generateJSDoc;
|
package/dist/src/parser.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.parseFile = void 0;
|
|
27
|
-
const ts = __importStar(require("typescript"));
|
|
28
|
-
/**
|
|
29
|
-
* Parse a TypeScript or JavaScript file to extract functions
|
|
30
|
-
* @param content File content
|
|
31
|
-
* @returns Array of FunctionInfo
|
|
32
|
-
*/
|
|
33
|
-
function parseFile(content) {
|
|
34
|
-
const sourceFile = ts.createSourceFile("temp.ts", content, ts.ScriptTarget.ESNext, true);
|
|
35
|
-
const functions = [];
|
|
36
|
-
function visit(node) {
|
|
37
|
-
if (ts.isFunctionDeclaration(node) || ts.isFunctionExpression(node)) {
|
|
38
|
-
const name = node.name ? node.name.text : "anonymous";
|
|
39
|
-
const params = node.parameters.map((param) => ({
|
|
40
|
-
name: param.name.getText(),
|
|
41
|
-
type: param.type ? param.type.getText() : "any",
|
|
42
|
-
description: "",
|
|
43
|
-
}));
|
|
44
|
-
const returns = {
|
|
45
|
-
type: node.type ? node.type.getText() : "void",
|
|
46
|
-
description: "",
|
|
47
|
-
};
|
|
48
|
-
functions.push({
|
|
49
|
-
name,
|
|
50
|
-
description: `Function ${name}`,
|
|
51
|
-
params,
|
|
52
|
-
returns,
|
|
53
|
-
start: node.pos,
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
ts.forEachChild(node, visit);
|
|
57
|
-
}
|
|
58
|
-
visit(sourceFile);
|
|
59
|
-
return functions;
|
|
60
|
-
}
|
|
61
|
-
exports.parseFile = parseFile;
|
package/dist/src/utils.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.formatJSDoc = exports.writeFile = exports.fileExists = void 0;
|
|
27
|
-
const fs = __importStar(require("fs"));
|
|
28
|
-
/**
|
|
29
|
-
* Check if the file exists
|
|
30
|
-
* @param filePath Path to the file
|
|
31
|
-
* @returns True if the file exists
|
|
32
|
-
*/
|
|
33
|
-
function fileExists(filePath) {
|
|
34
|
-
return fs.existsSync(filePath);
|
|
35
|
-
}
|
|
36
|
-
exports.fileExists = fileExists;
|
|
37
|
-
/**
|
|
38
|
-
* Write content to a file
|
|
39
|
-
* @param filePath Path to the file
|
|
40
|
-
* @param content Content to write
|
|
41
|
-
*/
|
|
42
|
-
function writeFile(filePath, content) {
|
|
43
|
-
fs.writeFileSync(filePath, content, "utf-8");
|
|
44
|
-
}
|
|
45
|
-
exports.writeFile = writeFile;
|
|
46
|
-
/**
|
|
47
|
-
* Format a JSDoc comment
|
|
48
|
-
* @param description Description of the function
|
|
49
|
-
* @param params Parameters of the function
|
|
50
|
-
* @param returns Return type of the function
|
|
51
|
-
* @returns Formatted JSDoc string
|
|
52
|
-
*/
|
|
53
|
-
function formatJSDoc(description, params, returns) {
|
|
54
|
-
const paramDocs = params
|
|
55
|
-
.map((param) => ` * @param {${param.type}} ${param.name} - ${param.description}`)
|
|
56
|
-
.join("\n");
|
|
57
|
-
const returnDoc = ` * @returns {${returns.type}} - ${returns.description}`;
|
|
58
|
-
return `/**
|
|
59
|
-
* ${description}
|
|
60
|
-
${paramDocs}
|
|
61
|
-
${returnDoc}
|
|
62
|
-
*/`;
|
|
63
|
-
}
|
|
64
|
-
exports.formatJSDoc = formatJSDoc;
|
package/dist/utils.js
DELETED
|
@@ -1,41 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.formatJSDoc = exports.writeFile = exports.fileExists = void 0;
|
|
4
|
-
const fs = require("fs");
|
|
5
|
-
/**
|
|
6
|
-
* Check if the file exists
|
|
7
|
-
* @param filePath Path to the file
|
|
8
|
-
* @returns True if the file exists
|
|
9
|
-
*/
|
|
10
|
-
function fileExists(filePath) {
|
|
11
|
-
return fs.existsSync(filePath);
|
|
12
|
-
}
|
|
13
|
-
exports.fileExists = fileExists;
|
|
14
|
-
/**
|
|
15
|
-
* Write content to a file
|
|
16
|
-
* @param filePath Path to the file
|
|
17
|
-
* @param content Content to write
|
|
18
|
-
*/
|
|
19
|
-
function writeFile(filePath, content) {
|
|
20
|
-
fs.writeFileSync(filePath, content, "utf-8");
|
|
21
|
-
}
|
|
22
|
-
exports.writeFile = writeFile;
|
|
23
|
-
/**
|
|
24
|
-
* Format a JSDoc comment
|
|
25
|
-
* @param description Description of the function
|
|
26
|
-
* @param params Parameters of the function
|
|
27
|
-
* @param returns Return type of the function
|
|
28
|
-
* @returns Formatted JSDoc string
|
|
29
|
-
*/
|
|
30
|
-
function formatJSDoc(description, params, returns) {
|
|
31
|
-
const paramDocs = params
|
|
32
|
-
.map((param) => ` * @param {${param.type}} ${param.name} - ${param.description}`)
|
|
33
|
-
.join("\n");
|
|
34
|
-
const returnDoc = ` * @returns {${returns.type}} - ${returns.description}`;
|
|
35
|
-
return `/**
|
|
36
|
-
* "vv"${description}
|
|
37
|
-
${paramDocs}
|
|
38
|
-
${returnDoc}
|
|
39
|
-
*/`;
|
|
40
|
-
}
|
|
41
|
-
exports.formatJSDoc = formatJSDoc;
|