From 39ac2666babfb32534657d17df14adf785caf2c2 Mon Sep 17 00:00:00 2001 From: Sojin Park Date: Sat, 15 Aug 2026 15:38:53 +0900 Subject: [PATCH] chore: remove unused generate-docs script --- .scripts/docs/deno.json | 9 - .scripts/docs/deno.lock | 325 ------------------ .scripts/docs/formatters/class.ts | 48 --- .scripts/docs/formatters/function.ts | 40 --- .scripts/docs/formatters/helpers/readonly.ts | 21 -- .../docs/formatters/nodes/call-signature.ts | 19 - .scripts/docs/formatters/nodes/decorator.ts | 18 - .../docs/formatters/nodes/index-signature.ts | 22 -- .scripts/docs/formatters/nodes/method.ts | 29 -- .../docs/formatters/nodes/object-pat-prop.ts | 30 -- .scripts/docs/formatters/nodes/param.ts | 101 ------ .scripts/docs/formatters/nodes/property.ts | 27 -- .scripts/docs/formatters/nodes/type-param.ts | 21 -- .scripts/docs/formatters/nodes/type.ts | 292 ---------------- .scripts/docs/formatters/options.ts | 5 - .scripts/docs/generate-docs.mts | 133 ------- .scripts/docs/operations/render/en.ts | 84 ----- .scripts/docs/operations/render/ja.ts | 78 ----- .scripts/docs/operations/render/ko.ts | 76 ---- .scripts/docs/operations/render/types.ts | 3 - .scripts/docs/operations/render/zh_hans.ts | 76 ---- .../docs/operations/toDocumentationItem.ts | 122 ------- .scripts/docs/operations/translate.ts | 55 --- .scripts/docs/types/DocumentationItem.ts | 15 - .scripts/docs/types/Locale.ts | 1 - .vscode/settings.json | 2 - tsconfig.json | 2 +- 27 files changed, 1 insertion(+), 1653 deletions(-) delete mode 100644 .scripts/docs/deno.json delete mode 100644 .scripts/docs/deno.lock delete mode 100644 .scripts/docs/formatters/class.ts delete mode 100644 .scripts/docs/formatters/function.ts delete mode 100644 .scripts/docs/formatters/helpers/readonly.ts delete mode 100644 .scripts/docs/formatters/nodes/call-signature.ts delete mode 100644 .scripts/docs/formatters/nodes/decorator.ts delete mode 100644 .scripts/docs/formatters/nodes/index-signature.ts delete mode 100644 .scripts/docs/formatters/nodes/method.ts delete mode 100644 .scripts/docs/formatters/nodes/object-pat-prop.ts delete mode 100644 .scripts/docs/formatters/nodes/param.ts delete mode 100644 .scripts/docs/formatters/nodes/property.ts delete mode 100644 .scripts/docs/formatters/nodes/type-param.ts delete mode 100644 .scripts/docs/formatters/nodes/type.ts delete mode 100644 .scripts/docs/formatters/options.ts delete mode 100644 .scripts/docs/generate-docs.mts delete mode 100644 .scripts/docs/operations/render/en.ts delete mode 100644 .scripts/docs/operations/render/ja.ts delete mode 100644 .scripts/docs/operations/render/ko.ts delete mode 100644 .scripts/docs/operations/render/types.ts delete mode 100644 .scripts/docs/operations/render/zh_hans.ts delete mode 100644 .scripts/docs/operations/toDocumentationItem.ts delete mode 100644 .scripts/docs/operations/translate.ts delete mode 100644 .scripts/docs/types/DocumentationItem.ts delete mode 100644 .scripts/docs/types/Locale.ts diff --git a/.scripts/docs/deno.json b/.scripts/docs/deno.json deleted file mode 100644 index 7c3af52bdb..0000000000 --- a/.scripts/docs/deno.json +++ /dev/null @@ -1,9 +0,0 @@ -{ - "imports": { - "@deno/doc": "jsr:@deno/doc@^0.148.0", - "@es-toolkit/es-toolkit": "jsr:@es-toolkit/es-toolkit@^1.19.0", - "@std/dotenv": "jsr:@std/dotenv@^0.225.2", - "clipanion": "npm:clipanion@^3.2.1", - "openai": "npm:openai@^4.58.1" - } -} diff --git a/.scripts/docs/deno.lock b/.scripts/docs/deno.lock deleted file mode 100644 index ea7d1a85e3..0000000000 --- a/.scripts/docs/deno.lock +++ /dev/null @@ -1,325 +0,0 @@ -{ - "version": "3", - "packages": { - "specifiers": { - "jsr:@deno/cache-dir@0.11": "jsr:@deno/cache-dir@0.11.1", - "jsr:@deno/doc@^0.148.0": "jsr:@deno/doc@0.148.0", - "jsr:@deno/graph@0.82": "jsr:@deno/graph@0.82.1", - "jsr:@deno/graph@^0.73.1": "jsr:@deno/graph@0.73.1", - "jsr:@es-toolkit/es-toolkit@^1.19.0": "jsr:@es-toolkit/es-toolkit@1.19.0", - "jsr:@std/assert@^0.223.0": "jsr:@std/assert@0.223.0", - "jsr:@std/bytes@^0.223.0": "jsr:@std/bytes@0.223.0", - "jsr:@std/dotenv@^0.225.2": "jsr:@std/dotenv@0.225.2", - "jsr:@std/fmt@^0.223": "jsr:@std/fmt@0.223.0", - "jsr:@std/fs@^0.223": "jsr:@std/fs@0.223.0", - "jsr:@std/io@^0.223": "jsr:@std/io@0.223.0", - "jsr:@std/path@^0.223": "jsr:@std/path@0.223.0", - "npm:@types/node": "npm:@types/node@18.16.19", - "npm:clipanion@^3.2.1": "npm:clipanion@3.2.1_typanion@3.14.0", - "npm:openai@^4.58.1": "npm:openai@4.58.1" - }, - "jsr": { - "@deno/cache-dir@0.11.1": { - "integrity": "eaedd37ff99928cfbdee0174448322228bdc9e5a4f0fbd722fe925f28756f900", - "dependencies": [ - "jsr:@deno/graph@^0.73.1", - "jsr:@std/fmt@^0.223", - "jsr:@std/fs@^0.223", - "jsr:@std/io@^0.223", - "jsr:@std/path@^0.223" - ] - }, - "@deno/doc@0.148.0": { - "integrity": "45b8524e297c003e0040506583ec621036b5db79d6d3d6da891d5c22054f018d", - "dependencies": [ - "jsr:@deno/cache-dir@0.11", - "jsr:@deno/graph@0.82" - ] - }, - "@deno/graph@0.73.1": { - "integrity": "cd69639d2709d479037d5ce191a422eabe8d71bb68b0098344f6b07411c84d41" - }, - "@deno/graph@0.82.1": { - "integrity": "ce5ccb325b1c84f65000eddb6d1922cfb43545beabd4f395648ad541c1cd987c" - }, - "@es-toolkit/es-toolkit@1.19.0": { - "integrity": "d792dcfe879d6b3a0586026f3e2f887074254418b5358a767506285c21af09dd" - }, - "@std/assert@0.223.0": { - "integrity": "eb8d6d879d76e1cc431205bd346ed4d88dc051c6366365b1af47034b0670be24" - }, - "@std/bytes@0.223.0": { - "integrity": "84b75052cd8680942c397c2631318772b295019098f40aac5c36cead4cba51a8" - }, - "@std/dotenv@0.225.2": { - "integrity": "e2025dce4de6c7bca21dece8baddd4262b09d5187217e231b033e088e0c4dd23" - }, - "@std/fmt@0.223.0": { - "integrity": "6deb37794127dfc7d7bded2586b9fc6f5d50e62a8134846608baf71ffc1a5208" - }, - "@std/fs@0.223.0": { - "integrity": "3b4b0550b2c524cbaaa5a9170c90e96cbb7354e837ad1bdaf15fc9df1ae9c31c" - }, - "@std/io@0.223.0": { - "integrity": "2d8c3c2ab3a515619b90da2c6ff5ea7b75a94383259ef4d02116b228393f84f1", - "dependencies": [ - "jsr:@std/assert@^0.223.0", - "jsr:@std/bytes@^0.223.0" - ] - }, - "@std/path@0.223.0": { - "integrity": "593963402d7e6597f5a6e620931661053572c982fc014000459edc1f93cc3989", - "dependencies": [ - "jsr:@std/assert@^0.223.0" - ] - } - }, - "npm": { - "@types/node-fetch@2.6.11": { - "integrity": "sha512-24xFj9R5+rfQJLRyM56qh+wnVSYhyXC2tkoBndtY0U+vubqNsYXGjufB2nn8Q6gt0LrARwL6UBtMCSVCwl4B1g==", - "dependencies": { - "@types/node": "@types/node@18.16.19", - "form-data": "form-data@4.0.0" - } - }, - "@types/node@18.16.19": { - "integrity": "sha512-IXl7o+R9iti9eBW4Wg2hx1xQDig183jj7YLn8F7udNceyfkbn1ZxmzZXuak20gR40D7pIkIY1kYGx5VIGbaHKA==", - "dependencies": {} - }, - "@types/qs@6.9.15": { - "integrity": "sha512-uXHQKES6DQKKCLh441Xv/dwxOq1TVS3JPUMlEqoEglvlhR6Mxnlew/Xq/LRVHpLyk7iK3zODe1qYHIMltO7XGg==", - "dependencies": {} - }, - "abort-controller@3.0.0": { - "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", - "dependencies": { - "event-target-shim": "event-target-shim@5.0.1" - } - }, - "agentkeepalive@4.5.0": { - "integrity": "sha512-5GG/5IbQQpC9FpkRGsSvZI5QYeSCzlJHdpBQntCsuTOxhKD8lqKhrleg2Yi7yvMIf82Ycmmqln9U8V9qwEiJew==", - "dependencies": { - "humanize-ms": "humanize-ms@1.2.1" - } - }, - "asynckit@0.4.0": { - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", - "dependencies": {} - }, - "call-bind@1.0.7": { - "integrity": "sha512-GHTSNSYICQ7scH7sZ+M2rFopRoLh8t2bLSW6BbgrtLsahOIB5iyAVJf9GjWK3cYTDaMj4XdBpM1cA6pIS0Kv2w==", - "dependencies": { - "es-define-property": "es-define-property@1.0.0", - "es-errors": "es-errors@1.3.0", - "function-bind": "function-bind@1.1.2", - "get-intrinsic": "get-intrinsic@1.2.4", - "set-function-length": "set-function-length@1.2.2" - } - }, - "clipanion@3.2.1_typanion@3.14.0": { - "integrity": "sha512-dYFdjLb7y1ajfxQopN05mylEpK9ZX0sO1/RfMXdfmwjlIsPkbh4p7A682x++zFPLDCo1x3p82dtljHf5cW2LKA==", - "dependencies": { - "typanion": "typanion@3.14.0" - } - }, - "combined-stream@1.0.8": { - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", - "dependencies": { - "delayed-stream": "delayed-stream@1.0.0" - } - }, - "define-data-property@1.1.4": { - "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", - "dependencies": { - "es-define-property": "es-define-property@1.0.0", - "es-errors": "es-errors@1.3.0", - "gopd": "gopd@1.0.1" - } - }, - "delayed-stream@1.0.0": { - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", - "dependencies": {} - }, - "es-define-property@1.0.0": { - "integrity": "sha512-jxayLKShrEqqzJ0eumQbVhTYQM27CfT1T35+gCgDFoL82JLsXqTJ76zv6A0YLOgEnLUMvLzsDsGIrl8NFpT2gQ==", - "dependencies": { - "get-intrinsic": "get-intrinsic@1.2.4" - } - }, - "es-errors@1.3.0": { - "integrity": "sha512-Zf5H2Kxt2xjTvbJvP2ZWLEICxA6j+hAmMzIlypy4xcBg1vKVnx89Wy0GbS+kf5cwCVFFzdCFh2XSCFNULS6csw==", - "dependencies": {} - }, - "event-target-shim@5.0.1": { - "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==", - "dependencies": {} - }, - "form-data-encoder@1.7.2": { - "integrity": "sha512-qfqtYan3rxrnCk1VYaA4H+Ms9xdpPqvLZa6xmMgFvhO32x7/3J/ExcTd6qpxM0vH2GdMI+poehyBZvqfMTto8A==", - "dependencies": {} - }, - "form-data@4.0.0": { - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", - "dependencies": { - "asynckit": "asynckit@0.4.0", - "combined-stream": "combined-stream@1.0.8", - "mime-types": "mime-types@2.1.35" - } - }, - "formdata-node@4.4.1": { - "integrity": "sha512-0iirZp3uVDjVGt9p49aTaqjk84TrglENEDuqfdlZQ1roC9CWlPk6Avf8EEnZNcAqPonwkG35x4n3ww/1THYAeQ==", - "dependencies": { - "node-domexception": "node-domexception@1.0.0", - "web-streams-polyfill": "web-streams-polyfill@4.0.0-beta.3" - } - }, - "function-bind@1.1.2": { - "integrity": "sha512-7XHNxH7qX9xG5mIwxkhumTox/MIRNcOgDrxWsMt2pAr23WHp6MrRlN7FBSFpCpr+oVO0F744iUgR82nJMfG2SA==", - "dependencies": {} - }, - "get-intrinsic@1.2.4": { - "integrity": "sha512-5uYhsJH8VJBTv7oslg4BznJYhDoRI6waYCxMmCdnTrcCrHA/fCFKoTFz2JKKE0HdDFUF7/oQuhzumXJK7paBRQ==", - "dependencies": { - "es-errors": "es-errors@1.3.0", - "function-bind": "function-bind@1.1.2", - "has-proto": "has-proto@1.0.3", - "has-symbols": "has-symbols@1.0.3", - "hasown": "hasown@2.0.2" - } - }, - "gopd@1.0.1": { - "integrity": "sha512-d65bNlIadxvpb/A2abVdlqKqV563juRnZ1Wtk6s1sIR8uNsXR70xqIzVqxVf1eTqDunwT2MkczEeaezCKTZhwA==", - "dependencies": { - "get-intrinsic": "get-intrinsic@1.2.4" - } - }, - "has-property-descriptors@1.0.2": { - "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", - "dependencies": { - "es-define-property": "es-define-property@1.0.0" - } - }, - "has-proto@1.0.3": { - "integrity": "sha512-SJ1amZAJUiZS+PhsVLf5tGydlaVB8EdFpaSO4gmiUKUOxk8qzn5AIy4ZeJUmh22znIdk/uMAUT2pl3FxzVUH+Q==", - "dependencies": {} - }, - "has-symbols@1.0.3": { - "integrity": "sha512-l3LCuF6MgDNwTDKkdYGEihYjt5pRPbEg46rtlmnSPlUbgmB8LOIrKJbYYFBSbnPaJexMKtiPO8hmeRjRz2Td+A==", - "dependencies": {} - }, - "hasown@2.0.2": { - "integrity": "sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==", - "dependencies": { - "function-bind": "function-bind@1.1.2" - } - }, - "humanize-ms@1.2.1": { - "integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==", - "dependencies": { - "ms": "ms@2.1.3" - } - }, - "mime-db@1.52.0": { - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", - "dependencies": {} - }, - "mime-types@2.1.35": { - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", - "dependencies": { - "mime-db": "mime-db@1.52.0" - } - }, - "ms@2.1.3": { - "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", - "dependencies": {} - }, - "node-domexception@1.0.0": { - "integrity": "sha512-/jKZoMpw0F8GRwl4/eLROPA3cfcXtLApP0QzLmUT/HuPCZWyB7IY9ZrMeKw2O/nFIqPQB3PVM9aYm0F312AXDQ==", - "dependencies": {} - }, - "node-fetch@2.7.0": { - "integrity": "sha512-c4FRfUm/dbcWZ7U+1Wq0AwCyFL+3nt2bEw05wfxSz+DWpWsitgmSgYmy2dQdWyKC1694ELPqMs/YzUSNozLt8A==", - "dependencies": { - "whatwg-url": "whatwg-url@5.0.0" - } - }, - "object-inspect@1.13.2": { - "integrity": "sha512-IRZSRuzJiynemAXPYtPe5BoI/RESNYR7TYm50MC5Mqbd3Jmw5y790sErYw3V6SryFJD64b74qQQs9wn5Bg/k3g==", - "dependencies": {} - }, - "openai@4.58.1": { - "integrity": "sha512-n9fN4RIjbj4PbZU6IN/FOBBbxHbHEcW18rDZ4nW2cDNfZP2+upm/FM20UCmRNMQTvhOvw/2Tw4vgioQyQb5nlA==", - "dependencies": { - "@types/node": "@types/node@18.16.19", - "@types/node-fetch": "@types/node-fetch@2.6.11", - "@types/qs": "@types/qs@6.9.15", - "abort-controller": "abort-controller@3.0.0", - "agentkeepalive": "agentkeepalive@4.5.0", - "form-data-encoder": "form-data-encoder@1.7.2", - "formdata-node": "formdata-node@4.4.1", - "node-fetch": "node-fetch@2.7.0", - "qs": "qs@6.13.0" - } - }, - "qs@6.13.0": { - "integrity": "sha512-+38qI9SOr8tfZ4QmJNplMUxqjbe7LKvvZgWdExBOmd+egZTtjLB67Gu0HRX3u/XOq7UU2Nx6nsjvS16Z9uwfpg==", - "dependencies": { - "side-channel": "side-channel@1.0.6" - } - }, - "set-function-length@1.2.2": { - "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", - "dependencies": { - "define-data-property": "define-data-property@1.1.4", - "es-errors": "es-errors@1.3.0", - "function-bind": "function-bind@1.1.2", - "get-intrinsic": "get-intrinsic@1.2.4", - "gopd": "gopd@1.0.1", - "has-property-descriptors": "has-property-descriptors@1.0.2" - } - }, - "side-channel@1.0.6": { - "integrity": "sha512-fDW/EZ6Q9RiO8eFG8Hj+7u/oW+XrPTIChwCOM2+th2A6OblDtYYIpve9m+KvI9Z4C9qSEXlaGR6bTEYHReuglA==", - "dependencies": { - "call-bind": "call-bind@1.0.7", - "es-errors": "es-errors@1.3.0", - "get-intrinsic": "get-intrinsic@1.2.4", - "object-inspect": "object-inspect@1.13.2" - } - }, - "tr46@0.0.3": { - "integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==", - "dependencies": {} - }, - "typanion@3.14.0": { - "integrity": "sha512-ZW/lVMRabETuYCd9O9ZvMhAh8GslSqaUjxmK/JLPCh6l73CvLBiuXswj/+7LdnWOgYsQ130FqLzFz5aGT4I3Ug==", - "dependencies": {} - }, - "web-streams-polyfill@4.0.0-beta.3": { - "integrity": "sha512-QW95TCTaHmsYfHDybGMwO5IJIM93I/6vTRk+daHTWFPhwh+C8Cg7j7XyKrwrj8Ib6vYXe0ocYNrmzY4xAAN6ug==", - "dependencies": {} - }, - "webidl-conversions@3.0.1": { - "integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==", - "dependencies": {} - }, - "whatwg-url@5.0.0": { - "integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==", - "dependencies": { - "tr46": "tr46@0.0.3", - "webidl-conversions": "webidl-conversions@3.0.1" - } - } - } - }, - "remote": {}, - "workspace": { - "dependencies": [ - "jsr:@deno/doc@^0.148.0", - "jsr:@es-toolkit/es-toolkit@^1.19.0", - "jsr:@std/dotenv@^0.225.2", - "npm:clipanion@^3.2.1", - "npm:openai@^4.58.1" - ] - } -} diff --git a/.scripts/docs/formatters/class.ts b/.scripts/docs/formatters/class.ts deleted file mode 100644 index 47ae84dd3e..0000000000 --- a/.scripts/docs/formatters/class.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { DocNodeClass } from '@deno/doc'; -import { formatDecorator } from './nodes/decorator.ts'; -import { formatTypeParam } from './nodes/type-param.ts'; -import { formatType } from './nodes/type.ts'; -import { FormatOption } from './options.ts'; - -export function formatClassDoc(node: DocNodeClass, options: FormatOption = {}): string { - let result = ''; - - if (node.classDef.decorators != null && node.classDef.decorators.length > 0) { - result += node.classDef.decorators.map(d => formatDecorator(d, options)).join('\n'); - } - - if (node.declarationKind === 'private') { - result += 'private '; - } - - if (node.classDef.isAbstract) { - result += 'abstract '; - } - - result += 'class '; - result += node.name; - - if (node.classDef.typeParams.length > 0) { - result += '<'; - result += node.classDef.typeParams.map(p => formatTypeParam(p, options)).join(', '); - result += '>'; - } - - if (node.classDef.extends) { - result += ' extends '; - result += node.classDef.extends; - } - - if (node.classDef.superTypeParams.length > 0) { - result += '<'; - result += node.classDef.superTypeParams.map(p => formatType(p, options)).join(', '); - result += '>'; - } - - if (node.classDef.implements.length > 0) { - result += ' implements '; - result += node.classDef.implements.map(i => formatType(i, options)).join(', '); - } - - return result; -} diff --git a/.scripts/docs/formatters/function.ts b/.scripts/docs/formatters/function.ts deleted file mode 100644 index aa7dfdcfb3..0000000000 --- a/.scripts/docs/formatters/function.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { DocNodeFunction } from '@deno/doc'; -import { formatParam } from './nodes/param.ts'; -import { formatTypeParam } from './nodes/type-param.ts'; -import { formatType } from './nodes/type.ts'; -import { FormatOption } from './options.ts'; - -export function formatFunctionDoc(node: DocNodeFunction, options: FormatOption = {}): string { - let result = ''; - - if (node.functionDef.isAsync) { - result += 'async '; - } - - result += 'function'; - - if (node.functionDef.isGenerator) { - result += '*'; - } - - result += ' '; - - result += node.name; - - if (node.functionDef.typeParams.length > 0) { - result += '<'; - result += node.functionDef.typeParams.map(p => formatTypeParam(p, options)).join(', '); - result += '>'; - } - - result += '('; - result += node.functionDef.params.map(p => formatParam(p, options)).join(', '); - result += ')'; - - if (node.functionDef.returnType != null) { - result += ': '; - result += formatType(node.functionDef.returnType, options); - } - - return result; -} diff --git a/.scripts/docs/formatters/helpers/readonly.ts b/.scripts/docs/formatters/helpers/readonly.ts deleted file mode 100644 index f4146bdee4..0000000000 --- a/.scripts/docs/formatters/helpers/readonly.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { FormatOption } from '../options.ts'; - -export function formatReadonly(node: { readonly?: boolean | '+' | '-' }, options: FormatOption): string { - if (!options.display?.readonly) { - return ''; - } - - switch (node.readonly) { - case true: { - return 'readonly '; - } - case '+': { - return '+readonly '; - } - case '-': { - return '-readonly '; - } - } - - return ''; -} diff --git a/.scripts/docs/formatters/nodes/call-signature.ts b/.scripts/docs/formatters/nodes/call-signature.ts deleted file mode 100644 index 572fbce7ab..0000000000 --- a/.scripts/docs/formatters/nodes/call-signature.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { LiteralCallSignatureDef } from '@deno/doc'; -import { formatParam } from './param.ts'; -import { formatType } from './type.ts'; -import { FormatOption } from '../options.ts'; - -export function formatCallSignatureDef(node: LiteralCallSignatureDef, options: FormatOption) { - let result = ''; - - result += '('; - result += node.params.map(param => formatParam(param, options)).join(', '); - result += ')'; - - if (node.tsType != null) { - result += ': '; - result += formatType(node.tsType, options); - } - - return result; -} diff --git a/.scripts/docs/formatters/nodes/decorator.ts b/.scripts/docs/formatters/nodes/decorator.ts deleted file mode 100644 index 72c2a81a57..0000000000 --- a/.scripts/docs/formatters/nodes/decorator.ts +++ /dev/null @@ -1,18 +0,0 @@ -import { DecoratorDef } from '@deno/doc'; -import { FormatOption } from '../options.ts'; - -// eslint-disable-next-line -export function formatDecorator(node: DecoratorDef, _: FormatOption) { - let result = ''; - - result += '@'; - result += node.name; - - if (node.args != null && node.args.length > 0) { - result += '('; - result += node.args.join(', '); - result += ')'; - } - - return result; -} diff --git a/.scripts/docs/formatters/nodes/index-signature.ts b/.scripts/docs/formatters/nodes/index-signature.ts deleted file mode 100644 index 7547dca913..0000000000 --- a/.scripts/docs/formatters/nodes/index-signature.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { LiteralIndexSignatureDef } from '@deno/doc'; -import { formatParam } from './param.ts'; -import { formatType } from './type.ts'; -import { formatReadonly } from '../helpers/readonly.ts'; -import { FormatOption } from '../options.ts'; - -export function formatIndexSignatureDef(node: LiteralIndexSignatureDef, options: FormatOption) { - let result = ''; - - result += formatReadonly(node, options); - - result += '['; - result += node.params.map(p => formatParam(p, options)).join(', '); - result += ']'; - - if (node.tsType != null) { - result += ': '; - result += formatType(node.tsType, options); - } - - return result; -} diff --git a/.scripts/docs/formatters/nodes/method.ts b/.scripts/docs/formatters/nodes/method.ts deleted file mode 100644 index 3549238617..0000000000 --- a/.scripts/docs/formatters/nodes/method.ts +++ /dev/null @@ -1,29 +0,0 @@ -import { LiteralMethodDef } from '@deno/doc'; -import { formatParam } from './param.ts'; -import { formatType } from './type.ts'; -import { FormatOption } from '../options.ts'; - -export function formatMethodDef(node: LiteralMethodDef, options: FormatOption) { - let result = ''; - - if (node.computed) { - result += `[${node.name}]`; - } else { - result += node.name; - } - - if (node.optional) { - result += '?'; - } - - result += '('; - result += node.params.map(x => formatParam(x, options)).join(', '); - result += ')'; - - if (node.returnType != null) { - result += ': '; - result += formatType(node.returnType, options); - } - - return result; -} diff --git a/.scripts/docs/formatters/nodes/object-pat-prop.ts b/.scripts/docs/formatters/nodes/object-pat-prop.ts deleted file mode 100644 index 92a74e80a4..0000000000 --- a/.scripts/docs/formatters/nodes/object-pat-prop.ts +++ /dev/null @@ -1,30 +0,0 @@ -import { ObjectPatPropDef } from '@deno/doc'; -import { formatParam } from './param.ts'; - -export function formatObjectPatProp(node: ObjectPatPropDef) { - switch (node.kind) { - case 'keyValue': { - return node.key; - } - case 'assign': { - let result = ''; - - result += node.key; - - if (node.value != null) { - result += ' = '; - result += node.value; - } - - return result; - } - case 'rest': { - let result = ''; - - result += '...'; - result += formatParam(node.arg); - - return result; - } - } -} diff --git a/.scripts/docs/formatters/nodes/param.ts b/.scripts/docs/formatters/nodes/param.ts deleted file mode 100644 index 268434c327..0000000000 --- a/.scripts/docs/formatters/nodes/param.ts +++ /dev/null @@ -1,101 +0,0 @@ -import { ParamDef } from '@deno/doc'; -import { formatObjectPatProp } from './object-pat-prop.ts'; -import { formatType } from './type.ts'; -import { FormatOption } from '../options.ts'; - -export function formatParam(node: ParamDef, options: FormatOption): string { - if (node.decorators != null) { - throw new Error(`Not implemented`); - } - - switch (node.kind) { - case 'array': { - let result = ''; - - result += '['; - - result += node.elements - .filter(x => x != null) - .map(item => { - return formatParam(item!, options); - }) - .join(', '); - - result += ']'; - - if (node.optional) { - result += '?'; - } - - if (node.tsType != null) { - result += ': '; - result += formatType(node.tsType, options); - } - - return result; - } - - case 'assign': { - let result = ''; - - result += formatParam(node.left, options); - - if (node.tsType != null) { - result += ': '; - result += formatType(node.tsType, options); - } - - return result; - } - - case 'identifier': { - let result = ''; - - result += node.name; - - if (node.optional) { - result += '?'; - } - - if (node.tsType != null) { - result += ': '; - result += formatType(node.tsType, options); - } - - return result; - } - - case 'object': { - let result = ''; - - result += '{'; - result += node.props.map(prop => formatObjectPatProp(prop)).join(', '); - result += '}'; - - if (node.optional) { - result += '?'; - } - - if (node.tsType != null) { - result += ': '; - result += formatType(node.tsType, options); - } - - return result; - } - - case 'rest': { - let result = ''; - - result += '...'; - result += formatParam(node.arg, options); - - if (node.tsType != null) { - result += ': '; - result += formatType(node.tsType, options); - } - - return result; - } - } -} diff --git a/.scripts/docs/formatters/nodes/property.ts b/.scripts/docs/formatters/nodes/property.ts deleted file mode 100644 index a1c0d8e5df..0000000000 --- a/.scripts/docs/formatters/nodes/property.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { LiteralPropertyDef } from '@deno/doc'; -import { formatType } from './type.ts'; -import { formatReadonly } from '../helpers/readonly.ts'; -import { FormatOption } from '../options.ts'; - -export function formatPropertyDef(node: LiteralPropertyDef, options: FormatOption) { - let result = ''; - - result += formatReadonly(node, options); - - if (node.computed) { - result += `[${node.name}]`; - } else { - result += node.name; - } - - if (node.optional) { - result += '?'; - } - - if (node.tsType != null) { - result += ': '; - result += formatType(node.tsType, options); - } - - return result; -} diff --git a/.scripts/docs/formatters/nodes/type-param.ts b/.scripts/docs/formatters/nodes/type-param.ts deleted file mode 100644 index b4ef735935..0000000000 --- a/.scripts/docs/formatters/nodes/type-param.ts +++ /dev/null @@ -1,21 +0,0 @@ -import { TsTypeParamDef } from '@deno/doc'; -import { formatType } from './type.ts'; -import { FormatOption } from '../options.ts'; - -export function formatTypeParam(node: TsTypeParamDef, options: FormatOption) { - let result = ''; - - result += node.name; - - if (node.constraint != null) { - result += ' extends '; - result += formatType(node.constraint, options); - } - - if (node.default != null) { - result += ' = '; - result += formatType(node.default, options); - } - - return result; -} diff --git a/.scripts/docs/formatters/nodes/type.ts b/.scripts/docs/formatters/nodes/type.ts deleted file mode 100644 index fb0b0c4ae3..0000000000 --- a/.scripts/docs/formatters/nodes/type.ts +++ /dev/null @@ -1,292 +0,0 @@ -import { TsTypeDef } from '@deno/doc'; -import { formatCallSignatureDef } from './call-signature.ts'; -import { formatIndexSignatureDef } from './index-signature.ts'; -import { formatMethodDef } from './method.ts'; -import { formatParam } from './param.ts'; -import { formatPropertyDef } from './property.ts'; -import { formatTypeParam } from './type-param.ts'; -import { formatReadonly } from '../helpers/readonly.ts'; -import { FormatOption } from '../options.ts'; - -export function formatType(node: TsTypeDef, options: FormatOption): string { - switch (node.kind) { - case 'array': { - switch (node.array.kind) { - case 'union': - case 'intersection': - return `Array<${formatType(node.array, options)}>`; - } - - return `${formatType(node.array, options)}[]`; - } - case 'conditional': { - let result = ''; - - result += formatType(node.conditionalType.checkType, options); - result += ' extends '; - result += formatType(node.conditionalType.extendsType, options); - result += ' ? '; - result += formatType(node.conditionalType.trueType, options); - result += ' : '; - result += formatType(node.conditionalType.falseType, options); - - return result; - } - case 'infer': { - let result = ''; - - result += 'infer '; - result += formatTypeParam(node.infer.typeParam, options); - - return result; - } - case 'importType': { - let result = ''; - - result += 'import('; - result += node.importType.specifier; - result += ')'; - - if (node.importType.qualifier != null) { - result += '.'; - result += node.importType.qualifier; - } - - if (node.importType.typeParams != null) { - result += '<'; - result += node.importType.typeParams.map(param => formatType(param, options)).join(', '); - result += '>'; - } - - return result; - } - case 'fnOrConstructor': { - let result = ''; - - if (node.fnOrConstructor.constructor) { - result += 'new '; - } - - result += '('; - result += node.fnOrConstructor.params.map(param => formatParam(param, options)).join(', '); - result += ')'; - - result += ' => '; - - result += formatType(node.fnOrConstructor.tsType, options); - - return result; - } - - case 'indexedAccess': { - let result = ''; - - result += formatType(node.indexedAccess.objType, options); - - result += '['; - result += formatType(node.indexedAccess.indexType, options); - result += ']'; - - return result; - } - - case 'intersection': { - return node.intersection.map(u => formatType(u, options)).join(' & '); - } - - case 'mapped': { - let result = ''; - - result += formatReadonly(node.mappedType, options); - - result += '['; - - if (node.mappedType.typeParam.constraint != null) { - result += node.mappedType.typeParam.name; - result += ' in '; - result += formatType(node.mappedType.typeParam.constraint, options); - } else { - result += formatTypeParam(node.mappedType.typeParam, options); - } - - if (node.mappedType.nameType != null) { - result += ' as '; - result += formatType(node.mappedType.nameType, options); - } - - result += ']'; - - switch (node.mappedType.optional) { - case true: { - result += '?'; - break; - } - case '+': { - result += '+?'; - break; - } - case '-': { - result += '-?'; - break; - } - } - - if (node.mappedType.tsType != null) { - result += ': '; - result += formatType(node.mappedType.tsType, options); - } - - return result; - } - - case 'keyword': { - return node.keyword; - } - - case 'literal': { - switch (node.literal.kind) { - case 'boolean': { - if (node.literal.boolean) { - return 'true'; - } else { - return 'false'; - } - } - - case 'string': { - return node.literal.string; - } - - case 'template': { - let result = ''; - - result += '`'; - - for (const tsType of node.literal.tsTypes) { - if (tsType.kind === 'literal') { - if (tsType.literal.kind === 'string') { - result += tsType.literal.string; - continue; - } - } - - result += '${'; - result += formatType(tsType, options); - result += '}'; - } - - result += '`'; - - return result; - } - - case 'number': { - return node.literal.number.toString(); - } - - case 'bigInt': { - return node.literal.string; - } - } - - throw new Error(`Not reachable`); - } - - case 'optional': { - return `${formatType(node.optional, options)}?`; - } - - case 'parenthesized': { - return `(${formatType(node.parenthesized, options)})`; - } - - case 'rest': { - return `...${formatType(node.rest, options)}`; - } - - case 'this': { - return `this`; - } - - case 'tuple': { - let result = ''; - - result += '['; - result += node.tuple.map(item => formatType(item, options)).join(', '); - result += ']'; - - return result; - } - - case 'typeLiteral': { - let result = ''; - - result += '{ '; - result += node.typeLiteral.callSignatures.map(sig => formatCallSignatureDef(sig, options)).join('; '); - result += node.typeLiteral.methods.map(m => formatMethodDef(m, options)).join('; '); - result += node.typeLiteral.properties.map(p => formatPropertyDef(p, options)).join('; '); - result += node.typeLiteral.indexSignatures - .map(indexSignature => formatIndexSignatureDef(indexSignature, options)) - .join('; '); - - result += result += ' }'; - - result += '}'; - - return result; - } - - case 'typeOperator': { - let result = ''; - - switch (node.typeOperator.operator) { - case 'readonly': { - if (!options.display?.readonly) { - break; - } - - result += node.typeOperator.operator; - result += ' '; - break; - } - default: { - result += node.typeOperator.operator; - result += ' '; - break; - } - } - - result += formatType(node.typeOperator.tsType, options); - - return result; - } - - case 'typeQuery': { - return `typeof ${node.typeQuery}`; - } - - case 'typeRef': { - let result = ''; - - result += node.typeRef.typeName; - - if (node.typeRef.typeParams != null) { - result += '<'; - result += node.typeRef.typeParams.map(p => formatType(p, options)).join(', '); - result += '>'; - } - - return result; - } - - case 'union': { - return node.union.map(u => formatType(u, options)).join(' | '); - } - - case 'typePredicate': { - return node.repr; - } - } - - throw new Error(`Unreachable`); -} diff --git a/.scripts/docs/formatters/options.ts b/.scripts/docs/formatters/options.ts deleted file mode 100644 index b03e35aeea..0000000000 --- a/.scripts/docs/formatters/options.ts +++ /dev/null @@ -1,5 +0,0 @@ -export interface FormatOption { - display?: { - readonly?: boolean; - }; -} diff --git a/.scripts/docs/generate-docs.mts b/.scripts/docs/generate-docs.mts deleted file mode 100644 index 7060cf0937..0000000000 --- a/.scripts/docs/generate-docs.mts +++ /dev/null @@ -1,133 +0,0 @@ -import path from 'node:path'; -import { fileURLToPath } from 'node:url'; -import { doc, DocNode } from '@deno/doc'; -import { differenceWith, groupBy } from '@es-toolkit/es-toolkit'; -import '@std/dotenv/load'; -import { render as renderEN } from './operations/render/en.ts'; -import { render as renderJA } from './operations/render/ja.ts'; -import { render as renderKO } from './operations/render/ko.ts'; -import { RenderOptions } from './operations/render/types.ts'; -import { render as renderZH } from './operations/render/zh_hans.ts'; -import { toDocumentationItem } from './operations/toDocumentationItem.ts'; -import { translate } from './operations/translate.ts'; -import { DocumentationItem } from './types/DocumentationItem.ts'; -import { Locale } from './types/Locale.ts'; - -// eslint-disable-next-line -const __dirname = path.dirname(fileURLToPath(import.meta.url)); - -const basePath = path.resolve(__dirname, '..', '..', 'src'); - -const openAiApiKey = Deno.env.get('OPENAI_API_KEY'); - -type DocumentationItems = Array<{ docPath: string; item: DocumentationItem }>; -type DocumentationPaths = Record; - -async function run() { - const docsRoot = path.resolve(__dirname, '..', '..', 'docs'); - - const docsPaths: DocumentationPaths = { - en: path.join(docsRoot, 'reference'), - ko: path.join(docsRoot, 'ko', 'reference'), - ja: path.join(docsRoot, 'ja', 'reference'), - zh_hans: path.join(docsRoot, 'zh_hans', 'reference'), - }; - - const items = toDocumentationItems(await doc(`file:${path.join(basePath, 'index.ts')}`)); - - await renderDocs(docsPaths, items); - - const compatItems = differenceWith( - toDocumentationItems(await doc(`file:${path.join(basePath, 'compat', 'index.ts')}`)), - items, - (x, y) => x.item.name === y.item.name - ); - - await renderDocs(docsPaths, compatItems, { compat: true }); -} - -async function renderDocs(docsPaths: DocumentationPaths, items: DocumentationItems, options: RenderOptions = {}) { - for (const { docPath, item } of items) { - console.log(`> Doc: ${docPath}`); - - const enPath = path.join(docsPaths.en, docPath); - - if (!(await exists(enPath))) { - console.log(`> Generating English docs for for: ${docPath}`); - await Deno.mkdir(path.dirname(enPath), { recursive: true }); - await Deno.writeTextFile(enPath, renderEN(item, options)); - } - - const koPath = path.join(docsPaths.ko, docPath); - - if (!(await exists(koPath))) { - console.log(`> Generating Korean docs for for: ${docPath}`); - - const koreanItem = openAiApiKey != null ? await translate(item, 'ko', { openAiApiKey }) : item; - await Deno.mkdir(path.dirname(koPath), { recursive: true }); - await Deno.writeTextFile(koPath, renderKO(koreanItem, options)); - } - - const jaPath = path.join(docsPaths.ja, docPath); - - if (!(await exists(jaPath))) { - console.log(`> Generating Japanese docs for for: ${docPath}`); - - const japaneseItem = openAiApiKey != null ? await translate(item, 'ja', { openAiApiKey }) : item; - - await Deno.mkdir(path.dirname(jaPath), { recursive: true }); - await Deno.writeTextFile(jaPath, renderJA(japaneseItem, options)); - } - - const zhPath = path.join(docsPaths.zh_hans, docPath); - - if (!(await exists(zhPath))) { - console.log(`> Generating Simplified Chinese docs for for: ${docPath}`); - - const zhItem = openAiApiKey != null ? await translate(item, 'zh_hans', { openAiApiKey }) : item; - - await Deno.mkdir(path.dirname(zhPath), { recursive: true }); - await Deno.writeTextFile(zhPath, renderZH(zhItem, options)); - } - } -} - -async function exists(path: string): Promise { - try { - await Deno.stat(path); - return true; - } catch (error) { - if (error instanceof Deno.errors.NotFound) { - return false; - } - throw error; // rethrow other errors - } -} - -function toDocumentationItems(docs: DocNode[]): DocumentationItems { - const entries = Object.entries(groupBy(docs, x => x.name)); - - return entries - .filter(([name, entries]) => { - if (name === '') { - return false; - } - - if (entries.some(x => x.kind !== 'class' && x.kind !== 'function')) { - return false; - } - - return true; - }) - .map(([name, entries]) => { - const sourcePath = fileURLToPath(entries[0].location.filename); - const docPath: string = path.join(path.dirname(path.relative(basePath, sourcePath)), `${name}.md`); - - return { - docPath: docPath, - item: toDocumentationItem(name, entries), - }; - }); -} - -run(); diff --git a/.scripts/docs/operations/render/en.ts b/.scripts/docs/operations/render/en.ts deleted file mode 100644 index 3c8e4a728b..0000000000 --- a/.scripts/docs/operations/render/en.ts +++ /dev/null @@ -1,84 +0,0 @@ -import { RenderOptions } from './types.ts'; -import { DocumentationItem } from '../../types/DocumentationItem.ts'; - -export function render(item: DocumentationItem, options: RenderOptions = {}) { - return [title(item.name), compatNotice(options), item.description, signature(item), examples(item)] - .filter(x => x != null) - .join('\n\n'); -} - -function title(name: string) { - return `# ${name}`; -} - -function compatNotice(options: RenderOptions) { - if (!options.compat) { - return null; - } - - return ` -::: info -This function is only available in \`es-toolkit/compat\` for compatibility reasons. It either has alternative native JavaScript APIs or isn’t fully optimized yet. - -When imported from \`es-toolkit/compat\`, it behaves exactly like lodash and provides the same functionalities, as detailed [here](../../../compatibility.md). -::: -`.trim(); -} - -function signature(item: DocumentationItem) { - return ['## Signature', symbolInterface(item), parameters(item), returns(item)].filter(x => x != null).join('\n\n'); -} - -function symbolInterface(item: DocumentationItem): string { - return ` -\`\`\`typescript -${item.signature} -\`\`\` -`.trim(); -} - -function parameters(item: DocumentationItem) { - if (item.parameters == null) { - return null; - } - - return ` -### Parameters - -${item.parameters.map(p => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`).join('\n')} - `.trim(); -} - -function returns(item: DocumentationItem) { - if (item.returns == null) { - return null; - } - - if (item.returns.type == null) { - return ` -#### Returns - -(\`${item.returns.type}\`): ${item.returns.document} - `.trim(); - } - - return ` -#### Returns - -(\`${item.returns.type}\`): ${item.returns.document} - `.trim(); -} - -function examples(item: DocumentationItem) { - if (item.exampleCodes.length === 0) { - return null; - } - - return ` -## Examples - -\`\`\`typescript -${item.exampleCodes.join('\n\n')} -\`\`\` - `.trim(); -} diff --git a/.scripts/docs/operations/render/ja.ts b/.scripts/docs/operations/render/ja.ts deleted file mode 100644 index 7fbb91db1b..0000000000 --- a/.scripts/docs/operations/render/ja.ts +++ /dev/null @@ -1,78 +0,0 @@ -import { RenderOptions } from './types.ts'; -import { DocumentationItem } from '../../types/DocumentationItem.ts'; - -export function render(item: DocumentationItem, options: RenderOptions = {}) { - return [title(item.name), compatNotice(options), item.description, signature(item), examples(item)] - .filter(x => x != null) - .join('\n\n'); -} - -function title(name: string) { - return `# ${name}`; -} - -function compatNotice(options: RenderOptions) { - if (!options.compat) { - return null; - } - - return ` -::: info -この関数は互換性のために \`es-toolkit/compat\` からのみインポートできます。代替可能なネイティブ JavaScript API があるか、まだ十分に最適化されていないためです。 - -\`es-toolkit/compat\` からこの関数をインポートすると、[lodash と完全に同じように動作](../../../compatibility.md)します。 -::: -`.trim(); -} - -function signature(item: DocumentationItem) { - return ['## インターフェース', symbolInterface(item), parameters(item), returns(item)] - .filter(x => x != null) - .join('\n\n'); -} - -function symbolInterface(item: DocumentationItem): string { - return ` -\`\`\`typescript -${item.signature} -\`\`\` -`.trim(); -} - -function parameters(item: DocumentationItem) { - if (item.parameters == null) { - return null; - } - - return ` -### パラメータ - -${item.parameters.map(p => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`).join('\n')} - `.trim(); -} - -function returns(item: DocumentationItem) { - if (item.returns == null) { - return null; - } - - return ` -#### 戻り値 - -(\`${item.returns.type}\`): ${item.returns.document} - `.trim(); -} - -function examples(item: DocumentationItem) { - if (item.exampleCodes.length === 0) { - return null; - } - - return ` -## 例 - -\`\`\`typescript -${item.exampleCodes.join('\n\n')} -\`\`\` - `.trim(); -} diff --git a/.scripts/docs/operations/render/ko.ts b/.scripts/docs/operations/render/ko.ts deleted file mode 100644 index f3ffd2fb3f..0000000000 --- a/.scripts/docs/operations/render/ko.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { RenderOptions } from './types.ts'; -import { DocumentationItem } from '../../types/DocumentationItem.ts'; - -export function render(item: DocumentationItem, options: RenderOptions = {}) { - return [title(item.name), compatNotice(options), item.description, signature(item), examples(item)] - .filter(x => x != null) - .join('\n\n'); -} - -function title(name: string) { - return `# ${name}`; -} - -function compatNotice(options: RenderOptions) { - if (!options.compat) { - return null; - } - - return ` -::: info -이 함수는 호환성을 위한 \`es-toolkit/compat\` 에서만 가져올 수 있어요. 대체할 수 있는 네이티브 JavaScript API가 있거나, 아직 충분히 최적화되지 않았기 때문이에요. - -\`es-toolkit/compat\`에서 이 함수를 가져오면, [lodash와 완전히 똑같이 동작](../../../compatibility.md)해요. -::: -`.trim(); -} - -function signature(item: DocumentationItem) { - return ['## 인터페이스', symbolInterface(item), parameters(item), returns(item)].filter(x => x != null).join('\n\n'); -} - -function symbolInterface(item: DocumentationItem): string { - return ` -\`\`\`typescript -${item.signature} -\`\`\` -`.trim(); -} - -function parameters(item: DocumentationItem) { - if (item.parameters == null) { - return null; - } - - return ` -### 파라미터 - -${item.parameters.map(p => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`).join('\n')} - `.trim(); -} - -function returns(item: DocumentationItem) { - if (item.returns == null) { - return null; - } - - return ` -#### 반환 값 - -(\`${item.returns.type}\`): ${item.returns.document} - `.trim(); -} - -function examples(item: DocumentationItem) { - if (item.exampleCodes.length === 0) { - return null; - } - - return ` -## 예시 - -\`\`\`typescript -${item.exampleCodes.join('\n\n')} -\`\`\` - `.trim(); -} diff --git a/.scripts/docs/operations/render/types.ts b/.scripts/docs/operations/render/types.ts deleted file mode 100644 index cb727ae288..0000000000 --- a/.scripts/docs/operations/render/types.ts +++ /dev/null @@ -1,3 +0,0 @@ -export interface RenderOptions { - compat?: boolean; -} diff --git a/.scripts/docs/operations/render/zh_hans.ts b/.scripts/docs/operations/render/zh_hans.ts deleted file mode 100644 index 98ac79af95..0000000000 --- a/.scripts/docs/operations/render/zh_hans.ts +++ /dev/null @@ -1,76 +0,0 @@ -import { RenderOptions } from './types.ts'; -import { DocumentationItem } from '../../types/DocumentationItem.ts'; - -export function render(item: DocumentationItem, options: RenderOptions = {}) { - return [title(item.name), compatNotice(options), item.description, signature(item), examples(item)] - .filter(x => x != null) - .join('\n\n'); -} - -function title(name: string) { - return `# ${name}`; -} - -function compatNotice(options: RenderOptions) { - if (!options.compat) { - return null; - } - - return ` -::: info -出于兼容性原因,此函数仅在 \`es-toolkit/compat\` 中提供。它可能具有替代的原生 JavaScript API,或者尚未完全优化。 - -从 \`es-toolkit/compat\` 导入时,它的行为与 lodash 完全一致,并提供相同的功能,详情请见 [这里](../../../compatibility.md)。 -::: -`.trim(); -} - -function signature(item: DocumentationItem) { - return ['## 签名', symbolInterface(item), parameters(item), returns(item)].filter(x => x != null).join('\n\n'); -} - -function symbolInterface(item: DocumentationItem): string { - return ` -\`\`\`typescript -${item.signature} -\`\`\` -`.trim(); -} - -function parameters(item: DocumentationItem) { - if (item.parameters == null) { - return null; - } - - return ` -### 参数 - -${item.parameters.map(p => `- \`${p.name}\` (\`${p.type}\`): ${p.document}`).join('\n')} - `.trim(); -} - -function returns(item: DocumentationItem) { - if (item.returns == null) { - return null; - } - - return ` -#### 返回值 - -(\`${item.returns.type}\`): ${item.returns.document} - `.trim(); -} - -function examples(item: DocumentationItem) { - if (item.exampleCodes.length === 0) { - return null; - } - - return ` -## 示例 - -\`\`\`typescript -${item.exampleCodes.join('\n\n')} -\`\`\` - `.trim(); -} diff --git a/.scripts/docs/operations/toDocumentationItem.ts b/.scripts/docs/operations/toDocumentationItem.ts deleted file mode 100644 index c99fa8627d..0000000000 --- a/.scripts/docs/operations/toDocumentationItem.ts +++ /dev/null @@ -1,122 +0,0 @@ -import { DocNode, JsDocTag, JsDocTagDocRequired, JsDocTagParam, JsDocTagReturn } from '@deno/doc'; -import { formatClassDoc } from '../formatters/class.ts'; -import { formatFunctionDoc } from '../formatters/function.ts'; -import { DocumentationItem } from '../types/DocumentationItem.ts'; - -export function toDocumentationItem(symbolName: string, docs: DocNode[]): DocumentationItem { - const lastDoc = docs.at(-1) ?? docs.at(0); - const tags = lastDoc?.jsDoc?.tags ?? []; - - const description = lastDoc?.jsDoc?.doc; - - if (description == null) { - throw new Error( - `No description provided for ${symbolName} (${lastDoc?.location.filename}:${lastDoc?.location.line}:${lastDoc?.location.col}).` - ); - } - - return { - name: symbolName, - description: description.trim(), - signature: toSignature(symbolName, docs), - parameters: toParameters(symbolName, tags), - returns: toReturns(symbolName, tags), - exampleCodes: toExampleCodes(tags), - }; -} - -function toSignature(symbolName: string, docs: DocNode[]) { - if (docs.length === 0) { - throw new Error(`No document provided for ${symbolName}.`); - } - - switch (docs[0].kind) { - case 'function': { - return toFunctionSignature(symbolName, docs); - } - case 'class': { - return toClassSignature(symbolName, docs); - } - } - - throw new Error(`Unsupported document node type: ${docs[0].kind}`); -} - -function toFunctionSignature(symbolName: string, docs: DocNode[]) { - return docs - .map(doc => { - if (doc.kind !== 'function') { - throw new Error(`Unsupported document type in ${symbolName}: ${doc.kind}`); - } - - return `${formatFunctionDoc(doc, { display: { readonly: false } })};`; - }) - .join('\n'); -} - -function toClassSignature(symbolName: string, docs: DocNode[]) { - return docs - .map(doc => { - if (doc.kind !== 'class') { - throw new Error(`Unsupported document type in ${symbolName}: ${doc.kind}`); - } - - return `${formatClassDoc(doc, { display: { readonly: false } })}`; - }) - .join('\n'); -} - -function toParameters(symbolName: string, tags: JsDocTag[]): DocumentationItem['parameters'] { - const parameters = tags.filter((tag): tag is JsDocTagParam => tag.kind === 'param'); - - if (parameters.length === 0) { - return null; - } - - return parameters.map(param => { - if (param.name == null) { - throw new Error(`parameter name is not provided in ${symbolName}.`); - } - - if (param.type == null) { - throw new Error(`parameter type is not provided in ${symbolName}. (for parameter ${param.name})`); - } - - if (param.doc == null) { - throw new Error(`parameter doc is not provided in ${symbolName}. (for parameter ${param.name})`); - } - - return { - name: param.name, - type: param.type, - document: param.doc.replace(/^- /g, ''), - }; - }); -} - -function toReturns(symbolName: string, tags: JsDocTag[]): DocumentationItem['returns'] { - const returns = tags.filter((x): x is JsDocTagReturn => x.kind === 'return')[0]; - - if (returns == null) { - return null; - } - - if (returns.doc == null) { - throw new Error(`returns.doc is not provided in ${symbolName}.`); - } - - return { - type: returns.type ?? null, - document: returns.doc.replace(/^- /g, ''), - }; -} - -function toExampleCodes(tags: JsDocTag[]) { - const examples = tags.filter((x): x is JsDocTagDocRequired => x.kind === 'example'); - - if (examples.length === 0) { - return []; - } - - return examples.map(x => x.doc.trim()); -} diff --git a/.scripts/docs/operations/translate.ts b/.scripts/docs/operations/translate.ts deleted file mode 100644 index 188dce1cd1..0000000000 --- a/.scripts/docs/operations/translate.ts +++ /dev/null @@ -1,55 +0,0 @@ -import OpenAI from 'openai'; -import { pick, toMerged } from '@es-toolkit/es-toolkit'; -import { DocumentationItem } from '../types/DocumentationItem.ts'; -import { Locale } from '../types/Locale.ts'; - -interface TranslateOptions { - openAiApiKey: string; -} - -export async function translate( - doc: DocumentationItem, - locale: Locale, - { openAiApiKey }: TranslateOptions -): Promise { - const client = new OpenAI({ - apiKey: openAiApiKey, - }); - - const item = { - description: doc.description, - parameters: doc.parameters?.map(param => { - return pick(param, ['document']); - }), - returns: pick(doc.returns! ?? {}, ['document']), - }; - - const prompt = ` -Always answer in the JSON format as given in the input, without triple backticks. -Translate the following JSON to ${locale}. - -If translating in Korean, write the sentence in 해요 style. -If translating in Japanese, finish the sentence in ます style. -Finish with a noun if it is a explanation for a parameter or a return value. - -=== -\`\`\` -${JSON.stringify(item, null, 2)} -\`\`\` - `; - - const response = await client.chat.completions.create({ - model: 'gpt-4o', - messages: [{ role: 'user', content: prompt }], - }); - - const translatedItem = response.choices[0].message.content; - - if (translatedItem == null) { - throw new Error(`API Error while translating ${doc.name} to ${locale}.`); - } - - const translatedDoc: DocumentationItem = JSON.parse(translatedItem); - - return toMerged(doc, translatedDoc); -} diff --git a/.scripts/docs/types/DocumentationItem.ts b/.scripts/docs/types/DocumentationItem.ts deleted file mode 100644 index 3ec79594f3..0000000000 --- a/.scripts/docs/types/DocumentationItem.ts +++ /dev/null @@ -1,15 +0,0 @@ -export interface DocumentationItem { - name: string; - description: string; - signature: string; - parameters: Array<{ - name: string; - type: string; - document: string; - }> | null; - returns: { - type: string | null; - document: string; - } | null; - exampleCodes: string[]; -} diff --git a/.scripts/docs/types/Locale.ts b/.scripts/docs/types/Locale.ts deleted file mode 100644 index f50b8692fb..0000000000 --- a/.scripts/docs/types/Locale.ts +++ /dev/null @@ -1 +0,0 @@ -export type Locale = 'en' | 'ko' | 'ja' | 'zh_hans'; diff --git a/.vscode/settings.json b/.vscode/settings.json index 0c1f7c833e..f25ce75403 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -8,8 +8,6 @@ "prettier.prettierPath": ".yarn/sdks/prettier/index.cjs", "typescript.tsdk": ".yarn/sdks/typescript/lib", "typescript.enablePromptUseWorkspaceTsdk": true, - "deno.enablePaths": ["./.scripts/docs"], - "deno.config": "./.scripts/docs/deno.json", "editor.defaultFormatter": "esbenp.prettier-vscode", "editor.formatOnSave": true, "editor.codeActionsOnSave": { diff --git a/tsconfig.json b/tsconfig.json index b833722cc5..749ab0e790 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -12,5 +12,5 @@ "skipLibCheck": true }, "include": ["src", ".scripts/**/*", "**/*.spec.ts"], - "exclude": [".scripts/docs/**/*", "tests/types/**/*"] + "exclude": ["tests/types/**/*"] }