commit b2fb73fd2ae090be19fa51b74628af48b8dc3999 Author: James Brumond Date: Sat May 13 18:44:28 2023 -0700 first commit diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..9653646 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,14 @@ + +root = true + +[*] +indent_size = 4 +indent_style = tab + +[*.{js,ts,css,html}] +indent_size = 4 +indent_style = tab + +[*.{md,json,jsonc,yml,yaml,sql}] +indent_size = 2 +indent_style = space diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..dd87e2d --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +node_modules +build diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..3d88fc1 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,851 @@ +{ + "name": "@doc-utils/jsonschema2markdown", + "version": "0.1.0", + "lockfileVersion": 2, + "requires": true, + "packages": { + "": { + "name": "@doc-utils/jsonschema2markdown", + "version": "0.1.0", + "dependencies": { + "glob": "^10.2.2", + "luxon": "^3.3.0", + "mustache": "^4.2.0", + "yaml": "^2.2.2" + }, + "bin": { + "docs2website": "bin/docs2website" + }, + "devDependencies": { + "@types/luxon": "^3.1.0", + "@types/mustache": "^4.2.2", + "@types/node": "^18.16.3", + "typescript": "^5.0.4" + } + }, + "node_modules/@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "dependencies": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + }, + "engines": { + "node": ">=12" + } + }, + "node_modules/@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "optional": true, + "engines": { + "node": ">=14" + } + }, + "node_modules/@types/luxon": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.0.tgz", + "integrity": "sha512-uKRI5QORDnrGFYgcdAVnHvEIvEZ8noTpP/Bg+HeUzZghwinDlIS87DEenV5r1YoOF9G4x600YsUXLWZ19rmTmg==", + "dev": true + }, + "node_modules/@types/mustache": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.2.2.tgz", + "integrity": "sha512-MUSpfpW0yZbTgjekDbH0shMYBUD+X/uJJJMm9LXN1d5yjl5lCY1vN/eWKD6D1tOtjA6206K0zcIPnUaFMurdNA==", + "dev": true + }, + "node_modules/@types/node": { + "version": "18.16.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.9.tgz", + "integrity": "sha512-IeB32oIV4oGArLrd7znD2rkHQ6EDCM+2Sr76dJnrHwv9OHBTTM6nuDLK9bmikXzPa0ZlWMWtRGo/Uw4mrzQedA==", + "dev": true + }, + "node_modules/ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-regex?sponsor=1" + } + }, + "node_modules/ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "node_modules/brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "dependencies": { + "balanced-match": "^1.0.0" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "node_modules/cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dependencies": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" + }, + "node_modules/emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" + }, + "node_modules/foreground-child": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "dependencies": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/glob": { + "version": "10.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.2.3.tgz", + "integrity": "sha512-Kb4rfmBVE3eQTAimgmeqc2LwSnN0wIOkkUL6HmxEFxNJ4fHghYHVbFba/HcGcRjE6s9KoMNK3rSOwkL4PioZjg==", + "dependencies": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.0.3", + "minimatch": "^9.0.0", + "minipass": "^5.0.0", + "path-scurry": "^1.7.0" + }, + "bin": { + "glob": "dist/cjs/src/bin.js" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "engines": { + "node": ">=8" + } + }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "node_modules/jackspeak": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.2.0.tgz", + "integrity": "sha512-r5XBrqIJfwRIjRt/Xr5fv9Wh09qyhHfKnYddDlpM+ibRR20qrYActpCAgU6U+d53EOEjzkvxPMVHSlgR7leXrQ==", + "dependencies": { + "@isaacs/cliui": "^8.0.2" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + }, + "optionalDependencies": { + "@pkgjs/parseargs": "^0.11.0" + } + }, + "node_modules/lru-cache": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-9.1.1.tgz", + "integrity": "sha512-65/Jky17UwSb0BuB9V+MyDpsOtXKmYwzhyl+cOa9XUiI4uV2Ouy/2voFP3+al0BjZbJgMBD8FojMpAf+Z+qn4A==", + "engines": { + "node": "14 || >=16.14" + } + }, + "node_modules/luxon": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.3.0.tgz", + "integrity": "sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==", + "engines": { + "node": ">=12" + } + }, + "node_modules/minimatch": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.0.tgz", + "integrity": "sha512-0jJj8AvgKqWN05mrwuqi8QYKx1WmYSUoKSxu5Qhs9prezTz10sxAHGNZe9J9cqIJzta8DWsleh2KaVaLl6Ru2w==", + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/mustache": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", + "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==", + "bin": { + "mustache": "bin/mustache" + } + }, + "node_modules/path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "engines": { + "node": ">=8" + } + }, + "node_modules/path-scurry": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.8.0.tgz", + "integrity": "sha512-IjTrKseM404/UAWA8bBbL3Qp6O2wXkanuIE3seCxBH7ctRuvH1QRawy1N3nVDHGkdeZsjOsSe/8AQBL/VQCy2g==", + "dependencies": { + "lru-cache": "^9.1.1", + "minipass": "^5.0.0" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dependencies": { + "shebang-regex": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "engines": { + "node": ">=8" + } + }, + "node_modules/signal-exit": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz", + "integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==", + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "dependencies": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/string-width-cjs": { + "name": "string-width", + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/string-width-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/string-width-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz", + "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==", + "dependencies": { + "ansi-regex": "^6.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/strip-ansi?sponsor=1" + } + }, + "node_modules/strip-ansi-cjs": { + "name": "strip-ansi", + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/strip-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/typescript": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=12.20" + } + }, + "node_modules/which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "node-which": "bin/node-which" + }, + "engines": { + "node": ">= 8" + } + }, + "node_modules/wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "dependencies": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + }, + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs": { + "name": "wrap-ansi", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dependencies": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/wrap-ansi?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==", + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "node_modules/wrap-ansi-cjs/node_modules/string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "dependencies": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/wrap-ansi-cjs/node_modules/strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "dependencies": { + "ansi-regex": "^5.0.1" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/yaml": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", + "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==", + "engines": { + "node": ">= 14" + } + } + }, + "dependencies": { + "@isaacs/cliui": { + "version": "8.0.2", + "resolved": "https://registry.npmjs.org/@isaacs/cliui/-/cliui-8.0.2.tgz", + "integrity": "sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==", + "requires": { + "string-width": "^5.1.2", + "string-width-cjs": "npm:string-width@^4.2.0", + "strip-ansi": "^7.0.1", + "strip-ansi-cjs": "npm:strip-ansi@^6.0.1", + "wrap-ansi": "^8.1.0", + "wrap-ansi-cjs": "npm:wrap-ansi@^7.0.0" + } + }, + "@pkgjs/parseargs": { + "version": "0.11.0", + "resolved": "https://registry.npmjs.org/@pkgjs/parseargs/-/parseargs-0.11.0.tgz", + "integrity": "sha512-+1VkjdD0QBLPodGrJUeqarH8VAIvQODIbwh9XpP5Syisf7YoQgsJKPNFoqqLQlu+VQ/tVSshMR6loPMn8U+dPg==", + "optional": true + }, + "@types/luxon": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/@types/luxon/-/luxon-3.3.0.tgz", + "integrity": "sha512-uKRI5QORDnrGFYgcdAVnHvEIvEZ8noTpP/Bg+HeUzZghwinDlIS87DEenV5r1YoOF9G4x600YsUXLWZ19rmTmg==", + "dev": true + }, + "@types/mustache": { + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/@types/mustache/-/mustache-4.2.2.tgz", + "integrity": "sha512-MUSpfpW0yZbTgjekDbH0shMYBUD+X/uJJJMm9LXN1d5yjl5lCY1vN/eWKD6D1tOtjA6206K0zcIPnUaFMurdNA==", + "dev": true + }, + "@types/node": { + "version": "18.16.9", + "resolved": "https://registry.npmjs.org/@types/node/-/node-18.16.9.tgz", + "integrity": "sha512-IeB32oIV4oGArLrd7znD2rkHQ6EDCM+2Sr76dJnrHwv9OHBTTM6nuDLK9bmikXzPa0ZlWMWtRGo/Uw4mrzQedA==", + "dev": true + }, + "ansi-regex": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-6.0.1.tgz", + "integrity": "sha512-n5M855fKb2SsfMIiFFoVrABHJC8QtHwVx+mHWP3QcEqBHYienj5dHSgjbxtC0WEZXYt4wcD6zrQElDPhFuZgfA==" + }, + "ansi-styles": { + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-6.2.1.tgz", + "integrity": "sha512-bN798gFfQX+viw3R7yrGWRqnrN2oRkEkUjjl4JNn4E8GxxbjtG3FbrEIIY3l8/hrwUwIeCZvi4QuOTP4MErVug==" + }, + "balanced-match": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz", + "integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==" + }, + "brace-expansion": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz", + "integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==", + "requires": { + "balanced-match": "^1.0.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "eastasianwidth": { + "version": "0.2.0", + "resolved": "https://registry.npmjs.org/eastasianwidth/-/eastasianwidth-0.2.0.tgz", + "integrity": "sha512-I88TYZWc9XiYHRQ4/3c5rjjfgkjhLyW2luGIheGERbNQ6OY7yTybanSpDXZa8y7VUP9YmDcYa+eyq4ca7iLqWA==" + }, + "emoji-regex": { + "version": "9.2.2", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz", + "integrity": "sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==" + }, + "foreground-child": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-3.1.1.tgz", + "integrity": "sha512-TMKDUnIte6bfb5nWv7V/caI169OHgvwjb7V4WkeUvbQQdjr5rWKqHFiKWb/fcOwB+CzBT+qbWjvj+DVwRskpIg==", + "requires": { + "cross-spawn": "^7.0.0", + "signal-exit": "^4.0.1" + } + }, + "glob": { + "version": "10.2.3", + "resolved": "https://registry.npmjs.org/glob/-/glob-10.2.3.tgz", + "integrity": "sha512-Kb4rfmBVE3eQTAimgmeqc2LwSnN0wIOkkUL6HmxEFxNJ4fHghYHVbFba/HcGcRjE6s9KoMNK3rSOwkL4PioZjg==", + "requires": { + "foreground-child": "^3.1.0", + "jackspeak": "^2.0.3", + "minimatch": "^9.0.0", + "minipass": "^5.0.0", + "path-scurry": "^1.7.0" + } + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==" + }, + "jackspeak": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/jackspeak/-/jackspeak-2.2.0.tgz", + "integrity": "sha512-r5XBrqIJfwRIjRt/Xr5fv9Wh09qyhHfKnYddDlpM+ibRR20qrYActpCAgU6U+d53EOEjzkvxPMVHSlgR7leXrQ==", + "requires": { + "@isaacs/cliui": "^8.0.2", + "@pkgjs/parseargs": "^0.11.0" + } + }, + "lru-cache": { + "version": "9.1.1", + "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-9.1.1.tgz", + "integrity": "sha512-65/Jky17UwSb0BuB9V+MyDpsOtXKmYwzhyl+cOa9XUiI4uV2Ouy/2voFP3+al0BjZbJgMBD8FojMpAf+Z+qn4A==" + }, + "luxon": { + "version": "3.3.0", + "resolved": "https://registry.npmjs.org/luxon/-/luxon-3.3.0.tgz", + "integrity": "sha512-An0UCfG/rSiqtAIiBPO0Y9/zAnHUZxAMiCpTd5h2smgsj7GGmcenvrvww2cqNA8/4A5ZrD1gJpHN2mIHZQF+Mg==" + }, + "minimatch": { + "version": "9.0.0", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-9.0.0.tgz", + "integrity": "sha512-0jJj8AvgKqWN05mrwuqi8QYKx1WmYSUoKSxu5Qhs9prezTz10sxAHGNZe9J9cqIJzta8DWsleh2KaVaLl6Ru2w==", + "requires": { + "brace-expansion": "^2.0.1" + } + }, + "minipass": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-5.0.0.tgz", + "integrity": "sha512-3FnjYuehv9k6ovOEbyOswadCDPX1piCfhV8ncmYtHOjuPwylVWsghTLo7rabjC3Rx5xD4HDx8Wm1xnMF7S5qFQ==" + }, + "mustache": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/mustache/-/mustache-4.2.0.tgz", + "integrity": "sha512-71ippSywq5Yb7/tVYyGbkBggbU8H3u5Rz56fH60jGFgr8uHwxs+aSKeqmluIVzM0m0kB7xQjKS6qPfd0b2ZoqQ==" + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==" + }, + "path-scurry": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/path-scurry/-/path-scurry-1.8.0.tgz", + "integrity": "sha512-IjTrKseM404/UAWA8bBbL3Qp6O2wXkanuIE3seCxBH7ctRuvH1QRawy1N3nVDHGkdeZsjOsSe/8AQBL/VQCy2g==", + "requires": { + "lru-cache": "^9.1.1", + "minipass": "^5.0.0" + } + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==" + }, + "signal-exit": { + "version": "4.0.2", + "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-4.0.2.tgz", + "integrity": "sha512-MY2/qGx4enyjprQnFaZsHib3Yadh3IXyV2C321GY0pjGfVBu4un0uDJkwgdxqO+Rdx8JMT8IfJIRwbYVz3Ob3Q==" + }, + "string-width": { + "version": "5.1.2", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-5.1.2.tgz", + "integrity": "sha512-HnLOCR3vjcY8beoNLtcjZ5/nxn2afmME6lhrDrebokqMap+XbeW8n9TXpPDOqdGK5qcI3oT0GKTW6wC7EMiVqA==", + "requires": { + "eastasianwidth": "^0.2.0", + "emoji-regex": "^9.2.2", + "strip-ansi": "^7.0.1" + } + }, + "string-width-cjs": { + "version": "npm:string-width@4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, + "strip-ansi": { + "version": "7.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-7.0.1.tgz", + "integrity": "sha512-cXNxvT8dFNRVfhVME3JAe98mkXDYN2O1l7jmcwMnOslDeESg1rF/OZMtK0nRAhiari1unG5cD4jG3rapUAkLbw==", + "requires": { + "ansi-regex": "^6.0.1" + } + }, + "strip-ansi-cjs": { + "version": "npm:strip-ansi@6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + } + } + }, + "typescript": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.0.4.tgz", + "integrity": "sha512-cW9T5W9xY37cc+jfEnaUvX91foxtHkza3Nw3wkoF4sSlKn0MONdkdEndig/qPBWXNkmplh3NzayQzCiHM4/hqw==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "requires": { + "isexe": "^2.0.0" + } + }, + "wrap-ansi": { + "version": "8.1.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-8.1.0.tgz", + "integrity": "sha512-si7QWI6zUMq56bESFvagtmzMdGOtoxfR+Sez11Mobfc7tm+VkUckk9bW2UeffTGVUbOksxmSw0AA2gs8g71NCQ==", + "requires": { + "ansi-styles": "^6.1.0", + "string-width": "^5.0.1", + "strip-ansi": "^7.0.1" + } + }, + "wrap-ansi-cjs": { + "version": "npm:wrap-ansi@7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.1", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz", + "integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "string-width": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", + "integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.1" + } + }, + "strip-ansi": { + "version": "6.0.1", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", + "integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==", + "requires": { + "ansi-regex": "^5.0.1" + } + } + } + }, + "yaml": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.2.2.tgz", + "integrity": "sha512-CBKFWExMn46Foo4cldiChEzn7S7SRV+wqiluAb6xmueD/fGyRHIhX8m14vVGgeFWjN540nKCNVj6P21eQjgTuA==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..584b93d --- /dev/null +++ b/package.json @@ -0,0 +1,27 @@ +{ + "name": "@doc-utils/jsonschema2markdown", + "version": "0.1.0", + "publishConfig": { + "registry": "https://gitea.home.jbrumond.me/api/packages/doc-utils/npm/" + }, + "scripts": { + "tsc": "tsc", + "clean": "rm -rf ./build ./www" + }, + "bin": { + "docs2website": "./bin/docs2website" + }, + "main": "./build/index.js", + "devDependencies": { + "@types/luxon": "^3.1.0", + "@types/mustache": "^4.2.2", + "@types/node": "^18.16.3", + "typescript": "^5.0.4" + }, + "dependencies": { + "glob": "^10.2.2", + "luxon": "^3.3.0", + "mustache": "^4.2.0", + "yaml": "^2.2.2" + } +} diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..3e7f258 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,575 @@ + +// import * as wrap from 'word-wrap'; +// import { JSONSchema7 } from 'json-schema'; +// import { JSONSchema, JSONSchemaDefinition, SchemaDoc } from '../../documents'; +// import { MarkdownBuilder } from './builder'; +// import { JsonPointer } from '../../utils'; +// import { render_document_formats } from './formats-section'; + +// const indent_with = ' '; + +export function build_markdown_from_json_schema(/* json_schema: SchemaDoc */) /* : string */ { } +// const schema = json_schema.data; +// const doc = new MarkdownBuilder({ +// numbered_headings: false, +// }); + +// doc.h1(schema.title, { id: '/title' }); + +// if (schema.description) { +// doc.p(schema.description); +// } + +// render_document_formats(doc, json_schema.json_media_type, { +// json: json_schema.json_media_type, +// yaml: json_schema.yaml_media_type, +// }); + +// doc.h2('Schema', { id: '/' }); + +// const close_block = doc.code_block({ lang: 'clike' }); +// doc.raw(render_type(schema) + '\n\n'); +// close_block(); + +// if (schema.definitions) { +// const ptr = new JsonPointer([ 'definitions' ]); + +// doc.h2('Definitions', { id: ptr.as_md_str() }); + +// for (const [ name, type ] of Object.entries(schema.definitions) as [ string, JSONSchemaDefinition ][]) { +// if (name === '//') { +// continue; +// } + +// doc.h3(name, { id: ptr.step_down(name).as_md_str() }); + +// const close_block = doc.code_block({ lang: 'clike' }); +// doc.raw(render_comment_if_needed(type) + 'def ' + name + ': ' + render_type(type) + '\n'); +// close_block(); +// } +// } + +// return doc.as_str(); +// } + +// function render_comment_if_needed(obj: JSONSchema | boolean, indent_depth = 0) { +// if (typeof obj === 'boolean') { +// return ''; +// } + +// const indent = `${indent_with.repeat(indent_depth)}// `; + +// const chunks: string[] = [ ]; + +// if (obj.title) { +// chunks.push(indent + obj.title + '\n'); +// } + +// if (obj.description) { +// chunks.push(wrap(obj.description, { indent, width: 100, }) + '\n'); +// } + +// if (Array.isArray(obj.examples)) { +// chunks.push( +// indent + 'Examples:\n' + obj.examples.map((example) => { +// return indent + '- ' + JSON.stringify(example) + '\n' +// }).join('') +// ); +// } + +// if ((obj as JSONSchema7).$comment) { +// chunks.push( +// indent + '--- Comment ---\n' + +// wrap((obj as JSONSchema7).$comment, { indent, width: 100, }) + '\n' +// ); +// } + +// return chunks.join(indent + '\n'); +// } + +// function render_schema(doc: SchemaDoc, indent_depth = 0, inline = true) { +// const schema = doc.data; +// const chunks: string[] = [ ]; +// const indent = indent_with.repeat(indent_depth); + +// chunks.push(render_comment_if_needed(schema, indent_depth)); +// chunks.push((inline ? '' : indent) + 'schema ' + (schema.$id ? str(schema.$id) + ' {\n' : '{\n')); +// chunks.push(render_type(schema, indent_depth + 1, false)); + +// if (schema.definitions) { +// chunks.push('\n'); +// chunks.push(render_definitions(schema, indent_depth + 1)); +// } + +// chunks.push('}'); + +// return chunks.join(''); +// } + +// function render_type(obj: JSONSchema | boolean, indent_depth = 0, inline = true) { +// if (obj === true) { +// return render_simple('any', indent_depth, inline); +// } + +// if (obj === false) { +// return render_simple('never', indent_depth, inline); +// } + +// const chunks: string[] = [ ]; +// const core_type = render_core_type_details(obj, indent_depth, inline); + +// if (core_type) { +// chunks.push(core_type); +// } + +// const indent = indent_with.repeat(indent_depth); + +// if (obj.oneOf) { +// chunks.push(render_additional(obj, render_one_of)); +// } + +// if (obj.anyOf) { +// chunks.push(render_additional(obj, render_any_of)); +// } + +// if (obj.allOf) { +// chunks.push(render_additional(obj, render_all_of)); +// } + +// if (obj.not) { +// chunks.push(render_additional(obj, render_not)); +// } + +// // todo: if +// // todo: then +// // todo: else + +// if (! chunks.length) { +// return render_any(obj, indent_depth, inline); +// } + +// if (inline) { +// if (! chunks[chunks.length - 1].endsWith(';')) { +// chunks.push(';'); +// } +// } + +// else if (! chunks[chunks.length - 1].endsWith(';\n')) { +// if (chunks[chunks.length - 1].endsWith('\n')) { +// chunks[chunks.length - 1] = chunks[chunks.length - 1].slice(0, -1) + ';\n'; +// } + +// else { +// chunks.push( +// chunks[chunks.length - 1].endsWith(';') ? '\n' : ';\n' +// ); +// } +// } + +// return chunks.join(''); + +// function render_additional(obj: JSONSchema, render: (obj: JSONSchema, indent_depth: number, inline: boolean) => string) { +// if (chunks.length) { +// const newline = inline ? '\n' : ''; +// return newline + indent + '+ ' + render(obj, indent_depth, true); +// } + +// return render(obj, indent_depth, inline); +// } +// } + +// function render_core_type_details(obj: JSONSchema, indent_depth = 0, inline = true) { +// if (obj.$ref) { +// return render_ref(obj, indent_depth, inline); +// } + +// if (Array.isArray(obj.type)) { +// const is_obj = obj.type.includes('object'); +// const is_arr = obj.type.includes('array'); + +// if (is_obj && is_arr) { +// // todo: render schemas that can be both objects and arrays somehow... +// } + +// else if (is_obj) { +// return render_object(obj, indent_depth, inline) +// } + +// else if (is_arr) { +// // todo: render multi-type arrays +// } + +// else { +// return render_basic(obj, indent_depth, inline); +// } +// } + +// const type = obj.type || infer_type(obj); + +// switch (type) { +// case 'any': return render_any(obj, indent_depth, inline); +// case 'array': return render_array(obj, indent_depth, inline); +// case 'boolean': return render_basic(obj, indent_depth, inline); +// case 'integer': return render_basic(obj, indent_depth, inline); +// case 'null': return render_simple('null', indent_depth, inline); +// case 'number': return render_basic(obj, indent_depth, inline); +// case 'object': return render_object(obj, indent_depth, inline); +// case 'string': return render_basic(obj, indent_depth, inline); +// } +// } + + + +// // ===== Type-Specific Renderers ===== + +// function render_simple(text: string, indent_depth = 0, inline = true) { +// const indent = indent_with.repeat(indent_depth); +// return inline ? `${text};` : (indent + `${text};\n`); +// } + +// function render_basic_type_and_attributes(obj: JSONSchema, type_str?: string, indent_depth = 0, inline = true) { +// const indent = indent_with.repeat(indent_depth); +// const basic_type = type_str || ( +// Array.isArray(obj.type) ? obj.type.join(' | ') : (obj.type || 'any') +// ); +// const chunks: string[] = [ (inline ? '' : indent) + basic_type ]; +// const attrs: string[] = [ ]; + +// if ('const' in obj) { +// attrs.push(`(const ${JSON.stringify(obj.const)})`); +// } + +// if ('enum' in obj) { +// const values = obj.enum.map((value) => JSON.stringify(value)); +// const value_list = render_inline_list(values, 1); +// attrs.push(`(enum${value_list})`); +// } + +// if ('default' in obj) { +// attrs.push(`(default ${JSON.stringify(obj.default)})`); +// } + +// if ('minimum' in obj) { +// attrs.push(`(minimum ${obj.minimum})`); +// } + +// if ('maximum' in obj) { +// attrs.push(`(maximum ${obj.maximum})`); +// } + +// if ('exclusiveMinimum' in obj) { +// attrs.push(`(exclusive-minimum ${obj.exclusiveMinimum})`); +// } + +// if ('exclusiveMaximum' in obj) { +// attrs.push(`(exclusive-maximum ${obj.exclusiveMaximum})`); +// } + +// if ('multipleOf' in obj) { +// attrs.push(`(multiple-of ${obj.multipleOf})`); +// } + +// if ('minItems' in obj) { +// attrs.push(`(min-items ${obj.minItems})`); +// } + +// if ('maxItems' in obj) { +// attrs.push(`(max-items ${obj.maxItems})`); +// } + +// if ('uniqueItems' in obj) { +// attrs.push('(unique-items)'); +// } + +// if ('format' in obj) { +// attrs.push(`(format ${obj.format})`); +// } + +// if ('pattern' in obj) { +// attrs.push(`(pattern ${regex(obj.pattern)})`); +// } + +// if ('minLength' in obj) { +// attrs.push(`(min-length ${obj.minLength})`); +// } + +// if ('maxLength' in obj) { +// attrs.push(`(max-length ${obj.maxLength})`); +// } + +// if ('contentMediaType' in obj) { +// attrs.push(`(content-media-type ${str(obj.contentMediaType)})`); +// } + +// if ('contentEncoding' in obj) { +// attrs.push(`(content-encoding ${str(obj.contentEncoding)})`); +// } + +// chunks.push(render_inline_list(attrs, indent_depth + 1)); + +// return chunks; +// } + +// function render_ref(obj: JSONSchema, indent_depth = 0, inline = true) { +// const chunks = render_basic_type_and_attributes(obj, `<${str(obj.$ref)}>`, indent_depth, inline); +// return chunks.join('') + (inline ? '' : '\n'); +// } + +// function render_any(obj: JSONSchema, indent_depth = 0, inline = true) { +// const chunks = render_basic_type_and_attributes(obj, 'any', indent_depth, inline); +// return chunks.join('') + (inline ? '' : '\n'); +// } + +// function render_basic(obj: JSONSchema, indent_depth = 0, inline = true) { +// const chunks = render_basic_type_and_attributes(obj, null, indent_depth, inline); +// return chunks.join('') + (inline ? '' : '\n'); +// } + +// function render_array(obj: JSONSchema, indent_depth = 0, inline = true) { +// const indent = indent_with.repeat(indent_depth); +// const chunks = render_basic_type_and_attributes(obj, null, indent_depth, inline); + +// if (obj.items) { +// if (Array.isArray(obj.items)) { +// chunks.push(' [\n'); +// chunks.push(render_array_tuple(obj, indent_depth + 1)); +// chunks.push(indent + ']'); +// } + +// else { +// chunks.push(' {\n'); +// chunks.push(render_comment_if_needed(obj.items, indent_depth + 1)); +// chunks.push(render_type(obj.items, indent_depth + 1, false)); +// chunks.push(indent + '}'); +// } +// } + +// return chunks.join('') + (inline ? '' : '\n'); +// } + +// function render_array_tuple(obj: JSONSchema, indent_depth = 0) { +// const chunks: string[] = [ ]; +// const indent = indent_with.repeat(indent_depth); + +// for (const type of (obj.items as JSONSchemaDefinition[])) { +// if (chunks.length) { +// chunks.push('\n'); +// } + +// chunks.push(render_comment_if_needed(type, indent_depth)); +// chunks.push(indent + render_type(type, indent_depth) + '\n'); +// } + +// if (obj.additionalItems) { +// if (chunks.length) { +// chunks.push('\n'); +// } + +// chunks.push(render_comment_if_needed(obj.additionalItems, indent_depth)); +// chunks.push(indent + '... ' + render_type(obj.additionalItems, indent_depth) + '\n'); +// } + +// return chunks.join(''); +// } + +// function render_object(obj: JSONSchema, indent_depth = 0, inline = true) { +// const indent = indent_with.repeat(indent_depth); +// const chunks = render_basic_type_and_attributes(obj, null, indent_depth, inline); + +// if (obj.properties || obj.additionalProperties || obj.patternProperties) { +// chunks.push(' {\n'); +// chunks.push(render_object_properties(obj, indent_depth + 1)); +// chunks.push(indent + '}'); +// } + +// else if (Array.isArray(obj.required)) { +// const values = obj.required.map((value) => JSON.stringify(value)); +// const value_list = render_inline_list(values, 1); +// chunks.push(` (required${value_list})`); +// } + +// return chunks.join('') + (inline ? '' : '\n'); +// } + +// function render_object_properties(obj: JSONSchema, indent_depth = 0) { +// const chunks: string[] = [ ]; +// const indent = indent_with.repeat(indent_depth); +// const required = new Set(Array.isArray(obj.required) ? obj.required : [ ]); + +// if (obj.properties) { +// for (const [name, type] of Object.entries(obj.properties) as [string, JSONSchema['properties'][string]][]) { +// if (chunks.length) { +// chunks.push('\n'); +// } + +// const optional_ind = required.has(name) ? '' : '?'; +// chunks.push(render_comment_if_needed(type, indent_depth)); +// chunks.push(indent + name + optional_ind + ': ' + render_type(type, indent_depth) + '\n'); +// } +// } + +// if (obj.patternProperties) { +// for (const [name, type] of Object.entries(obj.patternProperties) as [string, JSONSchema['properties'][string]][]) { +// if (chunks.length) { +// chunks.push('\n'); +// } + +// chunks.push(render_comment_if_needed(type, indent_depth)); +// chunks.push(indent + `['${name}']: ` + render_type(type, indent_depth) + '\n'); +// } +// } + +// if (obj.additionalProperties) { +// if (chunks.length) { +// chunks.push('\n'); +// } + +// chunks.push(render_comment_if_needed(obj.additionalProperties, indent_depth)); +// chunks.push(indent + '[*]: ' + render_type(obj.additionalProperties, indent_depth) + '\n'); +// } + +// return chunks.join(''); +// } + +// function render_one_of(obj: JSONSchema, indent_depth = 0, inline = true) { +// const indent = indent_with.repeat(indent_depth); +// const chunks: string[] = [ (inline ? '' : indent) + 'one_of' ]; + +// chunks.push(' {\n'); +// render_type_list(chunks, obj.oneOf, indent_depth); +// chunks.push(indent + '}'); + +// return chunks.join('') + (inline ? '' : '\n'); +// } + +// function render_all_of(obj: JSONSchema, indent_depth = 0, inline = true) { +// const indent = indent_with.repeat(indent_depth); +// const chunks: string[] = [ (inline ? '' : indent) + 'all_of' ]; + +// chunks.push(' {\n'); +// render_type_list(chunks, obj.allOf, indent_depth); +// chunks.push(indent + '}'); + +// return chunks.join('') + (inline ? '' : '\n'); +// } + +// function render_any_of(obj: JSONSchema, indent_depth = 0, inline = true) { +// const indent = indent_with.repeat(indent_depth); +// const chunks: string[] = [ (inline ? '' : indent) + 'any_of' ]; + +// chunks.push(' {\n'); +// render_type_list(chunks, obj.anyOf, indent_depth); +// chunks.push(indent + '}'); + +// return chunks.join('') + (inline ? '' : '\n'); +// } + +// function render_not(obj: JSONSchema, indent_depth = 0, inline = true) { +// const indent = indent_with.repeat(indent_depth); +// const prefix = inline ? '' : indent; +// const suffix = inline ? '' : '\n'; +// return prefix + 'not ' + render_type(obj.not, indent_depth, true) + suffix; +// } + + + +// // ===== Rendering Utils ===== + +// function infer_type(obj: JSONSchema) { +// return (obj.properties || obj.additionalProperties || obj.required || 'minimumProperties' in obj || 'maximumProperties' in obj) ? 'object' +// : (obj.items || obj.additionalItems || 'minimumItems' in obj || 'maximumItems' in obj) ? 'array' +// : ('minimum' in obj || 'maximum' in obj || 'exclusiveMinimum' in obj || 'exclusiveMaximum' in obj) ? 'number' +// : ('minLength' in obj || 'maxLength' in obj) ? 'string' +// : null +// ; +// } + +// function render_type_list(chunks: string[], types: JSONSchemaDefinition[], indent_depth = 0) { +// for (const type of types) { +// if (typeof type === 'object') { +// // skip the extra newline before the first entry +// if (chunks.length > 2) { +// chunks.push('\n'); +// } + +// chunks.push(render_comment_if_needed(type, indent_depth + 1)); +// chunks.push(render_type(type, indent_depth + 1, false)); +// } +// } +// } + +// function render_definitions(obj: JSONSchema, indent_depth = 0) { +// const chunks: string[] = [ ]; +// const indent = indent_with.repeat(indent_depth); + +// type Def = Exclude; +// for (const [name, type] of Object.entries(obj.definitions) as [string, Def][]) { +// if (chunks.length) { +// chunks.push('\n'); +// } + +// chunks.push(render_comment_if_needed(type, indent_depth)); +// chunks.push(indent + 'def ' + name + ': ' + render_type(type, indent_depth) + '\n'); +// } + +// return chunks.join(''); +// } + +// function render_inline_list(items: string[], indent_depth = 0) { +// const lines: string[] = [ ]; +// const indent = indent_with.repeat(indent_depth); +// const line_max = 100; +// const first_line_max = 85; + +// let line = ''; + +// for (const item of items) { +// if (item.includes('\n')) { +// const sub_lines = item.split('\n'); +// const first_line = sub_lines[0]; +// const last_line = sub_lines[sub_lines.length - 1]; +// const middle_lines = sub_lines.slice(1, -1); + +// add_item(first_line); +// lines.push(line + '\n'); + +// for (const item of middle_lines) { +// lines.push(indent + item + '\n'); +// } + +// line = indent + last_line; +// } + +// else { +// add_item(item); +// } +// } + +// function add_item(item: string) { +// const new_length = line.length + item.length + 1; +// const max_length = lines.length ? line_max : first_line_max; + +// if (line && new_length > max_length) { +// lines.push(line + '\n'); +// line = indent + item; +// } + +// else { +// line += ' ' + item; +// } +// } + +// if (line) { +// lines.push(line); +// } + +// return lines.join(''); +// } + +// function str(str: string) { +// return JSON.stringify(str) as `"${string}"`; +// } + +// function regex(str: string) { +// return "'" + str + "'"; +// } diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..2a97571 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,27 @@ +{ + "compilerOptions": { + "target": "es2020", + "module": "commonjs", + "outDir": "build", + "rootDir": "src", + "declaration": true, + "sourceMap": true, + "declarationMap": false, + "incremental": true, + "moduleResolution": "node", + "typeRoots": [ + "node_modules/@types/" + ], + "tsBuildInfoFile": "build/.tsbuildinfo", + "lib": [ + "es2020" + ] + }, + "exclude": [ + "node_modules", + "build" + ], + "include": [ + "src/**/*.ts" + ] +} \ No newline at end of file