diff --git a/common/config/rush/npm-shrinkwrap.json b/common/config/rush/npm-shrinkwrap.json index d181315d..ec5e0ec1 100644 --- a/common/config/rush/npm-shrinkwrap.json +++ b/common/config/rush/npm-shrinkwrap.json @@ -5,9 +5,9 @@ "requires": true, "dependencies": { "@babel/code-frame": { - "version": "7.0.0-beta.35", - "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.35.tgz", - "integrity": "sha512-l0SE8cl9DUIY4hYAFAKTLX3F2Yr14Qri7uTsuI7iegB5E4KyQy4XY72L3VOxmj6kwR/RDQURoKYr2NzyETGo7A==", + "version": "7.0.0-beta.36", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.0.0-beta.36.tgz", + "integrity": "sha512-sW77BFwJ48YvQp3Gzz5xtAUiXuYOL2aMJKDwiaY3OcvdqBFurtYfOpSa4QrNyDxmOGRFSYzUpabU2m9QrlWE7w==", "requires": { "chalk": "2.3.0", "esutils": "2.0.2", @@ -16,7 +16,7 @@ }, "@rush-temp/test-generator-cli": { "version": "file:projects/test-generator-cli.tgz", - "integrity": "sha1-JJJ6MyfmltDVjIVMJwQ1+5PfnzY=", + "integrity": "sha1-poL86JfifvnYdj6kO8BwW/R5VEA=", "requires": { "@types/fs-extra": "4.0.7", "@types/handlebars": "4.0.36", @@ -33,19 +33,19 @@ }, "@rush-temp/ts-docs-gen": { "version": "file:projects/ts-docs-gen.tgz", - "integrity": "sha1-AGcTehH/O+/1KBdtdw3/lnlFnlQ=", + "integrity": "sha1-X6xmRRnm3HUhBtQEy5JoWktjvnQ=", "requires": { - "@simplrjs/markdown": "1.0.3", + "@simplrjs/markdown": "1.0.7", "@types/fs-extra": "5.0.0", - "@types/jest": "21.1.9", + "@types/jest": "21.1.10", "@types/sinon": "4.1.2", "fast-glob": "1.0.1", "fs-extra": "5.0.0", - "jest": "22.0.3", + "jest": "22.0.4", "simplr-logger": "1.0.1", "simplr-tslint": "0.0.1", "sinon": "4.1.3", - "ts-extractor": "3.0.1", + "ts-extractor": "3.0.3", "ts-jest": "22.0.0", "tslint": "5.8.0", "typescript": "2.6.2" @@ -72,9 +72,9 @@ } }, "@simplrjs/markdown": { - "version": "1.0.3", - "resolved": "https://registry.npmjs.org/@simplrjs/markdown/-/markdown-1.0.3.tgz", - "integrity": "sha512-QkC79ttUek7d9w1yysaETZnsD7WO7JOLCbAIX8kCAeZhMY/21ZRULWjb3Pl7SBm6QqqYTOnKl8rvikmbVaGtLA==", + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/@simplrjs/markdown/-/markdown-1.0.7.tgz", + "integrity": "sha512-QIIyLpb37GHpQD+7a5FCz/cxB2RVBp8mn2rSoFMkC0ZZAFIsw1UEmy7B9nPTPW923VNW5w9+4GnVqCUqkvCqfQ==", "requires": { "@types/string": "0.0.29", "string": "3.3.3" @@ -94,9 +94,9 @@ "integrity": "sha512-LjNiTX7TY7wtuC6y3QwC93hKMuqYhgV9A1uXBKNvZtVC8ZvyWAjZkJ5BvT0K7RKqORRYRLMrqCxpw5RgS+MdrQ==" }, "@types/jest": { - "version": "21.1.9", - "resolved": "https://registry.npmjs.org/@types/jest/-/jest-21.1.9.tgz", - "integrity": "sha512-81wGgp3KLAhcrDQBeGADeuH1SvOmgZty5XF/mdPBOSxjEgAT9rcLr4CQCk2cRRjZE8vzmx7S1SPL6D/Z8OOR6A==" + "version": "21.1.10", + "resolved": "https://registry.npmjs.org/@types/jest/-/jest-21.1.10.tgz", + "integrity": "sha512-qDyqzbcyNgW2RgWbl606xCYQ+5fK9khOW5+Hl3wH7RggVES0dB6GcZvpmPs/XIty5qpu1xYCwpiK+iRkJ3xFBw==" }, "@types/node": { "version": "8.5.2", @@ -124,16 +124,16 @@ "integrity": "sha1-X6rZwsB/YN12dw9xzwJbYqY8/U4=" }, "acorn": { - "version": "5.2.1", - "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.2.1.tgz", - "integrity": "sha512-jG0u7c4Ly+3QkkW18V+NRDN+4bWHdln30NL1ZL2AvFZZmQe/BfopYCtghCKKVBUSetZ4QKcyA0pY6/4Gw8Pv8w==" + "version": "5.3.0", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-5.3.0.tgz", + "integrity": "sha512-Yej+zOJ1Dm/IMZzzj78OntP/r3zHEaKcyNoU2lAaxPtrseM6rF0xwqoz5Q5ysAiED9hTjI2hgtvLXitlCN1/Ug==" }, "acorn-globals": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/acorn-globals/-/acorn-globals-4.1.0.tgz", "integrity": "sha512-KjZwU26uG3u6eZcfGbTULzFcsoz6pegNKtHPksZPOUsiKo5bUmiBPa38FuHZ/Eun+XYh/JCCkS9AS3Lu4McQOQ==", "requires": { - "acorn": "5.2.1" + "acorn": "5.3.0" } }, "ajv": { @@ -444,9 +444,9 @@ } }, "babel-jest": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-22.0.3.tgz", - "integrity": "sha512-vIJAdq0YuLwg5TF6DDvcSFYx+Cqb9f2pTzC3ZcpGUBeysUUzPxZ6J3WVvuFMzpxgHa23tDKlNivDN9C4jIAKUQ==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-22.0.4.tgz", + "integrity": "sha512-/Yt61fUpdFjetYlnpj280BPKEsPnK4mqzxDdo8DybPvrPNrLurbAF/WBjn2nnoi1Hc2Ippsf12/aOp8ys/Vl1A==", "requires": { "babel-plugin-istanbul": "4.1.5", "babel-preset-jest": "22.0.3" @@ -828,6 +828,42 @@ "is-descriptor": "0.1.6" } }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -1059,7 +1095,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "requires": { - "is-descriptor": "1.0.1" + "is-descriptor": "1.0.2" } }, "delayed-stream": { @@ -1126,9 +1162,9 @@ } }, "es6-promise": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.1.1.tgz", - "integrity": "sha512-OaU1hHjgJf+b0NzsxCg7NdIYERD6Hy/PEmFLTjw+b65scuisG3Kt4QoTvJ66BBkPZ581gr0kpoVzKnxniM8nng==" + "version": "4.2.2", + "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.2.tgz", + "integrity": "sha512-LSas5vsuA6Q4nEdf9wokY5/AJYXry98i0IzXsv49rYsgDGDNDPbqAYR1Pe23iFxygfbGZNR/5VrHXBCh2BhvUQ==" }, "escape-string-regexp": { "version": "1.0.5", @@ -1213,6 +1249,42 @@ "is-descriptor": "0.1.6" } }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -1313,9 +1385,9 @@ } }, "extglob": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.2.tgz", - "integrity": "sha512-I0+eZBH+jFGL8F5BnIz2ON2nKCjTS3AS3H/5PeSmCp7UVC70Ym8IhdRiQly2juKYQ//f7z1aj1BRpQniFJoU1w==", + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.3.tgz", + "integrity": "sha512-AyptZexgu7qppEPq59DtN/XJGZDrLcVxSHai+4hdgMMS9EpF4GBvygcWWApno8lL9qSjVpYt7Raao28qzJX1ww==", "requires": { "array-unique": "0.3.2", "define-property": "1.0.0", @@ -1758,21 +1830,11 @@ "integrity": "sha1-EEqOSqym09jNFXqO+L+rLXo//bY=" }, "is-accessor-descriptor": { - "version": "0.1.6", - "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", - "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", + "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "requires": { - "is-buffer": "1.1.6" - } - } + "kind-of": "6.0.2" } }, "is-arrayish": { @@ -1815,21 +1877,11 @@ } }, "is-data-descriptor": { - "version": "0.1.4", - "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", - "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", + "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "requires": { - "kind-of": "3.2.2" - }, - "dependencies": { - "kind-of": { - "version": "3.2.2", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", - "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", - "requires": { - "is-buffer": "1.1.6" - } - } + "kind-of": "6.0.2" } }, "is-date-object": { @@ -1838,20 +1890,13 @@ "integrity": "sha1-mqIOtq7rv/d/vTPnTKAbM1gdOhY=" }, "is-descriptor": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.1.tgz", - "integrity": "sha512-G3fFVFTqfaqu7r4YuSBHKBAuOaLz8Sy7ekklUpFEliaLMP1Y2ZjoN9jS62YWCAPQrQpMUQSitRlrzibbuCZjdA==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", + "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "requires": { - "is-accessor-descriptor": "0.1.6", - "is-data-descriptor": "0.1.4", - "kind-of": "5.1.0" - }, - "dependencies": { - "kind-of": { - "version": "5.1.0", - "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", - "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==" - } + "is-accessor-descriptor": "1.0.0", + "is-data-descriptor": "1.0.0", + "kind-of": "6.0.2" } }, "is-dotfile": { @@ -2110,11 +2155,11 @@ } }, "jest": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest/-/jest-22.0.3.tgz", - "integrity": "sha512-90H1wLqiNR3tLhQUgwhC6GWHfRCG+Da14m7vxD608Mt/QTKR0TA751D+QH09x5bvcrLfvxLtxArtA0VEC0ORow==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest/-/jest-22.0.4.tgz", + "integrity": "sha512-S0tmgK5psULvt/11QzgAZWGpY5y5TkMRzd3T21Q13JzTx37Vx6F0Nw022c9Kc/IbEy+AHkKkGFVO5QafE8MrDg==", "requires": { - "jest-cli": "22.0.3" + "jest-cli": "22.0.4" }, "dependencies": { "ansi-regex": { @@ -2175,9 +2220,9 @@ } }, "jest-cli": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-22.0.3.tgz", - "integrity": "sha512-aX71DL4q9aLxbSmYI8uuPVlXVRyREU4VbApOdiuD79oqqqSGYu9E5S1SLXRm/PB5lJPh5xd8bVRrdsrMVs2hyw==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest-cli/-/jest-cli-22.0.4.tgz", + "integrity": "sha512-f1lZRM13IwIINzjE3RebXQKtQLiKncpSrbJZ/aTZJXmzEWGdgSayW4ESyhU+xK3uGiJEUSzbHjwPY6nGJ8VbUA==", "requires": { "ansi-escapes": "3.0.0", "chalk": "2.3.0", @@ -2189,17 +2234,17 @@ "istanbul-lib-instrument": "1.9.1", "istanbul-lib-source-maps": "1.2.2", "jest-changed-files": "22.0.3", - "jest-config": "22.0.3", - "jest-environment-jsdom": "22.0.3", + "jest-config": "22.0.4", + "jest-environment-jsdom": "22.0.4", "jest-get-type": "22.0.3", "jest-haste-map": "22.0.3", "jest-message-util": "22.0.3", "jest-regex-util": "22.0.3", "jest-resolve-dependencies": "22.0.3", - "jest-runner": "22.0.3", - "jest-runtime": "22.0.3", + "jest-runner": "22.0.4", + "jest-runtime": "22.0.4", "jest-snapshot": "22.0.3", - "jest-util": "22.0.3", + "jest-util": "22.0.4", "jest-worker": "22.0.3", "micromatch": "2.3.11", "node-notifier": "5.1.2", @@ -2259,19 +2304,19 @@ } }, "jest-config": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-22.0.3.tgz", - "integrity": "sha512-omqyzFPhRm+YaHku+jPuqpSFJ0QD61G/hqR+m09r2IajJbaRjV9XDezCIOD+rJiQlAyfFfo+DAc+u1mLy2IEaA==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest-config/-/jest-config-22.0.4.tgz", + "integrity": "sha512-NcBeixqHjHDZO9+pUj+365LQV2s65d2f0/IrwlUyv0xaJovRNc6eDvoJ/r2UUlHnqjP3Go+R0ECUsXPXjk4SHw==", "requires": { "chalk": "2.3.0", "glob": "7.1.2", - "jest-environment-jsdom": "22.0.3", - "jest-environment-node": "22.0.3", + "jest-environment-jsdom": "22.0.4", + "jest-environment-node": "22.0.4", "jest-get-type": "22.0.3", - "jest-jasmine2": "22.0.3", + "jest-jasmine2": "22.0.4", "jest-regex-util": "22.0.3", - "jest-resolve": "22.0.3", - "jest-util": "22.0.3", + "jest-resolve": "22.0.4", + "jest-util": "22.0.4", "jest-validate": "22.0.3", "pretty-format": "22.0.3" } @@ -2296,22 +2341,22 @@ } }, "jest-environment-jsdom": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-22.0.3.tgz", - "integrity": "sha512-LrR9flT6I4IZKIA/dmoAiTmTzGi7W8sP5mCXbgsTjFop1Jh3rNluza/xnf6VfK/aOZvBglJIVYbKqGxtcm0KsQ==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest-environment-jsdom/-/jest-environment-jsdom-22.0.4.tgz", + "integrity": "sha512-vnjefLZlsNsmnjKcaXkx2IxTBNG40vfRVOdMfcfkPkq85JxFB7wzNtjLx+RIfiNpIZd04C1PXbF0aJIenY85Ng==", "requires": { "jest-mock": "22.0.3", - "jest-util": "22.0.3", + "jest-util": "22.0.4", "jsdom": "11.5.1" } }, "jest-environment-node": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-22.0.3.tgz", - "integrity": "sha512-Kk7FYtCQZ+CFwwCL1t3DJ/Lxvjoda4qRt/NJh/6jsAEWM7VcSBAzmmayA5JcMRpQQ4FRiUcLrvrKEfO01/Fgsw==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest-environment-node/-/jest-environment-node-22.0.4.tgz", + "integrity": "sha512-9vjNKb86UivvKCZCudMNixQgdMnOG7ql6iVYnaiK0CmvZ0WQD+mlM10NvgiWpRv4HstcnRL1pY/GSIHXAD6qXw==", "requires": { "jest-mock": "22.0.3", - "jest-util": "22.0.3" + "jest-util": "22.0.4" } }, "jest-get-type": { @@ -2415,9 +2460,9 @@ } }, "jest-jasmine2": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-22.0.3.tgz", - "integrity": "sha512-0Gz3pFZytCjbCKssBJWzx5NolNLg179gkT0Zfe+fWrJS9Ap9EH7eTB9UHoiT2O3lRNBfaYTzrXhOMgf4l/jCMg==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest-jasmine2/-/jest-jasmine2-22.0.4.tgz", + "integrity": "sha512-pn1XPHUkffHK6oNY1Dfl/+Rg0UuTdlg3aGDnjyK6dZzGEBeiH1uKuSgZEjy3Lj461l3atpzsQyw7ilXPyjFnUw==", "requires": { "callsites": "2.0.0", "chalk": "2.3.0", @@ -2453,7 +2498,7 @@ "resolved": "https://registry.npmjs.org/jest-message-util/-/jest-message-util-22.0.3.tgz", "integrity": "sha512-AVBdCx7Oj5wBpMOH089lx7Zgwpdz9HbReA82HuVAlIT4kEQRvCy6Sl9yVWDGJwHTgB/OYQGkgmbv/P/K8TkWNw==", "requires": { - "@babel/code-frame": "7.0.0-beta.35", + "@babel/code-frame": "7.0.0-beta.36", "chalk": "2.3.0", "micromatch": "2.3.11", "slash": "1.0.0", @@ -2553,9 +2598,9 @@ "integrity": "sha512-mplC9chiAotES3ClzNhy0SJcfHB2DivooKJZW+2hDdvP8LLB+OUI+D6bJd7sncbKUsyFcmblEvpm/zz/hef7HA==" }, "jest-resolve": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-22.0.3.tgz", - "integrity": "sha512-UHpim1kXTXH5hlftIpVOUkh0n+wd36/QNuYgpZnzwX8PsB8DizBuaPJbl5VvorHBpRouz21Ty0K0QM1pPny9cw==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest-resolve/-/jest-resolve-22.0.4.tgz", + "integrity": "sha512-yoxHsX4MTT2Ra/dFia9VCunzsA/4jMBENMmLjREIUkCIP1edk/PZUOGVVf680Gw04CtmT5stETylcbmbL7hJBw==", "requires": { "browser-resolve": "1.11.2", "chalk": "2.3.0" @@ -2570,38 +2615,38 @@ } }, "jest-runner": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-22.0.3.tgz", - "integrity": "sha512-b/Eh+bPFLU09R0AULy4/IcUQ4Cgiao7YcmCehI7eailVj2xGQAfhmzSlhDpVIYmvoRZFyReOseihZXXRsdFafA==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest-runner/-/jest-runner-22.0.4.tgz", + "integrity": "sha512-srBkbqmiSB+jzSaG652fmi3kS6rV6wS/4fOG8dxxBg3dCqNQcM2/L3TI3ZK0SwIAcdGJh5Gybs8aDboT8K9Cdw==", "requires": { - "jest-config": "22.0.3", + "jest-config": "22.0.4", "jest-docblock": "22.0.3", "jest-haste-map": "22.0.3", - "jest-jasmine2": "22.0.3", + "jest-jasmine2": "22.0.4", "jest-leak-detector": "22.0.3", "jest-message-util": "22.0.3", - "jest-runtime": "22.0.3", - "jest-util": "22.0.3", + "jest-runtime": "22.0.4", + "jest-util": "22.0.4", "jest-worker": "22.0.3", "throat": "4.1.0" } }, "jest-runtime": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-22.0.3.tgz", - "integrity": "sha512-SSOiAde16JhEtVtNaWV2OmimmyxP8lmUdHxYde5rwv7iibkRy/o4QtalmmmH48oUxwy/epZVDaEyBKBA/iDFBg==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest-runtime/-/jest-runtime-22.0.4.tgz", + "integrity": "sha512-+7uEwf/4f8k1E/eViyGK6/M5yA4O3f6TdWViuqF9MV7vXwG2OVJu8YEZa5239nEnHJiwinXp4eZXX+HB4pQRPg==", "requires": { "babel-core": "6.26.0", - "babel-jest": "22.0.3", + "babel-jest": "22.0.4", "babel-plugin-istanbul": "4.1.5", "chalk": "2.3.0", "convert-source-map": "1.5.1", "graceful-fs": "4.1.11", - "jest-config": "22.0.3", + "jest-config": "22.0.4", "jest-haste-map": "22.0.3", "jest-regex-util": "22.0.3", - "jest-resolve": "22.0.3", - "jest-util": "22.0.3", + "jest-resolve": "22.0.4", + "jest-util": "22.0.4", "json-stable-stringify": "1.0.1", "micromatch": "2.3.11", "realpath-native": "1.0.0", @@ -2712,9 +2757,9 @@ } }, "jest-util": { - "version": "22.0.3", - "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-22.0.3.tgz", - "integrity": "sha512-iDnKIw4P+9433L7II90UGYZ4rQOatbbcjZO/+1+Fga+rNUF1wEijDfTDjGQil98smAquvB02RBrDgfbquUHLmg==", + "version": "22.0.4", + "resolved": "https://registry.npmjs.org/jest-util/-/jest-util-22.0.4.tgz", + "integrity": "sha512-gNNPtcCFkVh7daKIl3/06eoQ90QXGXCyDOfyZ3IEyTWmHBdX3GvklcOtyGcdOvrYEubaZTfMcMKmEeo/6sRTog==", "requires": { "callsites": "2.0.0", "chalk": "2.3.0", @@ -2764,7 +2809,7 @@ "integrity": "sha512-89ztIZ03aYK9f1uUrLXLsZndRge/JnZjzjpaN+lrse3coqz+8PR/dX4WLHpbF5fIKTXhDjFODOJw2328lPJ90g==", "requires": { "abab": "1.0.4", - "acorn": "5.2.1", + "acorn": "5.3.0", "acorn-globals": "4.1.0", "array-equal": "1.0.0", "browser-process-hrtime": "0.1.2", @@ -3006,7 +3051,7 @@ "braces": "2.3.0", "define-property": "1.0.0", "extend-shallow": "2.0.1", - "extglob": "2.0.2", + "extglob": "2.0.3", "fragment-cache": "0.2.1", "kind-of": "6.0.2", "nanomatch": "1.2.6", @@ -3216,6 +3261,22 @@ "is-descriptor": "0.1.6" } }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "requires": { + "kind-of": "3.2.2" + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "requires": { + "kind-of": "3.2.2" + } + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -3643,7 +3704,7 @@ "integrity": "sha1-YUYwSGkKxqRVt1ti+nioj43IXlM=", "requires": { "call-me-maybe": "1.0.1", - "es6-promise": "4.1.1", + "es6-promise": "4.2.2", "glob-to-regexp": "0.3.0" } }, @@ -3957,6 +4018,42 @@ "is-descriptor": "0.1.6" } }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -4130,6 +4227,42 @@ "is-descriptor": "0.1.6" } }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -4419,6 +4552,42 @@ "is-descriptor": "0.1.6" } }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", @@ -4474,9 +4643,9 @@ "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=" }, "ts-extractor": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/ts-extractor/-/ts-extractor-3.0.1.tgz", - "integrity": "sha512-ghuDQd1kVvQ+A7WbcclGXzSVukXVNKjwaB2AO/oeOYpkw1we7FkgGvVFFogtvo2jJyVBsBQDmKtB92UHcW9FsQ==", + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/ts-extractor/-/ts-extractor-3.0.3.tgz", + "integrity": "sha512-4izZ/Mn0UgyCYz4Cl+x0C1WVVpl0ez6BuCCB8RAwti6teujA1OxfsbZI2oL/vwS2DFYECtVlsjqnapUm3bBIHA==", "requires": { "@types/fs-extra": "5.0.0", "fs-extra": "5.0.0", @@ -4516,7 +4685,7 @@ "babel-preset-jest": "22.0.3", "cpx": "1.5.0", "fs-extra": "4.0.3", - "jest-config": "22.0.3", + "jest-config": "22.0.4", "pkg-dir": "2.0.0", "source-map-support": "0.5.0", "yargs": "10.0.3" @@ -4542,13 +4711,13 @@ "resolve": "1.5.0", "semver": "5.4.1", "tslib": "1.8.1", - "tsutils": "2.13.1" + "tsutils": "2.15.0" } }, "tsutils": { - "version": "2.13.1", - "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.13.1.tgz", - "integrity": "sha512-XMOEvc2TiYesVSOJMI7OYPnBMSgcvERuGW5Li/J+2A0TuH607BPQnOLQ82oSPZCssB8c9+QGi6qhTBa/f1xQRA==", + "version": "2.15.0", + "resolved": "https://registry.npmjs.org/tsutils/-/tsutils-2.15.0.tgz", + "integrity": "sha512-kKb1mSqRMwF0GHKya5/hZsI2m7Flg4ONZDeYu4e6Gx+kYAu86zsLNCHcUmNWhCRaUcKshNI272hOzuaCQDzJ2g==", "requires": { "tslib": "1.8.1" } @@ -4667,6 +4836,42 @@ "is-descriptor": "0.1.6" } }, + "is-accessor-descriptor": { + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", + "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, + "is-data-descriptor": { + "version": "0.1.4", + "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", + "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", + "requires": { + "kind-of": "3.2.2" + }, + "dependencies": { + "kind-of": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", + "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", + "requires": { + "is-buffer": "1.1.6" + } + } + } + }, "is-descriptor": { "version": "0.1.6", "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", diff --git a/packages/ts-docs-gen/examples/simple/docs/api/index.md b/packages/ts-docs-gen/examples/simple/docs/api/index.md index a4736fe9..773f12df 100644 --- a/packages/ts-docs-gen/examples/simple/docs/api/index.md +++ b/packages/ts-docs-gen/examples/simple/docs/api/index.md @@ -1,5 +1,549 @@ -[ClassDeclaration-0]: index/hello.md#hello +[InterfaceDeclaration-1]: index.md#foo +[InterfaceDeclaration-2]: index.md#boo +[InterfaceDeclaration-4]: index.md#myconstrainttype +[InterfaceDeclaration-9]: index.md#dictionary +[InterfaceDeclaration-9]: index.md#dictionary +[InterfaceDeclaration-6]: index.md#objectsinterface +[InterfaceDeclaration-12]: index.md#monsterinterface # index -## [Hello][ClassDeclaration-0] +## interface ExtendedBar + +```typescript +interface ExtendedBar extends Foo, Boo { + OtherStuff: string[]; +} +``` + +### Extends + +[Foo][InterfaceDeclaration-1]<number> + +[Boo][InterfaceDeclaration-2] + +### Properties + +| Name | Type | +| ---------- | --------------------- | +| OtherStuff | Array<string> | + +## interface Foo + +```typescript +interface Foo { + Name: string; + Surname: string; + Type: TType; +} +``` + +### Type parameters + +| Name | +| ----- | +| TType | + +### Properties + +| Name | Type | +| ------- | ------ | +| Name | string | +| Surname | string | +| Type | TType | + +## interface Boo + +```typescript +interface Boo { + Boos: string[]; +} +``` + +### Properties + +| Name | Type | +| ---- | --------------------- | +| Boos | Array<string> | + +## interface AnotherInterface + +```typescript +interface AnotherInterface { + (param1: TValue, param2: TValue): boolean; +} +``` + +### Call + +```typescript +(param1: TValue, param2: TValue): boolean +``` + +Type parameters: + +| Name | +| ------ | +| TValue | + +Parameters: + +| Name | Type | +| ------ | ------ | +| param1 | TValue | +| param2 | TValue | + +Return type: + +true | false + +--- + + +## interface MyConstraintType + +```typescript +interface MyConstraintType { + myProperty: string; +} +``` + +### Properties + +| Name | Type | +| ---------- | ------ | +| myProperty | string | + +## interface MyDefaultType + +```typescript +interface MyDefaultType extends MyConstraintType { + anotherProperty: number; +} +``` + +### Extends + +[MyConstraintType][InterfaceDeclaration-4] + +### Properties + +| Name | Type | +| --------------- | ------ | +| anotherProperty | number | + +## interface ObjectsInterface + +```typescript +interface ObjectsInterface { + objectOne: Object; + objectTwo: Object; +} +``` + +### Properties + +| Name | Type | +| --------- | ------ | +| objectOne | Object | +| objectTwo | Object | + +## interface InterfaceWithCall + +```typescript +interface InterfaceWithCall { + (): { someProperty: T; }; +} +``` + +### Call + +```typescript +(): { someProperty: T; } +``` + +Type parameters: + +| Name | +| ---- | +| T | + +Return type: + +{ someProperty: T; } + +--- + + +## interface InterfaceWithConstraintType + +```typescript +interface InterfaceWithConstraintType extends Dictionary { + someProperty: string; +} +``` + +### Extends + +[Dictionary][InterfaceDeclaration-9]<string> + +### Properties + +| Name | Type | +| ------------ | ------ | +| someProperty | string | + +## interface InterfaceWithMethod + +```typescript +interface InterfaceWithMethod { + someMethodOne(): T; + someMethodTwo(): TReturn; +} +``` + +### Type parameters + +| Name | +| ---- | +| T | + +### Methods + +```typescript +someMethodOne(): T +``` + +Return type: + +T + +--- + +```typescript +someMethodTwo(): TReturn +``` + +Type parameters: + +| Name | +| ------- | +| TReturn | + +Return type: + +TReturn + +--- + + +## interface Dictionary + +```typescript +interface Dictionary { + new (): Dictionary; + [key: string]: TValue; +} +``` + +### Type parameters + +| Name | +| ------ | +| TValue | + +### Construct + +```typescript +new (): Dictionary +``` + +Return type: + +[Dictionary][InterfaceDeclaration-9]<TValue> + +--- + +### Index signatures + +```typescript +[key: string]: TValue +``` + +Index `key` - string + +Type - TValue + +--- + + +## interface MethodsInterface + +```typescript +interface MethodsInterface { + (arg: TValue): void; + someMethod(): string; +} +``` + +### Call + +```typescript +(arg: TValue): void +``` + +Type parameters: + +| Name | +| ------ | +| TValue | + +Parameters: + +| Name | Type | +| ---- | ------ | +| arg | TValue | + +Return type: + +void + +--- + +### Methods + +```typescript +someMethod(): string +``` + +Type parameters: + +| Name | +| ---- | +| T | + +Return type: + +string + +--- + + +## interface MonsterInterface + +Warning: Beta! + +Deprecated! + +Monster interface + +```typescript +interface MonsterInterface extends ObjectsInterface { + new (): MonsterInterface; + new (someParameter: string): string; + (): { someProperty: T; }; + (key?: string | undefined): { someProperty: T; }; + (key: number): { someProperty: T; }; + readonly [key: string]: TValue; + readonly objectOne?: TValue; + objectTwo: TValue; +} +``` + +### Type parameters + +| Name | Constraint type | Default type | +| ------ | --------------- | ------------ | +| TValue | Object | \{\} | + +### Extends + +[ObjectsInterface][InterfaceDeclaration-6] + +### Construct + +```typescript +new (): MonsterInterface +``` + +Type parameters: + +| Name | +| ---- | +| T | + +Return type: + +[MonsterInterface][InterfaceDeclaration-12]<T> + +--- + +```typescript +new (someParameter: string): string +``` + +Parameters: + +| Name | Type | +| ------------- | ------ | +| someParameter | string | + +Return type: + +string + +--- + +### Call + +```typescript +(): { someProperty: T; } +``` + +Type parameters: + +| Name | +| ---- | +| T | + +Return type: + +{ someProperty: T; } + +--- + +```typescript +(key?: string | undefined): { someProperty: T; } +``` + +Type parameters: + +| Name | +| ---- | +| T | + +Parameters: + +| Name | Type | Optional | +| ---- | ----------------------- | -------- | +| key | undefined | string | Yes | + +Return type: + +{ someProperty: T; } + +--- + +```typescript +(key: number): { someProperty: T; } +``` + +Type parameters: + +| Name | +| ---- | +| T | + +Parameters: + +| Name | Type | +| ---- | ------ | +| key | number | + +Return type: + +{ someProperty: T; } + +--- + +### Index signatures + +```typescript +readonly [key: string]: TValue +``` + +Readonly. + +Index `key` - string + +Type - TValue + +--- + +### Properties + +| Name | Type | +| --------- | ------ | +| objectOne | TValue | +| objectTwo | TValue | + +## interface SomeInterface + +```typescript +interface SomeInterface { + [key: string]: string | number; + [key: number]: string; +} +``` + +### Index signatures + +```typescript +[key: string]: string | number +``` + +Index `key` - string + +Type - string | number + +--- + +```typescript +[key: number]: string +``` + +Index `key` - number + +Type - string + +--- + + +## interface StringsDictionary + +```typescript +interface StringsDictionary { + [key: string]: string; +} +``` + +### Index signatures + +```typescript +[key: string]: string +``` + +Index `key` - string + +Type - string + +--- + + +## interface MyInterface + +```typescript +interface MyInterface { + MyPropertyOne: string; + MyPropertyTwo: Object; + MyPropertyThree: number; +} +``` + +### Properties + +| Name | Type | +| --------------- | ------ | +| MyPropertyOne | string | +| MyPropertyTwo | Object | +| MyPropertyThree | number | diff --git a/packages/ts-docs-gen/examples/simple/docs/api/index/hello.md b/packages/ts-docs-gen/examples/simple/docs/api/index/hello.md index cc6438ea..82cfc54a 100644 --- a/packages/ts-docs-gen/examples/simple/docs/api/index/hello.md +++ b/packages/ts-docs-gen/examples/simple/docs/api/index/hello.md @@ -52,9 +52,9 @@ public GetFoo(arg: string | number): string ``` #### Parameters -| Name | Type | -| ---- | ---------------- | -| arg | string \| number | +| Name | Type | +| ---- | -------------------- | +| arg | string | number | ## Properties diff --git a/packages/ts-docs-gen/examples/simple/index.ts b/packages/ts-docs-gen/examples/simple/index.ts index 724fafda..4d793115 100644 --- a/packages/ts-docs-gen/examples/simple/index.ts +++ b/packages/ts-docs-gen/examples/simple/index.ts @@ -1,5 +1,94 @@ // tslint:disable +export interface ExtendedBar extends Foo, Boo { + OtherStuff: string[]; +} + +export interface Foo { + Name: string; + Surname: string; + Type: TType; +} + +export interface Boo { + Boos: string[]; +} + +export interface AnotherInterface { + (param1: TValue, param2: TValue): boolean; +} + +export interface MyConstraintType { + myProperty: string; +} + +export interface MyDefaultType extends MyConstraintType { + anotherProperty: number; +} + +export interface ObjectsInterface { + objectOne: Object; + objectTwo: Object; +} + +export interface InterfaceWithCall { + (): { someProperty: T }; +} + +export interface InterfaceWithConstraintType extends Dictionary { + someProperty: string; +} + +export interface InterfaceWithMethod { + someMethodOne(): T; + someMethodTwo(): TReturn; +} + +export interface Dictionary { + new(): Dictionary; + [key: string]: TValue; +} + +export interface MethodsInterface { + someMethod(): string; + (arg: TValue): void; +} + +/** + * Monster interface + * @beta + * @deprecated + */ +export interface MonsterInterface extends ObjectsInterface { + new (): MonsterInterface; + new(someParameter: string): string; + + readonly [key: string]: TValue; + + (): { someProperty: T }; + (key?: string): { someProperty: T }; + (key: number): { someProperty: T }; + + readonly objectOne: TValue; + objectTwo: TValue; +} + +export interface SomeInterface { + [key: string]: string | number; + [key: number]: string; +} + +export interface StringsDictionary { + [key: string]: string; +} + +export interface MyInterface { + MyPropertyOne: string; + MyPropertyTwo: Object; + MyPropertyThree: number; +} + + // import { Foo } from "./exported-functions"; // export class World { } @@ -211,18 +300,18 @@ // } // } -export class Hello { - /** - * This is a constructor - * @param arg This is an argument ;) - */ - constructor(arg: string) { } +// export class Hello { +// /** +// * This is a constructor +// * @param arg This is an argument ;) +// */ +// constructor(arg: string) { } - GetFoo(arg: number): string - GetFoo(arg: string): string - GetFoo(arg: string | number): string { - throw new Error("Method not implemented."); - } +// GetFoo(arg: number): string +// GetFoo(arg: string): string +// GetFoo(arg: string | number): string { +// throw new Error("Method not implemented."); +// } - public Foo: string; -} +// public Foo: string; +// } diff --git a/packages/ts-docs-gen/package.json b/packages/ts-docs-gen/package.json index 8a284c47..202da6e3 100644 --- a/packages/ts-docs-gen/package.json +++ b/packages/ts-docs-gen/package.json @@ -15,12 +15,12 @@ "engine": "node >= 7.5.0", "author": "simplrjs (https://github.com/simplrjs)", "dependencies": { - "@simplrjs/markdown": "^1.0.3", + "@simplrjs/markdown": "^1.0.7", "@types/fs-extra": "^5.0.0", "fast-glob": "^1.0.1", "fs-extra": "^5.0.0", "simplr-logger": "^1.0.1", - "ts-extractor": "^3.0.1", + "ts-extractor": "^3.0.3", "typescript": "^2.6.2" }, "devDependencies": { diff --git a/packages/ts-docs-gen/src/default-plugins.ts b/packages/ts-docs-gen/src/default-plugins.ts index cf90c6a7..decf9706 100644 --- a/packages/ts-docs-gen/src/default-plugins.ts +++ b/packages/ts-docs-gen/src/default-plugins.ts @@ -4,6 +4,9 @@ import { ApiEnumPlugin } from "./plugins/api-enum-plugin"; import { ApiFunctionPlugin } from "./plugins/api-function-plugin"; import { ApiTypePlugin } from "./plugins/api-type-plugin"; import { ApiNamespacePlugin } from "./plugins/api-namespace-plugin"; +import { ApiInterfacePlugin } from "./plugins/api-interface-plugin"; +import { ApiCallablePlugin } from "./plugins/api-callable-plugin"; +import { ApiIndexPlugin } from "./plugins/api-index-plugin"; import { ApiClassPlugin } from "./plugins/api-class-plugin"; import { ApiClassConstructorPlugin } from "./plugins/api-class-constructor-plugin"; import { ApiClassMethodPlugin } from "./plugins/api-class-method-plugin"; @@ -16,6 +19,9 @@ export const DefaultPlugins = [ new ApiFunctionPlugin(), new ApiTypePlugin(), new ApiNamespacePlugin(), + new ApiInterfacePlugin(), + new ApiCallablePlugin(), + new ApiIndexPlugin(), new ApiClassPlugin(), new ApiClassConstructorPlugin(), new ApiClassMethodPlugin(), diff --git a/packages/ts-docs-gen/src/generator-helpers.ts b/packages/ts-docs-gen/src/generator-helpers.ts index 8b018276..a4a8d398 100644 --- a/packages/ts-docs-gen/src/generator-helpers.ts +++ b/packages/ts-docs-gen/src/generator-helpers.ts @@ -55,14 +55,6 @@ export namespace GeneratorHelpers { } case Contracts.TypeKinds.Basic: default: { - // Generics - if (type.Name != null && type.Generics != null) { - const generics = type.Generics.map(TypeDtoToMarkdownString); - references = references.concat(...generics.map(x => x.References)); - - text += `<${generics.map(x => x.Text).join(", ")}>`; - } - // Basic type with reference. if (type.Name == null || TSHelpers.IsInternalSymbolName(type.Name)) { text = type.Text; @@ -75,6 +67,14 @@ export namespace GeneratorHelpers { text = type.Name; } } + + // Generics + if (type.Name != null && type.Generics != null) { + const generics = type.Generics.map(TypeDtoToMarkdownString); + references = references.concat(...generics.map(x => x.References)); + + text += MarkdownGenerator.EscapeString(`<${generics.map(x => x.Text).join(", ")}>`); + } } } @@ -239,7 +239,8 @@ export namespace GeneratorHelpers { }; export const DEFAULT_TABLE_OPTIONS: MarkdownContracts.TableOptions = { - removeColumnIfEmpty: true + removeColumnIfEmpty: true, + removeRowIfEmpty: true }; export function FixSentence(sentence: string, punctuationMark: string = "."): string { @@ -261,49 +262,99 @@ export namespace GeneratorHelpers { return `type ${name} = ${item.Type.Text};`; } + export function TypeParametersToString(typeParameters?: Contracts.ApiTypeParameterDto[]): string { + if (typeParameters != null && typeParameters.length > 0) { + const params: string[] = typeParameters.map(TypeParameterToString); + return `<${params.join(", ")}>`; + } else { + return ""; + } + } + + export function TypeParameterToString(apiItem: Contracts.ApiTypeParameterDto): string { + const extendsString = apiItem.ConstraintType != null ? ` extends ${apiItem.ConstraintType.Text}` : ""; + const defaultType = apiItem.DefaultType != null ? ` = ${apiItem.DefaultType.Text}` : ""; + + return `${apiItem.Name}${extendsString}${defaultType}`; + } + /** - * From ApiFunction to build function head. + * Builds call declaration. * - * Return example: `function foo(arg: TValue): void` + * Return example: `(arg: TValue): void` */ - export function ApiFunctionToString( - apiItem: Contracts.ApiFunctionDto, + export function ApiCallToString( typeParameters?: Contracts.ApiTypeParameterDto[], parameters?: Contracts.ApiParameterDto[], - alias?: string + returnType?: Contracts.TypeDto ): string { - const name = alias || apiItem.Name; - // TypeParameters - let typeParametersString: string; - if (typeParameters != null && typeParameters.length > 0) { - const params: string[] = typeParameters.map(TypeParameterToString); - typeParametersString = `<${params.join(", ")}>`; - } else { - typeParametersString = ""; - } + const typeParametersString = TypeParametersToString(typeParameters); // Parameters let parametersString: string; if (parameters != null && parameters.length > 0) { parametersString = parameters - .map(x => `${x.Name}: ${x.Type.Text}`) + .map(ApiParameterToString) .join(", "); } else { parametersString = ""; } // ReturnType - const returnType = apiItem.ReturnType != null ? `: ${apiItem.ReturnType.Text}` : ""; + const returnTypeString = returnType != null ? `: ${returnType.Text}` : ""; - return `function ${name}${typeParametersString}(${parametersString})${returnType}`; + return `${typeParametersString}(${parametersString})${returnTypeString}`; } - export function TypeParameterToString(apiItem: Contracts.ApiTypeParameterDto): string { - const $extends = apiItem.ConstraintType != null ? ` extends ${apiItem.ConstraintType.Text}` : ""; - const defaultType = apiItem.DefaultType != null ? ` = ${apiItem.DefaultType.Text}` : ""; + // FIXME: `?` and `| undefined` in a single statement. + export function ApiParameterToString(apiItem: Contracts.ApiParameterDto): string { + const initializerString = apiItem.Initializer ? ` = ${apiItem.Initializer}` : ""; + const isOptionalString = apiItem.IsOptional ? "?" : ""; + return `${apiItem.Name}${isOptionalString}: ${apiItem.Type.Text}${initializerString}`; + } - return `${apiItem.Name}${$extends}${defaultType}`; + /** + * Builds function head from ApiFunction. + * + * Return example: `function foo(arg: TValue): void` + */ + export function ApiFunctionToString( + apiItem: Contracts.ApiFunctionDto, + typeParameters?: Contracts.ApiTypeParameterDto[], + parameters?: Contracts.ApiParameterDto[], + alias?: string + ): string { + const name = alias || apiItem.Name; + const callString = ApiCallToString(typeParameters, parameters, apiItem.ReturnType); + + return `function ${name}${callString}`; + } + + /** + * Builds construct declaration. + * + * Return example: `new (arg: TValue): void` + */ + export function ApiConstructToString( + typeParameters?: Contracts.ApiTypeParameterDto[], + parameters?: Contracts.ApiParameterDto[], + returnType?: Contracts.TypeDto + ): string { + const callString = ApiCallToString(typeParameters, parameters, returnType); + + return `new ${callString}`; + } + + export function ApiMethodToString( + name: string, + typeParameters?: Contracts.ApiTypeParameterDto[], + parameters?: Contracts.ApiParameterDto[], + returnType?: Contracts.TypeDto + ): string { + const callString = ApiCallToString(typeParameters, parameters, returnType); + + return `${name}${callString}`; } export function ClassToString( @@ -418,14 +469,17 @@ export namespace GeneratorHelpers { export function GetApiItemsFromReference( items: Contracts.ApiItemReference[], - extractedData: ExtractDto + extractedData: ExtractDto, + apiItemKind?: Contracts.ApiItemKinds ): T[] { const apiItems: T[] = []; for (const itemReferences of items) { for (const referenceId of itemReferences.Ids) { const apiItem = extractedData.Registry[referenceId] as T; - apiItems.push(apiItem); + if (apiItemKind == null || apiItemKind != null && apiItem.ApiKind === apiItemKind) { + apiItems.push(apiItem); + } } } @@ -442,6 +496,208 @@ export namespace GeneratorHelpers { return pathString.split(path.sep).join("/"); } + export function ApiInterfaceToSimpleString(alias: string, apiItem: Contracts.ApiInterfaceDto): string { + const name = alias || apiItem.Name; + return `interface ${name}`; + } + + // TODO: optimize. + export function ApiInterfaceToString( + apiItem: Contracts.ApiInterfaceDto, + extractedData: ExtractDto + ): string[] { + const typeParameters = GetApiItemsFromReference(apiItem.TypeParameters, extractedData); + const typeParametersString = TypeParametersToString(typeParameters); + + let extendsString: string; + + if (apiItem.Extends.length === 0) { + extendsString = ""; + } else { + const typesExtended = apiItem.Extends + .map(x => x.Text) + .join(", "); + extendsString = ` extends ${typesExtended}`; + } + + const builder = new MarkdownBuilder() + .Text(`interface ${apiItem.Name}${typeParametersString}${extendsString} {`); + + const constructMembers = GetApiItemsFromReference( + apiItem.Members, + extractedData, + Contracts.ApiItemKinds.Construct + ); + constructMembers.forEach(member => { + const parameters = GetApiItemsFromReference(member.Parameters, extractedData); + const memberTypeParameters = GetApiItemsFromReference(member.TypeParameters, extractedData); + builder.Text(`${Tab(1)}${ApiConstructToString(memberTypeParameters, parameters, member.ReturnType)};`); + }); + + const callMembers = GetApiItemsFromReference( + apiItem.Members, + extractedData, + Contracts.ApiItemKinds.Call + ); + callMembers.forEach(member => { + const parameters = GetApiItemsFromReference(member.Parameters, extractedData); + const memberTypeParameters = GetApiItemsFromReference(member.TypeParameters, extractedData); + builder.Text(`${Tab(1)}${ApiCallToString(memberTypeParameters, parameters, member.ReturnType)};`); + }); + + const indexMembers = GetApiItemsFromReference( + apiItem.Members, + extractedData, + Contracts.ApiItemKinds.Index + ); + indexMembers.forEach(member => { + const parameter = extractedData.Registry[member.Parameter] as Contracts.ApiParameterDto; + builder.Text(`${Tab(1)}${ApiIndexToString(parameter, member.Type, member.IsReadonly)};`); + }); + + const methodMembers = GetApiItemsFromReference( + apiItem.Members, + extractedData, + Contracts.ApiItemKinds.Method + ); + methodMembers.forEach(member => { + const parameters = GetApiItemsFromReference(member.Parameters, extractedData); + const memberTypeParameters = GetApiItemsFromReference(member.TypeParameters, extractedData); + + builder.Text(`${Tab(1)}${ApiMethodToString(member.Name, memberTypeParameters, parameters, member.ReturnType)};`); + }); + + const propertyMembers = GetApiItemsFromReference( + apiItem.Members, + extractedData, + Contracts.ApiItemKinds.Property + ); + propertyMembers.forEach(member => { + builder.Text(`${Tab(1)}${ApiPropertyToString(member)};`); + }); + + builder.Text("}"); + + return builder.GetOutput(); + } + + export function ApiPropertyToString(apiItem: Contracts.ApiPropertyDto): string { + const isReadOnlyString = apiItem.IsReadonly ? "readonly " : ""; + const isOptionalString = apiItem.IsReadonly ? "?" : ""; + const returnTypeString = apiItem.Type.Text; + return `${isReadOnlyString}${apiItem.Name}${isOptionalString}: ${returnTypeString}`; + } + + // TODO: add description from @template jsdoc tag. + export function ApiTypeParametersTableToString(typeParameters: Contracts.ApiTypeParameterDto[]): ReferenceDto { + if (typeParameters.length === 0) { + return { + References: [], + Text: [] + }; + } + + let referenceIds: string[] = []; + const header = ["Name", "Constraint type", "Default type"]; + const content = typeParameters.map(typeParameter => { + let constraintType: string = ""; + let defaultType: string = ""; + + if (typeParameter.ConstraintType) { + const parsedConstraintType = TypeDtoToMarkdownString(typeParameter.ConstraintType); + + referenceIds = referenceIds.concat(parsedConstraintType.References); + constraintType = MarkdownGenerator.EscapeString(parsedConstraintType.Text); + } + + if (typeParameter.DefaultType) { + const parsedDefaultType = TypeDtoToMarkdownString(typeParameter.DefaultType); + + referenceIds = referenceIds.concat(parsedDefaultType.References); + defaultType = MarkdownGenerator.EscapeString(parsedDefaultType.Text); + } + + return [typeParameter.Name, constraintType, defaultType]; + }); + + return { + References: referenceIds, + Text: MarkdownGenerator.Table(header, content, DEFAULT_TABLE_OPTIONS) + }; + } + + export function IsApiItemKind( + itemKind: Contracts.ApiItemKinds, + apiItem: Contracts.ApiItemDto): apiItem is TKindDto { + return apiItem.ApiKind === itemKind; + } + + // TODO: implement description. + // TODO: implement IsSpread. + export function ApiParametersToTableString(parameters: Contracts.ApiParameterDto[]): ReferenceDto { + if (parameters.length === 0) { + return { + References: [], + Text: [] + }; + } + + let referenceIds: string[] = []; + const header = ["Name", "Type", "Optional", "Initial value", "Description"]; + + const content = parameters.map(parameter => { + const parameterTypeDto = TypeDtoToMarkdownString(parameter.Type); + + referenceIds = referenceIds.concat(parameterTypeDto.References); + + const isOptionalString = parameter.IsOptional ? "Yes" : ""; + const initializerString = parameter.Initializer || ""; + + return [parameter.Name, MarkdownGenerator.EscapeString(parameterTypeDto.Text), isOptionalString, initializerString]; + }); + + return { + Text: MarkdownGenerator.Table(header, content, DEFAULT_TABLE_OPTIONS), + References: referenceIds + }; + } + + export function ApiIndexToString(parameter: Contracts.ApiParameterDto, type: Contracts.TypeDto, readOnly: boolean = false): string { + const typeString = TypeDtoToMarkdownString(type).Text; + const parameterTypeString = TypeDtoToMarkdownString(parameter.Type).Text; + + const readOnlyString = readOnly ? "readonly " : ""; + + return `${readOnlyString}[${parameter.Name}: ${parameterTypeString}]: ${typeString}`; + } + + export function ApiPropertiesToTableString(properties: Contracts.ApiPropertyDto[]): ReferenceDto { + if (properties.length === 0) { + return { + References: [], + Text: [] + }; + } + + let referenceIds: string[] = []; + const header = ["Name", "Type", "Optional"]; + + const content = properties.map(property => { + const parameterTypeDto = TypeDtoToMarkdownString(property.Type); + + referenceIds = referenceIds.concat(parameterTypeDto.References); + + const isOptionalString = property.IsOptional ? "Yes" : ""; + + return [property.Name, parameterTypeDto.Text, isOptionalString]; + }); + + return { + Text: MarkdownGenerator.Table(header, content, DEFAULT_TABLE_OPTIONS), + References: referenceIds + }; + } + export function MergePluginResultData(a: T, b: Partial): T { a.Headings = a.Headings.concat(b.Headings || []); a.Members = (a.Members || []).concat(b.Members || []); diff --git a/packages/ts-docs-gen/src/plugins/api-callable-plugin.ts b/packages/ts-docs-gen/src/plugins/api-callable-plugin.ts new file mode 100644 index 00000000..73d144f8 --- /dev/null +++ b/packages/ts-docs-gen/src/plugins/api-callable-plugin.ts @@ -0,0 +1,97 @@ +import { Contracts } from "ts-extractor"; +import { MarkdownBuilder } from "@simplrjs/markdown"; + +import { Plugin, SupportedApiItemKindType, PluginResult, PluginOptions } from "../contracts/plugin"; +import { GeneratorHelpers } from "../generator-helpers"; + +export type CallableApiItem = Contracts.ApiCallDto | Contracts.ApiMethodDto | Contracts.ApiConstructDto; + +export class ApiCallablePlugin implements Plugin { + public SupportedApiItemKinds(): SupportedApiItemKindType[] { + return [ + GeneratorHelpers.ApiItemKinds.Construct, + GeneratorHelpers.ApiItemKinds.Call, + GeneratorHelpers.ApiItemKinds.Method + ]; + } + + public CheckApiItem(item: CallableApiItem): boolean { + return true; + } + + private resolveItemCode( + apiItem: CallableApiItem, + parameters: Contracts.ApiParameterDto[], + typeParameters: Contracts.ApiTypeParameterDto[] + ): string { + + switch (apiItem.ApiKind) { + case Contracts.ApiItemKinds.Construct: { + return GeneratorHelpers.ApiConstructToString(typeParameters, parameters, apiItem.ReturnType); + } + case Contracts.ApiItemKinds.Call: { + return GeneratorHelpers.ApiCallToString(typeParameters, parameters, apiItem.ReturnType); + } + case Contracts.ApiItemKinds.Method: { + return GeneratorHelpers.ApiMethodToString(apiItem.Name, typeParameters, parameters, apiItem.ReturnType); + } + } + } + + public Render(data: PluginOptions): PluginResult { + const usedReferences = []; + const parameters = GeneratorHelpers.GetApiItemsFromReference( + data.ApiItem.Parameters, + data.ExtractedData + ); + const typeParameters = GeneratorHelpers.GetApiItemsFromReference( + data.ApiItem.TypeParameters, + data.ExtractedData + ); + + const builder = new MarkdownBuilder() + .Code(this.resolveItemCode(data.ApiItem, parameters, typeParameters), GeneratorHelpers.DEFAULT_CODE_OPTIONS) + .EmptyLine(); + + if (typeParameters.length > 0) { + const table = GeneratorHelpers.ApiTypeParametersTableToString(typeParameters); + usedReferences.push(...table.References); + + builder + .Text("Type parameters:") + .EmptyLine() + .Text(table.Text) + .EmptyLine(); + } + + if (parameters.length > 0) { + const table = GeneratorHelpers.ApiParametersToTableString(parameters); + usedReferences.push(...table.References); + + builder + .Text("Parameters:") + .EmptyLine() + .Text(table.Text) + .EmptyLine(); + } + + if (data.ApiItem.ReturnType) { + const renderedReturnType = GeneratorHelpers.TypeDtoToMarkdownString(data.ApiItem.ReturnType); + + builder + .Text("Return type:") + .EmptyLine() + .Text(renderedReturnType.Text); + + usedReferences.push(...renderedReturnType.References); + } + + return { + ApiItem: data.ApiItem, + Reference: data.Reference, + Headings: [], + Result: builder.GetOutput(), + UsedReferences: usedReferences + }; + } +} diff --git a/packages/ts-docs-gen/src/plugins/api-function-plugin.ts b/packages/ts-docs-gen/src/plugins/api-function-plugin.ts index 62f07865..00093db5 100644 --- a/packages/ts-docs-gen/src/plugins/api-function-plugin.ts +++ b/packages/ts-docs-gen/src/plugins/api-function-plugin.ts @@ -1,5 +1,5 @@ import { Contracts } from "ts-extractor"; -import { MarkdownBuilder, MarkdownGenerator } from "@simplrjs/markdown"; +import { MarkdownBuilder } from "@simplrjs/markdown"; import { GeneratorHelpers } from "../generator-helpers"; import { SupportedApiItemKindType, Plugin, PluginResult, PluginOptions, PluginHeading } from "../contracts/plugin"; @@ -23,72 +23,34 @@ export class ApiFunctionPlugin implements Plugin { }; } - let referenceIds: string[] = []; - const header = ["Name", "Type", "Description"]; - - const content = parameters.map(parameter => { - const parameterTypeDto = GeneratorHelpers.TypeDtoToMarkdownString(parameter.Type); - - referenceIds = referenceIds.concat(parameterTypeDto.References); - - return [parameter.Name, MarkdownGenerator.EscapeString(parameterTypeDto.Text)]; - }); - - const text = new MarkdownBuilder() + const table = GeneratorHelpers.ApiParametersToTableString(parameters); + const builder = new MarkdownBuilder() .Header("Parameters", 3) .EmptyLine() - .Table(header, content, GeneratorHelpers.DEFAULT_TABLE_OPTIONS) - .EmptyLine() - .GetOutput(); + .Text(table.Text) + .EmptyLine(); return { - Text: text, - References: referenceIds + Text: builder.GetOutput(), + References: table.References }; } - // TODO: add description from @template jsdoc tag. private resolveFunctionTypeParameters(typeParameters: Contracts.ApiTypeParameterDto[]): GeneratorHelpers.ReferenceDto { - let referenceIds: string[] = []; - if (typeParameters.length === 0) { - return { - References: [], - Text: [] - }; + return { References: [], Text: [] }; } - const header = ["Name", "Constraint type", "Default type"]; - const content = typeParameters.map(typeParameter => { - let constraintType: string = ""; - let defaultType: string = ""; - - if (typeParameter.ConstraintType) { - const parsedConstraintType = GeneratorHelpers.TypeDtoToMarkdownString(typeParameter.ConstraintType); - - referenceIds = referenceIds.concat(parsedConstraintType.References); - constraintType = MarkdownGenerator.EscapeString(parsedConstraintType.Text); - } - - if (typeParameter.DefaultType) { - const parsedDefaultType = GeneratorHelpers.TypeDtoToMarkdownString(typeParameter.DefaultType); - - referenceIds = referenceIds.concat(parsedDefaultType.References); - defaultType = MarkdownGenerator.EscapeString(parsedDefaultType.Text); - } - - return [typeParameter.Name, constraintType, defaultType]; - }); - + const typeParametersTable = GeneratorHelpers.ApiTypeParametersTableToString(typeParameters); const text = new MarkdownBuilder() .Header("Type parameters", 3) .EmptyLine() - .Table(header, content, GeneratorHelpers.DEFAULT_TABLE_OPTIONS) + .Text(typeParametersTable.Text) .EmptyLine() .GetOutput(); return { - References: referenceIds, + References: typeParametersTable.References, Text: text }; } diff --git a/packages/ts-docs-gen/src/plugins/api-index-plugin.ts b/packages/ts-docs-gen/src/plugins/api-index-plugin.ts new file mode 100644 index 00000000..9f052af1 --- /dev/null +++ b/packages/ts-docs-gen/src/plugins/api-index-plugin.ts @@ -0,0 +1,50 @@ +import { Contracts } from "ts-extractor"; +import { MarkdownBuilder } from "@simplrjs/markdown"; + +import { Plugin, SupportedApiItemKindType, PluginResult, PluginOptions } from "../contracts/plugin"; +import { GeneratorHelpers } from "../generator-helpers"; + +export class ApiIndexPlugin implements Plugin { + public SupportedApiItemKinds(): SupportedApiItemKindType[] { + return [GeneratorHelpers.ApiItemKinds.Index]; + } + + public CheckApiItem(item: Contracts.ApiIndexDto): boolean { + return true; + } + + public Render(data: PluginOptions): PluginResult { + const parameter = data.ExtractedData.Registry[data.ApiItem.Parameter] as Contracts.ApiParameterDto; + + const parameterType = GeneratorHelpers.TypeDtoToMarkdownString(parameter.Type); + const indexType = GeneratorHelpers.TypeDtoToMarkdownString(data.ApiItem.Type); + + const indexDeclarationString = GeneratorHelpers.ApiIndexToString(parameter, data.ApiItem.Type, data.ApiItem.IsReadonly); + + const builder = new MarkdownBuilder() + .Code(indexDeclarationString, GeneratorHelpers.DEFAULT_CODE_OPTIONS) + .EmptyLine(); + + if (data.ApiItem.IsReadonly) { + builder + .Text("Readonly.") + .EmptyLine(); + } + + builder + .Text(`Index \`${parameter.Name}\` - ${parameterType.Text}`) + .EmptyLine() + .Text(`Type - ${indexType.Text}`); + + return { + ApiItem: data.ApiItem, + Reference: data.Reference, + Headings: [], + Result: builder.GetOutput(), + UsedReferences: [ + ...parameterType.References, + ...indexType.References + ] + }; + } +} diff --git a/packages/ts-docs-gen/src/plugins/api-interface-plugin.ts b/packages/ts-docs-gen/src/plugins/api-interface-plugin.ts new file mode 100644 index 00000000..9eb58f63 --- /dev/null +++ b/packages/ts-docs-gen/src/plugins/api-interface-plugin.ts @@ -0,0 +1,214 @@ +import { Contracts } from "ts-extractor"; +import { MarkdownBuilder, MarkdownGenerator } from "@simplrjs/markdown"; +import { + Plugin, + SupportedApiItemKindType, + PluginResult, + PluginOptions, + GetItemPluginResultHandler, + PluginResultData +} from "../contracts/plugin"; +import { GeneratorHelpers } from "../generator-helpers"; +import { ApiItemReference } from "../contracts/api-item-reference"; + +interface ExtractedItemDto { + Reference: ApiItemReference; + ApiItem: TApiItemDto; +} + +export class ApiInterfacePlugin implements Plugin { + public SupportedApiItemKinds(): SupportedApiItemKindType[] { + return [GeneratorHelpers.ApiItemKinds.Interface]; + } + + public CheckApiItem(item: Contracts.ApiInterfaceDto): boolean { + return true; + } + + private renderTypeParameters(pluginOptions: PluginOptions): PluginResultData { + const typeParameters = GeneratorHelpers.GetApiItemsFromReference( + pluginOptions.ApiItem.TypeParameters, + pluginOptions.ExtractedData + ); + + if (typeParameters.length === 0) { + return GeneratorHelpers.GetDefaultPluginResultData(); + } + + const typeParametersTable = GeneratorHelpers.ApiTypeParametersTableToString(typeParameters); + const text = new MarkdownBuilder() + .Header("Type parameters", 3) + .EmptyLine() + .Text(typeParametersTable.Text) + .EmptyLine() + .GetOutput(); + + return { + Result: text, + UsedReferences: typeParametersTable.References, + Headings: [] + }; + } + + private renderConstraintTypes(apiItem: Contracts.ApiInterfaceDto): PluginResultData { + if (apiItem.Extends.length === 0) { + return GeneratorHelpers.GetDefaultPluginResultData(); + } + + const builder = new MarkdownBuilder() + .Header("Extends", 3) + .EmptyLine(); + + const references = []; + + for (const type of apiItem.Extends) { + const typeDto = GeneratorHelpers.TypeDtoToMarkdownString(type); + references.push(...typeDto.References); + + builder + .Text(typeDto.Text) + .EmptyLine(); + } + + return { + UsedReferences: references, + Result: builder.GetOutput(), + Headings: [] + }; + } + + private renderPropertyMembers(memberItems: ExtractedItemDto[]): PluginResultData { + const apiItems = memberItems.filter>( + this.isReferenceOfApiItemKind.bind(undefined, Contracts.ApiItemKinds.Property) + ).map(x => x.ApiItem); + + if (apiItems.length === 0) { + return GeneratorHelpers.GetDefaultPluginResultData(); + } + + const table = GeneratorHelpers.ApiPropertiesToTableString(apiItems); + const builder = new MarkdownBuilder() + .Header("Properties", 3) + .EmptyLine() + .Text(table.Text); + + return { + UsedReferences: table.References, + Result: builder.GetOutput(), + Headings: [] + }; + } + + private isReferenceOfApiItemKind( + itemKind: Contracts.ApiItemKinds, + extractedItem: ExtractedItemDto + ): extractedItem is ExtractedItemDto { + return extractedItem.ApiItem.ApiKind === itemKind; + } + + private renderMemberItemsGroup( + title: string, + apiItemKind: Contracts.ApiItemKinds, + memberItems: ExtractedItemDto[], + getPluginResult: GetItemPluginResultHandler + ): PluginResultData { + const items = memberItems.filter(this.isReferenceOfApiItemKind.bind(undefined, apiItemKind)); + + if (items.length === 0) { + return GeneratorHelpers.GetDefaultPluginResultData(); + } + + const pluginResult = GeneratorHelpers.GetDefaultPluginResultData(); + pluginResult.Result.push(MarkdownGenerator.Header(title, 3), ""); + + for (const item of items) { + const itemPluginResult = getPluginResult(item.Reference); + + GeneratorHelpers.MergePluginResultData(pluginResult, itemPluginResult); + pluginResult.Result.push("", MarkdownGenerator.HorizontalRule(), ""); + } + + return pluginResult; + } + + public Render(data: PluginOptions): PluginResult { + const alias = data.Reference.Alias; + const pluginResult: PluginResult = { + ...GeneratorHelpers.GetDefaultPluginResultData(), + ApiItem: data.ApiItem, + Reference: data.Reference, + Headings: [ + { + ApiItemId: data.Reference.Id, + Heading: alias + } + ] + }; + + const memberReferences = GeneratorHelpers.GetApiItemReferences(data.ExtractedData, data.ApiItem.Members); + const memberItems = memberReferences.map(itemReference => ({ + Reference: itemReference, + ApiItem: data.ExtractedData.Registry[itemReference.Id] + })); + + const interfaceString = GeneratorHelpers.ApiInterfaceToString(data.ApiItem, data.ExtractedData); + const builder = new MarkdownBuilder() + .Header(GeneratorHelpers.ApiInterfaceToSimpleString(alias, data.ApiItem), 2) + .EmptyLine() + .Text(GeneratorHelpers.RenderApiItemMetadata(data.ApiItem)) + .Code(interfaceString, GeneratorHelpers.DEFAULT_CODE_OPTIONS) + .EmptyLine(); + + pluginResult.Result = builder.GetOutput(); + + // Type parameters + const typeParametersResult = this.renderTypeParameters(data); + GeneratorHelpers.MergePluginResultData(pluginResult, typeParametersResult); + + // Constraint types + const constraintTypesResult = this.renderConstraintTypes(data.ApiItem); + GeneratorHelpers.MergePluginResultData(pluginResult, constraintTypesResult); + + // Construct items + const constructMembersResult = this.renderMemberItemsGroup( + "Construct", + Contracts.ApiItemKinds.Construct, + memberItems, + data.GetItemPluginResult + ); + GeneratorHelpers.MergePluginResultData(pluginResult, constructMembersResult); + + // Call items + const callMembersResult = this.renderMemberItemsGroup( + "Call", + Contracts.ApiItemKinds.Call, + memberItems, + data.GetItemPluginResult + ); + GeneratorHelpers.MergePluginResultData(pluginResult, callMembersResult); + + // Index items + const indexMembersResult = this.renderMemberItemsGroup( + "Index signatures", + Contracts.ApiItemKinds.Index, + memberItems, + data.GetItemPluginResult + ); + GeneratorHelpers.MergePluginResultData(pluginResult, indexMembersResult); + + // Method items + const methodMembersResult = this.renderMemberItemsGroup( + "Methods", + Contracts.ApiItemKinds.Method, + memberItems, + data.GetItemPluginResult + ); + GeneratorHelpers.MergePluginResultData(pluginResult, methodMembersResult); + + // Property items + const propertyMembersResult = this.renderPropertyMembers(memberItems); + GeneratorHelpers.MergePluginResultData(pluginResult, propertyMembersResult); + + return pluginResult; + } +} diff --git a/packages/ts-docs-gen/tests/cases/__tests__/__snapshots__/simple-project-1.test.ts.snap b/packages/ts-docs-gen/tests/cases/__tests__/__snapshots__/simple-project-1.test.ts.snap index 3af0b655..e6ae0e08 100644 --- a/packages/ts-docs-gen/tests/cases/__tests__/__snapshots__/simple-project-1.test.ts.snap +++ b/packages/ts-docs-gen/tests/cases/__tests__/__snapshots__/simple-project-1.test.ts.snap @@ -5,6 +5,13 @@ Array [ Object { "FileLocation": "index.md", "Result": Array [ + "[InterfaceDeclaration-1]: index.md#foointerface", + "[InterfaceDeclaration-2]: index.md#boo", + "[InterfaceDeclaration-4]: index.md#myconstrainttype", + "[InterfaceDeclaration-9]: index.md#dictionary", + "[InterfaceDeclaration-9]: index.md#dictionary", + "[InterfaceDeclaration-6]: index.md#objectsinterface", + "[InterfaceDeclaration-12]: index.md#monsterinterface", "[ClassDeclaration-0]: index/foo.md#foo", "[ClassDeclaration-1]: index/world.md#world", "[ClassDeclaration-2]: index/earth.md#earth", @@ -12,6 +19,546 @@ Array [ "[ClassDeclaration-1]: index/world.md#world", "# index", "", + "## interface ExtendedBar", + "", + "\`\`\`typescript", + "interface ExtendedBar extends FooInterface, Boo {", + " OtherStuff: string[];", + "}", + "\`\`\`", + "", + "### Extends", + "", + "[FooInterface][InterfaceDeclaration-1]<number>", + "", + "[Boo][InterfaceDeclaration-2]", + "", + "### Properties", + "", + "| Name | Type |", + "| ---------- | --------------------- |", + "| OtherStuff | Array<string> |", + "", + "## interface FooInterface", + "", + "\`\`\`typescript", + "interface FooInterface {", + " Name: string;", + " Surname: string;", + " Type: TType;", + "}", + "\`\`\`", + "", + "### Type parameters", + "", + "| Name |", + "| ----- |", + "| TType |", + "", + "### Properties", + "", + "| Name | Type |", + "| ------- | ------ |", + "| Name | string |", + "| Surname | string |", + "| Type | TType |", + "", + "## interface Boo", + "", + "\`\`\`typescript", + "interface Boo {", + " Boos: string[];", + "}", + "\`\`\`", + "", + "### Properties", + "", + "| Name | Type |", + "| ---- | --------------------- |", + "| Boos | Array<string> |", + "", + "## interface AnotherInterface", + "", + "\`\`\`typescript", + "interface AnotherInterface {", + " (param1: TValue, param2: TValue): boolean;", + "}", + "\`\`\`", + "", + "### Call", + "", + "\`\`\`typescript", + "(param1: TValue, param2: TValue): boolean", + "\`\`\`", + "", + "Type parameters:", + "", + "| Name |", + "| ------ |", + "| TValue |", + "", + "Parameters:", + "", + "| Name | Type |", + "| ------ | ------ |", + "| param1 | TValue |", + "| param2 | TValue |", + "", + "Return type:", + "", + "true | false", + "", + "---", + "", + "", + "## interface MyConstraintType", + "", + "\`\`\`typescript", + "interface MyConstraintType {", + " myProperty: string;", + "}", + "\`\`\`", + "", + "### Properties", + "", + "| Name | Type |", + "| ---------- | ------ |", + "| myProperty | string |", + "", + "## interface MyDefaultType", + "", + "\`\`\`typescript", + "interface MyDefaultType extends MyConstraintType {", + " anotherProperty: number;", + "}", + "\`\`\`", + "", + "### Extends", + "", + "[MyConstraintType][InterfaceDeclaration-4]", + "", + "### Properties", + "", + "| Name | Type |", + "| --------------- | ------ |", + "| anotherProperty | number |", + "", + "## interface ObjectsInterface", + "", + "\`\`\`typescript", + "interface ObjectsInterface {", + " objectOne: Object;", + " objectTwo: Object;", + "}", + "\`\`\`", + "", + "### Properties", + "", + "| Name | Type |", + "| --------- | ------ |", + "| objectOne | Object |", + "| objectTwo | Object |", + "", + "## interface InterfaceWithCall", + "", + "\`\`\`typescript", + "interface InterfaceWithCall {", + " (): { someProperty: T; };", + "}", + "\`\`\`", + "", + "### Call", + "", + "\`\`\`typescript", + "(): { someProperty: T; }", + "\`\`\`", + "", + "Type parameters:", + "", + "| Name |", + "| ---- |", + "| T |", + "", + "Return type:", + "", + "{ someProperty: T; }", + "", + "---", + "", + "", + "## interface InterfaceWithConstraintType", + "", + "\`\`\`typescript", + "interface InterfaceWithConstraintType extends Dictionary {", + " someProperty: string;", + "}", + "\`\`\`", + "", + "### Extends", + "", + "[Dictionary][InterfaceDeclaration-9]<string>", + "", + "### Properties", + "", + "| Name | Type |", + "| ------------ | ------ |", + "| someProperty | string |", + "", + "## interface InterfaceWithMethod", + "", + "\`\`\`typescript", + "interface InterfaceWithMethod {", + " someMethodOne(): T;", + " someMethodTwo(): TReturn;", + "}", + "\`\`\`", + "", + "### Type parameters", + "", + "| Name |", + "| ---- |", + "| T |", + "", + "### Methods", + "", + "\`\`\`typescript", + "someMethodOne(): T", + "\`\`\`", + "", + "Return type:", + "", + "T", + "", + "---", + "", + "\`\`\`typescript", + "someMethodTwo(): TReturn", + "\`\`\`", + "", + "Type parameters:", + "", + "| Name |", + "| ------- |", + "| TReturn |", + "", + "Return type:", + "", + "TReturn", + "", + "---", + "", + "", + "## interface Dictionary", + "", + "\`\`\`typescript", + "interface Dictionary {", + " new (): Dictionary;", + " [key: string]: TValue;", + "}", + "\`\`\`", + "", + "### Type parameters", + "", + "| Name |", + "| ------ |", + "| TValue |", + "", + "### Construct", + "", + "\`\`\`typescript", + "new (): Dictionary", + "\`\`\`", + "", + "Return type:", + "", + "[Dictionary][InterfaceDeclaration-9]<TValue>", + "", + "---", + "", + "### Index signatures", + "", + "\`\`\`typescript", + "[key: string]: TValue", + "\`\`\`", + "", + "Index \`key\` - string", + "", + "Type - TValue", + "", + "---", + "", + "", + "## interface MethodsInterface", + "", + "\`\`\`typescript", + "interface MethodsInterface {", + " (arg: TValue): void;", + " someMethod(): string;", + "}", + "\`\`\`", + "", + "### Call", + "", + "\`\`\`typescript", + "(arg: TValue): void", + "\`\`\`", + "", + "Type parameters:", + "", + "| Name |", + "| ------ |", + "| TValue |", + "", + "Parameters:", + "", + "| Name | Type |", + "| ---- | ------ |", + "| arg | TValue |", + "", + "Return type:", + "", + "void", + "", + "---", + "", + "### Methods", + "", + "\`\`\`typescript", + "someMethod(): string", + "\`\`\`", + "", + "Type parameters:", + "", + "| Name |", + "| ---- |", + "| T |", + "", + "Return type:", + "", + "string", + "", + "---", + "", + "", + "## interface MonsterInterface", + "", + "Warning: Beta!", + "", + "Deprecated!", + "", + "Monster interface", + "", + "\`\`\`typescript", + "interface MonsterInterface extends ObjectsInterface {", + " new (): MonsterInterface;", + " new (someParameter: string): string;", + " (): { someProperty: T; };", + " (key?: string | undefined): { someProperty: T; };", + " (key: number): { someProperty: T; };", + " readonly [key: string]: TValue;", + " readonly objectOne?: TValue;", + " objectTwo: TValue;", + "}", + "\`\`\`", + "", + "### Type parameters", + "", + "| Name | Constraint type | Default type |", + "| ------ | --------------- | ------------ |", + "| TValue | Object | \\\\{\\\\} |", + "", + "### Extends", + "", + "[ObjectsInterface][InterfaceDeclaration-6]", + "", + "### Construct", + "", + "\`\`\`typescript", + "new (): MonsterInterface", + "\`\`\`", + "", + "Type parameters:", + "", + "| Name |", + "| ---- |", + "| T |", + "", + "Return type:", + "", + "[MonsterInterface][InterfaceDeclaration-12]<T>", + "", + "---", + "", + "\`\`\`typescript", + "new (someParameter: string): string", + "\`\`\`", + "", + "Parameters:", + "", + "| Name | Type |", + "| ------------- | ------ |", + "| someParameter | string |", + "", + "Return type:", + "", + "string", + "", + "---", + "", + "### Call", + "", + "\`\`\`typescript", + "(): { someProperty: T; }", + "\`\`\`", + "", + "Type parameters:", + "", + "| Name |", + "| ---- |", + "| T |", + "", + "Return type:", + "", + "{ someProperty: T; }", + "", + "---", + "", + "\`\`\`typescript", + "(key?: string | undefined): { someProperty: T; }", + "\`\`\`", + "", + "Type parameters:", + "", + "| Name |", + "| ---- |", + "| T |", + "", + "Parameters:", + "", + "| Name | Type | Optional |", + "| ---- | ----------------------- | -------- |", + "| key | undefined | string | Yes |", + "", + "Return type:", + "", + "{ someProperty: T; }", + "", + "---", + "", + "\`\`\`typescript", + "(key: number): { someProperty: T; }", + "\`\`\`", + "", + "Type parameters:", + "", + "| Name |", + "| ---- |", + "| T |", + "", + "Parameters:", + "", + "| Name | Type |", + "| ---- | ------ |", + "| key | number |", + "", + "Return type:", + "", + "{ someProperty: T; }", + "", + "---", + "", + "### Index signatures", + "", + "\`\`\`typescript", + "readonly [key: string]: TValue", + "\`\`\`", + "", + "Readonly.", + "", + "Index \`key\` - string", + "", + "Type - TValue", + "", + "---", + "", + "### Properties", + "", + "| Name | Type |", + "| --------- | ------ |", + "| objectOne | TValue |", + "| objectTwo | TValue |", + "", + "## interface SomeInterface", + "", + "\`\`\`typescript", + "interface SomeInterface {", + " [key: string]: string | number;", + " [key: number]: string;", + "}", + "\`\`\`", + "", + "### Index signatures", + "", + "\`\`\`typescript", + "[key: string]: string | number", + "\`\`\`", + "", + "Index \`key\` - string", + "", + "Type - string | number", + "", + "---", + "", + "\`\`\`typescript", + "[key: number]: string", + "\`\`\`", + "", + "Index \`key\` - number", + "", + "Type - string", + "", + "---", + "", + "", + "## interface StringsDictionary", + "", + "\`\`\`typescript", + "interface StringsDictionary {", + " [key: string]: string;", + "}", + "\`\`\`", + "", + "### Index signatures", + "", + "\`\`\`typescript", + "[key: string]: string", + "\`\`\`", + "", + "Index \`key\` - string", + "", + "Type - string", + "", + "---", + "", + "", + "## interface MyInterface", + "", + "\`\`\`typescript", + "interface MyInterface {", + " MyPropertyOne: string;", + " MyPropertyTwo: Object;", + " MyPropertyThree: number;", + "}", + "\`\`\`", + "", + "### Properties", + "", + "| Name | Type |", + "| --------------- | ------ |", + "| MyPropertyOne | string |", + "| MyPropertyTwo | Object |", + "| MyPropertyThree | number |", + "", "## EnumList", "", "Simple list.", @@ -101,10 +648,10 @@ Array [ "", "### Parameters", "", - "| Name | Type |", - "| ---------- | ------- |", - "| parameter1 | string |", - "| parameter2 | Promise |", + "| Name | Type |", + "| ---------- | -------------------- |", + "| parameter1 | string |", + "| parameter2 | Promise&\\\\#60;T&\\\\#62; |", "", "### Return type", "", @@ -119,7 +666,7 @@ Array [ "", "### Return type", "", - "Promise", + "Promise<void>", "", "", "## FunctionWithOneParameter(parameter)", @@ -279,16 +826,16 @@ Array [ "", "### Type parameters", "", - "| Name | Constraint type |", - "| ---- | --------------- |", - "| T | Array |", + "| Name | Constraint type |", + "| ---- | ------------------ |", + "| T | Array&\\\\#60;T&\\\\#62; |", "", "### Parameters", "", - "| Name | Type |", - "| ---------- | ------- |", - "| parameter1 | string |", - "| parameter2 | Promise |", + "| Name | Type |", + "| ---------- | -------------------- |", + "| parameter1 | string |", + "| parameter2 | Promise&\\\\#60;T&\\\\#62; |", "", "### Return type", "", @@ -303,7 +850,7 @@ Array [ "", "### Return type", "", - "Array", + "Array<string>", "", "", "## FunctionWithPrimitiveReturnType()", @@ -349,15 +896,49 @@ Array [ "", "### Type parameters", "", - "| Name | Constraint type | Default type |", - "| ---- | -------------------------------------------------------------- | ------------------------- |", - "| T | \\\\{ myProperty: string; myPropertyTwo?: number \\\\| undefined; \\\\} | \\\\{ myProperty: string; \\\\} |", + "| Name | Constraint type | Default type |", + "| ---- | ------------------------------------------------------------------ | ------------------------- |", + "| T | \\\\{ myProperty: string; myPropertyTwo?: number | undefined; \\\\} | \\\\{ myProperty: string; \\\\} |", "", "### Return type", "", "T", "", "", + "## FunctionWithInitializedNumberParameter(someParameter)", + "", + "\`\`\`typescript", + "function FunctionWithInitializedNumberParameter(someParameter: number = 12): number", + "\`\`\`", + "", + "### Parameters", + "", + "| Name | Type | Initial value |", + "| ------------- | ------ | ------------- |", + "| someParameter | number | 12 |", + "", + "### Return type", + "", + "number", + "", + "", + "## FunctionWithInitializedStringParameter(someParameter)", + "", + "\`\`\`typescript", + "function FunctionWithInitializedStringParameter(someParameter: string = \\"12\\"): string", + "\`\`\`", + "", + "### Parameters", + "", + "| Name | Type | Initial value |", + "| ------------- | ------ | ------------- |", + "| someParameter | string | \\"12\\" |", + "", + "### Return type", + "", + "string", + "", + "", "", ], }, diff --git a/packages/ts-docs-gen/tests/cases/simple-project-1/index.ts b/packages/ts-docs-gen/tests/cases/simple-project-1/index.ts index eeaf5349..14e297b0 100644 --- a/packages/ts-docs-gen/tests/cases/simple-project-1/index.ts +++ b/packages/ts-docs-gen/tests/cases/simple-project-1/index.ts @@ -1,3 +1,94 @@ +// #region Interfaces +export interface ExtendedBar extends FooInterface, Boo { + OtherStuff: string[]; +} + +export interface FooInterface { + Name: string; + Surname: string; + Type: TType; +} + +export interface Boo { + Boos: string[]; +} + +export interface AnotherInterface { + (param1: TValue, param2: TValue): boolean; +} + +export interface MyConstraintType { + myProperty: string; +} + +export interface MyDefaultType extends MyConstraintType { + anotherProperty: number; +} + +export interface ObjectsInterface { + objectOne: Object; + objectTwo: Object; +} + +export interface InterfaceWithCall { + (): { someProperty: T }; +} + +export interface InterfaceWithConstraintType extends Dictionary { + someProperty: string; +} + +export interface InterfaceWithMethod { + someMethodOne(): T; + someMethodTwo(): TReturn; +} + +export interface Dictionary { + new(): Dictionary; + [key: string]: TValue; +} + +export interface MethodsInterface { + someMethod(): string; + (arg: TValue): void; +} + +/** + * Monster interface + * @beta + * @deprecated + */ +export interface MonsterInterface extends ObjectsInterface { + new (): MonsterInterface; + new(someParameter: string): string; + + readonly [key: string]: TValue; + + (): { someProperty: T }; + (key?: string): { someProperty: T }; + (key: number): { someProperty: T }; + + readonly objectOne: TValue; + objectTwo: TValue; +} + +export interface SomeInterface { + [key: string]: string | number; + [key: number]: string; +} + +export interface StringsDictionary { + [key: string]: string; +} + +export interface MyInterface { + MyPropertyOne: string; + MyPropertyTwo: Object; + MyPropertyThree: number; +} +// #endregion Interfaces + + // #region Enums /** * Simple list. @@ -137,4 +228,12 @@ export function MyFunction