jsdoc-builder 0.0.6 → 0.0.7

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/vite.d.ts ADDED
@@ -0,0 +1,20 @@
1
+ import { GenerateJSDocOptions } from "./index";
2
+ type FilterPattern = string | RegExp;
3
+ export interface ViteLikeTransformResult {
4
+ code: string;
5
+ map: null;
6
+ }
7
+ export interface ViteLikePlugin {
8
+ name: string;
9
+ enforce?: "pre" | "post";
10
+ apply?: "serve" | "build";
11
+ transform?: (code: string, id: string) => Promise<ViteLikeTransformResult | null> | ViteLikeTransformResult | null;
12
+ }
13
+ export interface JSDocBuilderVitePluginOptions extends GenerateJSDocOptions {
14
+ include?: FilterPattern[];
15
+ exclude?: FilterPattern[];
16
+ extensions?: string[];
17
+ apply?: "serve" | "build" | "both";
18
+ }
19
+ export declare function jsdocBuilderVitePlugin(options?: JSDocBuilderVitePluginOptions): ViteLikePlugin;
20
+ export {};
package/dist/vite.js ADDED
@@ -0,0 +1,111 @@
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 () {
19
+ var ownKeys = function(o) {
20
+ ownKeys = Object.getOwnPropertyNames || function (o) {
21
+ var ar = [];
22
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
+ return ar;
24
+ };
25
+ return ownKeys(o);
26
+ };
27
+ return function (mod) {
28
+ if (mod && mod.__esModule) return mod;
29
+ var result = {};
30
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
+ __setModuleDefault(result, mod);
32
+ return result;
33
+ };
34
+ })();
35
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
36
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
37
+ return new (P || (P = Promise))(function (resolve, reject) {
38
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
39
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
40
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
41
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
42
+ });
43
+ };
44
+ var __rest = (this && this.__rest) || function (s, e) {
45
+ var t = {};
46
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
47
+ t[p] = s[p];
48
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
49
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
50
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
51
+ t[p[i]] = s[p[i]];
52
+ }
53
+ return t;
54
+ };
55
+ Object.defineProperty(exports, "__esModule", { value: true });
56
+ exports.jsdocBuilderVitePlugin = jsdocBuilderVitePlugin;
57
+ const path = __importStar(require("path"));
58
+ const index_1 = require("./index");
59
+ const DEFAULT_EXTENSIONS = [".js", ".jsx", ".ts", ".tsx", ".vue"];
60
+ function jsdocBuilderVitePlugin(options = {}) {
61
+ const { include = [], exclude = [/node_modules/], extensions = DEFAULT_EXTENSIONS, apply = "both" } = options, generateOptions = __rest(options, ["include", "exclude", "extensions", "apply"]);
62
+ return {
63
+ name: "jsdoc-builder",
64
+ enforce: "pre",
65
+ apply: apply === "both" ? undefined : apply,
66
+ transform(code, id) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ const targetId = stripQuery(id);
69
+ if (!shouldProcessFile(targetId, include, exclude, extensions)) {
70
+ return null;
71
+ }
72
+ const nextCode = yield (0, index_1.generateJSDocFromCode)(targetId, code, generateOptions);
73
+ if (nextCode === code) {
74
+ return null;
75
+ }
76
+ return {
77
+ code: nextCode,
78
+ map: null,
79
+ };
80
+ });
81
+ },
82
+ };
83
+ }
84
+ function shouldProcessFile(id, include, exclude, extensions) {
85
+ if (!id || id.startsWith("\0")) {
86
+ return false;
87
+ }
88
+ const normalizedId = id.replace(/\\/g, "/");
89
+ const fileExt = path.extname(normalizedId).toLowerCase();
90
+ const normalizedExtensions = new Set(extensions.map((ext) => ext.toLowerCase()));
91
+ if (!normalizedExtensions.has(fileExt)) {
92
+ return false;
93
+ }
94
+ if (exclude.some((pattern) => matchesPattern(normalizedId, pattern))) {
95
+ return false;
96
+ }
97
+ if (include.length === 0) {
98
+ return true;
99
+ }
100
+ return include.some((pattern) => matchesPattern(normalizedId, pattern));
101
+ }
102
+ function matchesPattern(id, pattern) {
103
+ if (typeof pattern === "string") {
104
+ return id.includes(pattern);
105
+ }
106
+ return pattern.test(id);
107
+ }
108
+ function stripQuery(id) {
109
+ const queryIndex = id.indexOf("?");
110
+ return queryIndex >= 0 ? id.slice(0, queryIndex) : id;
111
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * @description Press Your { Function Component } Description
3
+ * @param {any} props
4
+ * @returns {void}
5
+ */
6
+ function Component(props) {
7
+ return <div>{props.title}</div>;
8
+ }
9
+ /**
10
+ * @description Press Your { Function ArrowComponent } Description
11
+ * @param {any} props
12
+ * @returns {void}
13
+ */
14
+ const ArrowComponent = (props) => {
15
+ return <div>{props.content}</div>;
16
+ };
17
+ export default Component;
@@ -0,0 +1,21 @@
1
+ interface Props {
2
+ title: string;
3
+ count?: number;
4
+ }
5
+ /**
6
+ * @description Press Your { Function Component } Description
7
+ * @param {Props} props
8
+ * @returns {void}
9
+ */
10
+ function Component(props: Props) {
11
+ return <div>{props.title}</div>;
12
+ }
13
+ /**
14
+ * @description Press Your { Function ArrowComponent } Description
15
+ * @param {Props} props
16
+ * @returns {JSX.Element}
17
+ */
18
+ const ArrowComponent = (props: Props): JSX.Element => {
19
+ return <div>{props.title}</div>;
20
+ };
21
+ export default Component;
@@ -0,0 +1,36 @@
1
+ <template>
2
+ <div>{{ message }}</div>
3
+ </template>
4
+
5
+ <script>/**
6
+ * @description Press Your { Function greet } Description
7
+ * @param {any} name
8
+ * @returns {void}
9
+ */
10
+ function greet(name) {
11
+ return `Hello, ${name}`;
12
+ }
13
+ /**
14
+ * @description Press Your { Function farewell } Description
15
+ * @param {any} name
16
+ * @returns {void}
17
+ */
18
+ const farewell = (name) => {
19
+ return `Goodbye, ${name}`;
20
+ };
21
+ export default {
22
+ name: 'ExampleComponent',
23
+ setup() {
24
+ return {
25
+ greet,
26
+ farewell
27
+ };
28
+ }
29
+ };
30
+ </script>
31
+
32
+ <style scoped>
33
+ div {
34
+ color: blue;
35
+ }
36
+ </style>
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "jsdoc-builder",
3
- "version": "0.0.6",
3
+ "version": "0.0.7",
4
4
  "author": "dori",
5
- "description": "Generate JSDoc comments for JavaScript and TypeScript files.",
5
+ "description": "Generate JSDoc comments for JavaScript, TypeScript, JSX, TSX, and Vue files.",
6
6
  "publishConfig": {
7
7
  "access": "public"
8
8
  },
@@ -14,6 +14,18 @@
14
14
  "bugs": {
15
15
  "url": "https://github.com/klmhyeonwoo/jsdoc-builder/issues"
16
16
  },
17
+ "main": "./dist/index.js",
18
+ "types": "./dist/index.d.ts",
19
+ "exports": {
20
+ ".": {
21
+ "types": "./dist/index.d.ts",
22
+ "default": "./dist/index.js"
23
+ },
24
+ "./vite": {
25
+ "types": "./dist/vite.d.ts",
26
+ "default": "./dist/vite.js"
27
+ }
28
+ },
17
29
  "bin": {
18
30
  "jsdoc-builder": "./dist/cli.js"
19
31
  },
@@ -29,6 +41,11 @@
29
41
  "typescript-docs",
30
42
  "typescript-jsdoc",
31
43
  "javascript-documentation",
44
+ "jsx-documentation",
45
+ "tsx-documentation",
46
+ "vue-documentation",
47
+ "react-jsdoc",
48
+ "vue-jsdoc",
32
49
  "cli-tool",
33
50
  "developer-tools"
34
51
  ],
@@ -42,7 +59,7 @@
42
59
  "typescript": "^5.0.0"
43
60
  },
44
61
  "devDependencies": {
45
- "@types/node": "^20.0.0",
62
+ "@types/node": "^20.19.34",
46
63
  "ts-node": "^10.0.0"
47
64
  }
48
65
  }