From 79979b47e4e645e1107221228e89e74278bcf1d9 Mon Sep 17 00:00:00 2001 From: Marten Mrfc <101009922+Marten-Mrfc@users.noreply.github.com> Date: Wed, 4 Sep 2024 16:25:03 +0200 Subject: [PATCH] [Docs] (hopefully) temporary build fixes --- .../02-extensions/07-api-changes/0.6.mdx | 2 +- documentation/docusaurus.config.js | 6 +- documentation/package-lock.json | 147 ++++++++++-------- .../plugins/code-snippets/codeSnippets.js | 71 ++++++--- .../plugins/code-snippets/snippets.json | 118 +++++--------- 5 files changed, 180 insertions(+), 164 deletions(-) diff --git a/documentation/docs/develop/02-extensions/07-api-changes/0.6.mdx b/documentation/docs/develop/02-extensions/07-api-changes/0.6.mdx index 966a86d1e3..4960a75743 100644 --- a/documentation/docs/develop/02-extensions/07-api-changes/0.6.mdx +++ b/documentation/docs/develop/02-extensions/07-api-changes/0.6.mdx @@ -5,6 +5,6 @@ title: 0.6.X API Changes # All API changes to 0.6.X As Typewriter changed from `Adapters` to `Extensions`, the API has changed significantly. -It is recommended to reread the [Getting Started](getting_started) guide to get a better understanding of how to create extensions. +It is recommended to reread the [Getting Started](../02-getting_started.mdx) guide to get a better understanding of how to create extensions. diff --git a/documentation/docusaurus.config.js b/documentation/docusaurus.config.js index 1ae08ce989..7948440af8 100644 --- a/documentation/docusaurus.config.js +++ b/documentation/docusaurus.config.js @@ -120,10 +120,10 @@ const config = { label: 'Documentation', }, { - type: 'docSidebar', - sidebarId: 'adapters', - position: 'left', + type: 'docsVersion', label: 'Extensions', + to: '/adapters', + position: 'left', }, { type: 'docSidebar', diff --git a/documentation/package-lock.json b/documentation/package-lock.json index 45341b336f..b522731ab2 100644 --- a/documentation/package-lock.json +++ b/documentation/package-lock.json @@ -177,9 +177,9 @@ } }, "node_modules/@algolia/client-common": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.2.3.tgz", - "integrity": "sha512-zqfcbgjYR72Y/rx/+/6g5Li/eV33yhRq5mkGbU06JYBzvGq6viy0gZl1ckCFhLLifKzXZ4yzUQTw/KG6FV+smg==", + "version": "5.2.5", + "resolved": "https://registry.npmjs.org/@algolia/client-common/-/client-common-5.2.5.tgz", + "integrity": "sha512-ITE85veJWwClnoNyv7Zydh9U0eKA82cDy8pLw+2hzL+zlzFIvV68ihGOEQ/kXt8N4v+R4MFzvsxnIpMruQzEug==", "license": "MIT", "peer": true, "engines": { @@ -208,15 +208,15 @@ } }, "node_modules/@algolia/client-search": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.2.3.tgz", - "integrity": "sha512-xXdCg8vpiwE8gqSyvjxq8V3qbFa+gHasY5epIz718IByWv3WKLLi/n4SMIfB/zRwXTLVWeGOH/UJSz5VCnAAqg==", + "version": "5.2.5", + "resolved": "https://registry.npmjs.org/@algolia/client-search/-/client-search-5.2.5.tgz", + "integrity": "sha512-OVDLzm5BEUbJmjfMm7b0Xx8vkK+NyEh7whPHuap2qy0x7RxQDLMXjiKsBbt1WNq+9nfX6+M/f2t0CJ8ENVuyYQ==", "license": "MIT", "peer": true, "dependencies": { - "@algolia/client-common": "5.2.3", - "@algolia/requester-browser-xhr": "5.2.3", - "@algolia/requester-node-http": "5.2.3" + "@algolia/client-common": "5.2.5", + "@algolia/requester-browser-xhr": "5.2.5", + "@algolia/requester-node-http": "5.2.5" }, "engines": { "node": ">= 14.0.0" @@ -302,13 +302,13 @@ } }, "node_modules/@algolia/requester-browser-xhr": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.2.3.tgz", - "integrity": "sha512-lezcE4E7ax7JkDGDKA/xAnyAY9p9LZ4AxzsyL0pksqUpOvn4U0msP553M2yJRfsxxdGDp15noCnPuRsh7u8dMg==", + "version": "5.2.5", + "resolved": "https://registry.npmjs.org/@algolia/requester-browser-xhr/-/requester-browser-xhr-5.2.5.tgz", + "integrity": "sha512-Ri73PphNy1ceig94xJW9bPdN7uIYFAjpsABpp2Fsun4DmeZD5a4rMCNwwOXXsbC8h+lUzW34zpUf+h4Nk+eaqA==", "license": "MIT", "peer": true, "dependencies": { - "@algolia/client-common": "5.2.3" + "@algolia/client-common": "5.2.5" }, "engines": { "node": ">= 14.0.0" @@ -321,13 +321,13 @@ "license": "MIT" }, "node_modules/@algolia/requester-node-http": { - "version": "5.2.3", - "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.2.3.tgz", - "integrity": "sha512-xTxsRnJqxG1dylIkxmflrHO9LJfJKjSHqEF5yGdRrtnqIEvb2hiQPCHm2XwqxMa3NBcf6lmydGfJqhPLnRJwtw==", + "version": "5.2.5", + "resolved": "https://registry.npmjs.org/@algolia/requester-node-http/-/requester-node-http-5.2.5.tgz", + "integrity": "sha512-/tTdEuWcWHSe/mGMomWkuaFDoRcpfl/jvGISVTPRq3pJvM1FPAzxlh2MXge6C30aUS9bxh3V0aWwgKFCilzyMQ==", "license": "MIT", "peer": true, "dependencies": { - "@algolia/client-common": "5.2.3" + "@algolia/client-common": "5.2.5" }, "engines": { "node": ">= 14.0.0" @@ -4755,9 +4755,9 @@ "license": "MIT" }, "node_modules/@types/node": { - "version": "22.5.1", - "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.1.tgz", - "integrity": "sha512-KkHsxej0j9IW1KKOOAA/XBA0z08UFSrRQHErzEfA3Vgq57eXIMYboIlHJuYIfd+lwCQjtKqUu3UnmKbtUc9yRw==", + "version": "22.5.3", + "resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.3.tgz", + "integrity": "sha512-njripolh85IA9SQGTAqbmnNZTdxv7X/4OYGPz8tgy5JDr8MP+uDBa921GpYEoDDnwm0Hmn5ZPeJgiiSTPoOzkQ==", "license": "MIT", "dependencies": { "undici-types": "~6.19.2" @@ -4803,9 +4803,9 @@ "license": "MIT" }, "node_modules/@types/react": { - "version": "18.3.4", - "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.4.tgz", - "integrity": "sha512-J7W30FTdfCxDDjmfRM+/JqLHBIyl7xUIp9kwK637FGmY7+mkSFSe6L4jpZzhj5QMfLssSDP4/i75AKkrdC7/Jw==", + "version": "18.3.5", + "resolved": "https://registry.npmjs.org/@types/react/-/react-18.3.5.tgz", + "integrity": "sha512-WeqMfGJLGuLCqHGYRGHxnKrXcTitc6L/nBUWfWPcTarG3t9PsquqUMuVeXZeca+mglY4Vo5GZjCi0A3Or2lnxA==", "license": "MIT", "dependencies": { "@types/prop-types": "*", @@ -5582,9 +5582,9 @@ "optional": true }, "node_modules/bare-fs": { - "version": "2.3.2", - "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.3.2.tgz", - "integrity": "sha512-Kcq/FG3lhspzGHK+Q0IMfImuFOmaW/jFofBAUJuuG7H67879JeaPUppUHhgLjJKenfxiO6Ix2AGSd47Pf7mRxg==", + "version": "2.3.3", + "resolved": "https://registry.npmjs.org/bare-fs/-/bare-fs-2.3.3.tgz", + "integrity": "sha512-7RYKL+vZVCyAsMLi5SPu7QGauGGT8avnP/HO571ndEuV4MYdGXvLhtW67FuLPeEI8EiIY7zbbRR9x7x7HU0kgw==", "dev": true, "license": "Apache-2.0", "optional": true, @@ -5595,9 +5595,9 @@ } }, "node_modules/bare-os": { - "version": "2.4.1", - "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-2.4.1.tgz", - "integrity": "sha512-yQC/blMP/eUdULsF7hrcC9tUFXlUmAWRbSQndEln77nOIh/N4Loaqch/MA4hyoDKhw1Zd1Wj+uLV/bT6lC/4BQ==", + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/bare-os/-/bare-os-2.4.2.tgz", + "integrity": "sha512-HZoJwzC+rZ9lqEemTMiO0luOePoGYNBgsLLgegKR/cljiJvcDNhDZQkzC+NC5Oh0aHbdBNSOHpghwMuB5tqhjg==", "dev": true, "license": "Apache-2.0", "optional": true @@ -5614,13 +5614,14 @@ } }, "node_modules/bare-stream": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.2.0.tgz", - "integrity": "sha512-+o9MG5bPRRBlkVSpfFlMag3n7wMaIZb4YZasU2+/96f+3HTQ4F9DKQeu3K/Sjz1W0umu6xvVq1ON0ipWdMlr3A==", + "version": "2.2.1", + "resolved": "https://registry.npmjs.org/bare-stream/-/bare-stream-2.2.1.tgz", + "integrity": "sha512-YTB47kHwBW9zSG8LD77MIBAAQXjU2WjAkMHeeb7hUplVs6+IoM5I7uEVQNPMB7lj9r8I76UMdoMkGnCodHOLqg==", "dev": true, "license": "Apache-2.0", "optional": true, "dependencies": { + "b4a": "^1.6.6", "streamx": "^2.18.0" } }, @@ -8691,9 +8692,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.6", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", - "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", + "version": "1.15.8", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.8.tgz", + "integrity": "sha512-xgrmBhBToVKay1q2Tao5LI26B83UhrB/vM1avwVSDzt8rx3rO6AizBAaF46EgksTVr+rFTQaqZZ9MVBfUe4nig==", "funding": [ { "type": "individual", @@ -10614,9 +10615,9 @@ } }, "node_modules/launch-editor": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.8.1.tgz", - "integrity": "sha512-elBx2l/tp9z99X5H/qev8uyDywVh0VXAwEbjk8kJhnc5grOFkGh7aW6q55me9xnYbss261XtnUrysZ+XvGbhQA==", + "version": "2.8.2", + "resolved": "https://registry.npmjs.org/launch-editor/-/launch-editor-2.8.2.tgz", + "integrity": "sha512-eF5slEUZXmi6WvFzI3dYcv+hA24/iKnROf24HztcURJpSz9RBmBgz5cNCVOeguouf1llrwy6Yctl4C4HM+xI8g==", "license": "MIT", "dependencies": { "picocolors": "^1.0.0", @@ -12422,9 +12423,9 @@ "license": "MIT" }, "node_modules/micromark-extension-mdx-jsx": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/micromark-extension-mdx-jsx/-/micromark-extension-mdx-jsx-3.0.0.tgz", - "integrity": "sha512-uvhhss8OGuzR4/N17L1JwvmJIpPhAd8oByMawEKx6NVdBCbesjH4t+vjEp3ZXft9DwvlKSD07fCeI44/N0Vf2w==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/micromark-extension-mdx-jsx/-/micromark-extension-mdx-jsx-3.0.1.tgz", + "integrity": "sha512-vNuFb9czP8QCtAQcEJn0UJQJZA8Dk6DXKBqx+bg/w0WGuSxDxNr7hErW89tHUY31dUW4NqEOWwmEUNhjTFmHkg==", "license": "MIT", "dependencies": { "@types/acorn": "^4.0.0", @@ -12434,6 +12435,7 @@ "micromark-factory-mdx-expression": "^2.0.0", "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", + "micromark-util-events-to-acorn": "^2.0.0", "micromark-util-symbol": "^2.0.0", "micromark-util-types": "^2.0.0", "vfile-message": "^4.0.0" @@ -12705,9 +12707,9 @@ "license": "MIT" }, "node_modules/micromark-factory-mdx-expression": { - "version": "2.0.1", - "resolved": "https://registry.npmjs.org/micromark-factory-mdx-expression/-/micromark-factory-mdx-expression-2.0.1.tgz", - "integrity": "sha512-F0ccWIUHRLRrYp5TC9ZYXmZo+p2AM13ggbsW4T0b5CRKP8KHVRB8t4pwtBgTxtjRmwrK0Irwm7vs2JOZabHZfg==", + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/micromark-factory-mdx-expression/-/micromark-factory-mdx-expression-2.0.2.tgz", + "integrity": "sha512-5E5I2pFzJyg2CtemqAbcyCktpHXuJbABnsb32wX2U8IQKhhVFBqkcZR5LRm1WVoFqa4kTueZK4abep7wdo9nrw==", "funding": [ { "type": "GitHub Sponsors", @@ -12722,6 +12724,7 @@ "dependencies": { "@types/estree": "^1.0.0", "devlop": "^1.0.0", + "micromark-factory-space": "^2.0.0", "micromark-util-character": "^2.0.0", "micromark-util-events-to-acorn": "^2.0.0", "micromark-util-symbol": "^2.0.0", @@ -12730,6 +12733,26 @@ "vfile-message": "^4.0.0" } }, + "node_modules/micromark-factory-mdx-expression/node_modules/micromark-factory-space": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/micromark-factory-space/-/micromark-factory-space-2.0.0.tgz", + "integrity": "sha512-TKr+LIDX2pkBJXFLzpyPyljzYK3MtmllMUMODTQJIUfDGncESaqB90db9IAUcz4AZAJFdd8U9zOp9ty1458rxg==", + "funding": [ + { + "type": "GitHub Sponsors", + "url": "https://github.com/sponsors/unifiedjs" + }, + { + "type": "OpenCollective", + "url": "https://opencollective.com/unified" + } + ], + "license": "MIT", + "dependencies": { + "micromark-util-character": "^2.0.0", + "micromark-util-types": "^2.0.0" + } + }, "node_modules/micromark-factory-mdx-expression/node_modules/micromark-util-character": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/micromark-util-character/-/micromark-util-character-2.1.0.tgz", @@ -14301,9 +14324,9 @@ } }, "node_modules/picocolors": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.0.1.tgz", - "integrity": "sha512-anP1Z8qwhkbmu7MFP5iTt+wQKXgwzf7zTyGlcdzabySa9vd0Xt392U0rVmz9poOaBj0uHJKyyo9/upk0HrEQew==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/picocolors/-/picocolors-1.1.0.tgz", + "integrity": "sha512-TQ92mBOW0l3LeMeyLV6mzy/kWr8lkd/hp3mTg7wYK7zJhuBStmGMBG0BdeDZS/dZx1IukaX6Bk11zcln25o1Aw==", "license": "ISC" }, "node_modules/picomatch": { @@ -14427,9 +14450,9 @@ } }, "node_modules/postcss": { - "version": "8.4.41", - "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.41.tgz", - "integrity": "sha512-TesUflQ0WKZqAvg52PWL6kHgLKP6xB6heTOdoYM0Wt2UHyxNa4K25EZZMgKns3BH1RLVbZCREPpLY0rhnNoHVQ==", + "version": "8.4.45", + "resolved": "https://registry.npmjs.org/postcss/-/postcss-8.4.45.tgz", + "integrity": "sha512-7KTLTdzdZZYscUc65XmjFiB73vBhBfbPztCYdUNvlaso9PrzjzcmjqBPR0lNGkcVlcO4BjiO5rK/qNz+XAen1Q==", "funding": [ { "type": "opencollective", @@ -15669,9 +15692,9 @@ "license": "MIT" }, "node_modules/react-json-view-lite": { - "version": "1.4.0", - "resolved": "https://registry.npmjs.org/react-json-view-lite/-/react-json-view-lite-1.4.0.tgz", - "integrity": "sha512-wh6F6uJyYAmQ4fK0e8dSQMEWuvTs2Wr3el3sLD9bambX1+pSWUVXIz1RFaoy3TI1mZ0FqdpKq9YgbgTTgyrmXA==", + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/react-json-view-lite/-/react-json-view-lite-1.5.0.tgz", + "integrity": "sha512-nWqA1E4jKPklL2jvHWs6s+7Na0qNgw9HCP6xehdQJeg6nPBTFZgGwyko9Q0oj+jQWKTTVRS30u0toM5wiuL3iw==", "license": "MIT", "engines": { "node": ">=14" @@ -16467,9 +16490,9 @@ } }, "node_modules/search-insights": { - "version": "2.17.0", - "resolved": "https://registry.npmjs.org/search-insights/-/search-insights-2.17.0.tgz", - "integrity": "sha512-AskayU3QNsXQzSL6v4LTYST7NNfs2HWyHHB+sdORP9chsytAhro5XRfToAMI/LAVYgNbzowVZTMfBRodgbUHKg==", + "version": "2.17.1", + "resolved": "https://registry.npmjs.org/search-insights/-/search-insights-2.17.1.tgz", + "integrity": "sha512-HHFjYH/0AqXacETlIbe9EYc3UNlQYGNNTY0fZ/sWl6SweX+GDxq9NB5+RVoPLgEFuOtCz7M9dhYxqDnhbbF0eQ==", "license": "MIT", "peer": true }, @@ -17142,9 +17165,9 @@ "license": "MIT" }, "node_modules/streamx": { - "version": "2.19.0", - "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.19.0.tgz", - "integrity": "sha512-5z6CNR4gtkPbwlxyEqoDGDmWIzoNJqCBt4Eac1ICP9YaIT08ct712cFj0u1rx4F8luAuL+3Qc+RFIdI4OX00kg==", + "version": "2.20.0", + "resolved": "https://registry.npmjs.org/streamx/-/streamx-2.20.0.tgz", + "integrity": "sha512-ZGd1LhDeGFucr1CUCTBOS58ZhEendd0ttpGT3usTvosS4ntIwKN9LJFp+OeCSprsCPL14BXVRZlHGRY1V9PVzQ==", "dev": true, "license": "MIT", "dependencies": { @@ -19075,9 +19098,9 @@ "license": "ISC" }, "node_modules/yaml": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.0.tgz", - "integrity": "sha512-2wWLbGbYDiSqqIKoPjar3MPgB94ErzCtrNE1FdqGuaO0pi2JGjmE8aW8TDZwzU7vuxcGRdL/4gPQwQ7hD5AMSw==", + "version": "2.5.1", + "resolved": "https://registry.npmjs.org/yaml/-/yaml-2.5.1.tgz", + "integrity": "sha512-bLQOjaX/ADgQ20isPJRvF0iRUHIxVhYvr53Of7wGcWlO2jvtUlH5m87DsmulFVxRpNLOnI4tB6p/oh8D7kpn9Q==", "dev": true, "license": "ISC", "bin": { diff --git a/documentation/plugins/code-snippets/codeSnippets.js b/documentation/plugins/code-snippets/codeSnippets.js index 4d6f16e26d..11edeb8b21 100644 --- a/documentation/plugins/code-snippets/codeSnippets.js +++ b/documentation/plugins/code-snippets/codeSnippets.js @@ -1,7 +1,7 @@ const fs = require('fs'); const path = require('path'); -const codeBockRegex = /\/\/<(?\/)?code-block:(?[a-zA-Z0-9_]*)>$/; +const codeBlockRegex = /\/\/<(?\/)?code-block:(?[a-zA-Z0-9_]*)>$/; module.exports = function() { const snippets = {}; @@ -10,26 +10,48 @@ module.exports = function() { const content = fs.readFileSync(filePath, 'utf8'); const lines = content.split('\n'); const blocks = {}; + const blockStartLines = {}; lines.forEach((line, index) => { - const match = line.match(codeBockRegex); + const match = line.match(codeBlockRegex); if (match) { const { closing, tag } = match.groups; if (closing) { const code = blocks[tag]; if (!code) { - throw new Error(`Code block not closed: ${tag} (${relativeFilePath}:${index + 1})`); + // Handle the case where a closing tag does not have an opening tag + snippets[tag] = { + file: relativeFilePath, + content: "Not found", // Temporary fix so the docs can be build... + startLine: "N/A", + endLine: index + 1 + }; + } else { + // Close the block and save the snippet + blocks[tag] = null; + snippets[tag] = { + file: relativeFilePath, + content: code.join('\n'), + startLine: blockStartLines[tag] + 1, + endLine: index + 1 + }; } - blocks[tag] = null; - snippets[tag] = { - file: relativeFilePath, - content: code.join('\n') - }; - return; + } else { + if (blocks[tag]) { + // Handle the case where an opening tag already exists + snippets[tag] = { + file: relativeFilePath, + content: "Not found", // Temporary fix so the docs can be build... + startLine: blockStartLines[tag] + 1, + endLine: index + 1 + }; + } + // Start a new block + blocks[tag] = []; + blockStartLines[tag] = index; } - - blocks[tag] = []; } else { + // Add lines to the current blocks for (const tag in blocks) { const code = blocks[tag]; if (!code) continue; @@ -41,11 +63,14 @@ module.exports = function() { // Handle any unclosed blocks for (const tag in blocks) { const code = blocks[tag]; - if (!code) continue; - snippets[tag] = { - file: relativeFilePath, - content: code.join('\n') - }; + if (code) { + snippets[tag] = { + file: relativeFilePath, + content: "Not found", // Temporary fix so the docs can be build... + startLine: blockStartLines[tag] + 1, + endLine: "N/A" + }; + } } } @@ -58,7 +83,13 @@ module.exports = function() { if (stat.isDirectory()) { traverseDirectory(filePath, baseDir); } else if (path.extname(filePath) === '.kt') { - processFile(filePath, relativeFilePath); + try { + processFile(filePath, relativeFilePath); + } catch (error) { + // Improve error handling by showing which file failed + console.error(`Error processing file: ${relativeFilePath}`); + throw error; + } } }); } @@ -67,13 +98,11 @@ module.exports = function() { const adaptersDir = path.resolve(__dirname, '../../../extensions/_DocsExtension'); traverseDirectory(adaptersDir, adaptersDir); - // console.log(`Exporting ${Object.keys(snippets).length} snippets: ${Object.keys(snippets)}`); - this.cacheable(false); const code = `${JSON.stringify(snippets, null, 2)}`; - fs.writeSync(fs.openSync(path.resolve(__dirname, 'snippets.json'), 'w'), code); + fs.writeFileSync(path.resolve(__dirname, 'snippets.json'), code); return `export default ${JSON.stringify(snippets, null, 2)}`; -}; +}; \ No newline at end of file diff --git a/documentation/plugins/code-snippets/snippets.json b/documentation/plugins/code-snippets/snippets.json index 09b958319a..4a27ba930a 100644 --- a/documentation/plugins/code-snippets/snippets.json +++ b/documentation/plugins/code-snippets/snippets.json @@ -1,98 +1,62 @@ { - "initializer": { - "file": "src/main/kotlin/com/typewritermc/example/ExampleInitializer.kt", - "content": "import com.typewritermc.core.extension.Initializable\nimport com.typewritermc.core.extension.annotations.Initializer\n\n@Initializer\nobject ExampleInitializer : Initializable {\n override fun initialize() {\n // Do something when the extension is initialized\n }\n\n override fun shutdown() {\n // Do something when the extension is shutdown\n }\n}" - }, - "cinematic_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/cinematic/ExampleCinematicEntry.kt", - "content": "@Entry(\"example_cinematic\", \"An example cinematic entry\", Colors.BLUE, \"material-symbols:cinematic-blur\")\nclass ExampleCinematicEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n override val criteria: List = emptyList(),\n @Segments(Colors.BLUE, \"material-symbols:cinematic-blur\")\n val segments: List = emptyList(),\n) : CinematicEntry {\n override fun create(player: Player): CinematicAction {\n return ExampleCinematicAction(player, this)\n }\n}" - }, - "cinematic_segment_with_min_max": { - "file": "src/main/kotlin/com/typewritermc/example/entries/cinematic/ExampleCinematicEntry.kt", - "content": " @Segments(Colors.BLUE, \"material-symbols:cinematic-blur\")\n @InnerMin(Min(10))\n @InnerMax(Max(20))\n val segments: List = emptyList()," - }, - "cinematic_create_actions": { - "file": "src/main/kotlin/com/typewritermc/example/entries/cinematic/ExampleCinematicEntry.kt", - "content": " // This will be used when the cinematic is normally displayed to the player.\n override fun create(player: Player): CinematicAction {\n return DefaultCinematicAction(player, this)\n }\n\n // This is used during content mode to display the cinematic to the player.\n // It may be null to not show it during simulation.\n override fun createSimulating(player: Player): CinematicAction? {\n return SimulatedCinematicAction(player, this)\n }\n\n // This is used during content mode to record the cinematic.\n // It may be null to not record it during simulation.\n override fun createRecording(player: Player): CinematicAction? {\n return RecordingCinematicAction(player, this)\n }" - }, - "cinematic_segment": { - "file": "src/main/kotlin/com/typewritermc/example/entries/cinematic/ExampleCinematicEntry.kt", - "content": "data class ExampleSegment(\n override val startFrame: Int = 0,\n override val endFrame: Int = 0,\n) : Segment" - }, - "cinematic_action": { - "file": "src/main/kotlin/com/typewritermc/example/entries/cinematic/ExampleCinematicEntry.kt", - "content": "class ExampleCinematicAction(\n val player: Player,\n val entry: ExampleCinematicEntry,\n) : CinematicAction {\n override suspend fun setup() {\n // Initialize variables, spawn entities, etc.\n }\n\n override suspend fun tick(frame: Int) {\n val segment = entry.segments activeSegmentAt frame\n // Can be null if no segment is active\n\n // The `frame` parameter is not necessarily next frame: `frame != old(frame)+1`\n\n // Execute tick logic for the segment\n }\n\n override suspend fun teardown() {\n // Remove entities, etc.\n }\n\n override fun canFinish(frame: Int): Boolean = entry.segments canFinishAt frame\n}" - }, - "cinematic_simple_action": { - "file": "src/main/kotlin/com/typewritermc/example/entries/cinematic/ExampleCinematicEntry.kt", - "content": "class ExampleSimpleCinematicAction(\n val player: Player,\n entry: ExampleCinematicEntry,\n) : SimpleCinematicAction() {\n override val segments: List = entry.segments\n\n override suspend fun startSegment(segment: ExampleSegment) {\n super.startSegment(segment) // Keep this\n // Called when a segment starts\n }\n\n override suspend fun tickSegment(segment: ExampleSegment, frame: Int) {\n super.tickSegment(segment, frame) // Keep this\n // Called every tick while the segment is active\n // Will always be called after startSegment and never after stopSegment\n\n // The `frame` parameter is not necessarily next frame: `frame != old(frame)+1`\n }\n\n override suspend fun stopSegment(segment: ExampleSegment) {\n super.stopSegment(segment) // Keep this\n // Called when the segment ends\n // Will also be called if the cinematic is stopped early\n }\n}" - }, - "audience_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/manifest/ExampleAudienceEntry.kt", - "content": "@Entry(\"example_audience\", \"An example audience entry.\", Colors.GREEN, \"material-symbols:chat-rounded\")\nclass ExampleAudienceEntry(\n override val id: String,\n override val name: String,\n) : AudienceEntry {\n override fun display(): AudienceDisplay {\n return ExampleAudienceDisplay()\n }\n}" - }, - "audience_display": { - "file": "src/main/kotlin/com/typewritermc/example/entries/manifest/ExampleAudienceEntry.kt", - "content": "class ExampleAudienceDisplay : AudienceDisplay() {\n override fun initialize() {\n // This is called when the first player is added to the audience.\n super.initialize()\n // Do something when the audience is initialized\n }\n\n override fun onPlayerAdd(player: Player) {\n // Do something when a player gets added to the audience\n }\n\n override fun onPlayerRemove(player: Player) {\n // Do something when a player gets removed from the audience\n }\n\n override fun dispose() {\n super.dispose()\n // Do something when the audience is disposed\n // It will always call onPlayerRemove for all players.\n // So no player cleanup is needed here.\n }\n}" - }, - "tickable_audience_display": { - "file": "src/main/kotlin/com/typewritermc/example/entries/manifest/ExampleAudienceEntry.kt", - "content": "// highlight-next-line\nclass TickableAudienceDisplay : AudienceDisplay(), TickableDisplay {\n override fun onPlayerAdd(player: Player) {}\n override fun onPlayerRemove(player: Player) {}\n\n // highlight-start\n override fun tick() {\n // Do something when the audience is ticked\n players.forEach { player ->\n // Do something with the player\n }\n\n // This is running asynchronously\n // If you need to do something on the main thread\n ThreadType.SYNC.launch {\n // Though this will run a tick later, to sync with the bukkit scheduler.\n }\n }\n // highlight-end\n}" - }, "audience_display_with_events": { - "file": "src/main/kotlin/com/typewritermc/example/entries/manifest/ExampleAudienceEntry.kt", - "content": "class AudienceDisplayWithEvents : AudienceDisplay() {\n override fun onPlayerAdd(player: Player) {}\n override fun onPlayerRemove(player: Player) {}\n\n // highlight-start\n @EventHandler\n fun onSomeEvent(event: SomeBukkitEvent) {\n // Do something when the event is triggered\n // This will trigger for all players, not just the ones in the audience.\n // So we need to check if the player is in the audience.\n if (event.player in this) {\n // Do something with the player\n }\n }\n // highlight-end\n}" - }, - "artifact_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/static/ExampleArtifactEntry.kt", - "content": "@Entry(\"example_artifact\", \"An example artifact entry.\", Colors.BLUE, \"material-symbols:home-storage-rounded\")\nclass ExampleArtifactEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n override val artifactId: String = \"\",\n) : ArtifactEntry" + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\entries\\manifest\\ExampleAudienceEntry.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 90 }, "artifact_access": { - "file": "src/main/kotlin/com/typewritermc/example/entries/static/ExampleArtifactEntry.kt", - "content": "suspend fun accessArtifactData(ref: Ref) {\n val assetManager = KoinJavaComponent.get(AssetManager::class.java)\n val entry = ref.get() ?: return\n val content: String? = assetManager.fetchAsset(entry)\n // Do something with the content\n}" - }, - "asset_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/static/ExampleAssetEntry.kt", - "content": "@Entry(\"example_asset\", \"An example asset entry.\", Colors.BLUE, \"material-symbols:home-storage-rounded\")\nclass ExampleAssetEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n override val path: String = \"\",\n) : AssetEntry" + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\entries\\static\\ExampleArtifactEntry.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 26 }, "asset_access": { - "file": "src/main/kotlin/com/typewritermc/example/entries/static/ExampleAssetEntry.kt", - "content": "suspend fun accessAssetData(ref: Ref) {\n val assetManager = KoinJavaComponent.get(AssetManager::class.java)\n val entry = ref.get() ?: return\n val content: String? = assetManager.fetchAsset(entry)\n // Do something with the content\n}" + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\entries\\static\\ExampleAssetEntry.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 26 }, "sound_id_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/static/ExampleSoundIdEntry.kt", - "content": "@Entry(\"example_sound\", \"An example sound entry.\", Colors.BLUE, \"icon-park-solid:volume-up\")\nclass ExampleSoundIdEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n override val soundId: String = \"\",\n) : SoundIdEntry" + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\entries\\static\\ExampleSoundIdEntry.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 14 }, "sound_source_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/static/ExampleSoundSourceEntry.kt", - "content": "@Entry(\"example_sound_source\", \"An example sound source entry.\", Colors.BLUE, \"ic:round-spatial-audio-off\")\nclass ExampleSoundSourceEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n) : SoundSourceEntry {\n override fun getEmitter(): Sound.Emitter {\n // Return the emitter that should be used for the sound.\n // A bukkit entity can be used here.\n return Sound.Emitter.self()\n }\n}" + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\entries\\static\\ExampleSoundSourceEntry.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 20 }, "speaker_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/static/ExampleSpeakerEntry.kt", - "content": "@Entry(\"example_speaker\", \"An example speaker entry.\", Colors.BLUE, \"ic:round-spatial-audio-off\")\nclass ExampleSpeakerEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n override val displayName: String = \"\",\n override val sound: Sound = Sound.EMPTY,\n) : SpeakerEntry" + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\entries\\static\\ExampleSpeakerEntry.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 16 }, "action_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/trigger/ExampleActionEntry.kt", - "content": "@Entry(\"example_action\", \"An example action entry.\", Colors.RED, \"material-symbols:touch-app-rounded\")\nclass ExampleActionEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n override val criteria: List = emptyList(),\n override val modifiers: List = emptyList(),\n override val triggers: List> = emptyList(),\n) : ActionEntry {\n override fun execute(player: Player) {\n super.execute(player) // This will apply all the modifiers.\n // Do something with the player\n }\n}" + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\entries\\trigger\\ExampleActionEntry.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 26 }, "custom_triggering_action_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/trigger/ExampleCustomTriggeringActionEntry.kt", - "content": "@Entry(\n \"example_custom_triggering_action\",\n \"An example custom triggering entry.\",\n Colors.RED,\n \"material-symbols:touch-app-rounded\"\n)\nclass ExampleCustomTriggeringActionEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n override val criteria: List = emptyList(),\n override val modifiers: List = emptyList(),\n @SerializedName(\"triggers\")\n override val customTriggers: List> = emptyList(),\n) : CustomTriggeringActionEntry {\n override fun execute(player: Player) {\n super.execute(player) // This will apply the modifiers.\n // Do something with the player\n player.triggerCustomTriggers() // Can be called later to trigger the next entries.\n }\n}" - }, - "dialogue_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/trigger/ExampleDialogueEntry.kt", - "content": "@Entry(\"example_dialogue\", \"An example dialogue entry.\", Colors.BLUE, \"material-symbols:chat-rounded\")\nclass ExampleDialogueEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n override val criteria: List = emptyList(),\n override val modifiers: List = emptyList(),\n override val triggers: List> = emptyList(),\n override val speaker: Ref = emptyRef(),\n @MultiLine\n @Placeholder\n @Colored\n @Help(\"The text to display to the player.\")\n val text: String = \"\",\n) : DialogueEntry" + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\entries\\trigger\\ExampleCustomTriggeringActionEntry.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 34 }, "dialogue_messenger": { - "file": "src/main/kotlin/com/typewritermc/example/entries/trigger/ExampleDialogueEntry.kt", - "content": "@Messenger(ExampleDialogueEntry::class)\nclass ExampleDialogueDialogueMessenger(player: Player, entry: ExampleDialogueEntry) :\n DialogueMessenger(player, entry) {\n\n companion object : MessengerFilter {\n override fun filter(player: Player, entry: DialogueEntry): Boolean = true\n }\n\n // Called every game tick (20 times per second).\n // The cycle is a parameter that is incremented every tick, starting at 0.\n override fun tick(playTime: Duration) {\n super.tick(playTime)\n if (state != MessengerState.RUNNING) return\n\n player.sendMessage(\"${entry.speakerDisplayName}: ${entry.text}\".parsePlaceholders(player).asMini())\n\n // When we want the dialogue to end, we can set the state to FINISHED.\n state = MessengerState.FINISHED\n }\n}" + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\entries\\trigger\\ExampleDialogueEntry.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 58 }, - "event_entry": { - "file": "src/main/kotlin/com/typewritermc/example/entries/trigger/ExampleEventEntry.kt", - "content": "@Entry(\"example_event\", \"An example event entry.\", Colors.YELLOW, \"material-symbols:bigtop-updates\")\nclass ExampleEventEntry(\n override val id: String = \"\",\n override val name: String = \"\",\n override val triggers: List> = emptyList(),\n) : EventEntry" - }, - "event_entry_listener": { - "file": "src/main/kotlin/com/typewritermc/example/entries/trigger/ExampleEventEntry.kt", - "content": "// Must be scoped to be public\n@EntryListener(ExampleEventEntry::class)\nfun onEvent(event: SomeBukkitEvent, query: Query) {\n // Do something\n val entries = query.find() // Find all the entries of this type, for more information see the Query section\n // Do something with the entries, for example trigger them\n entries triggerAllFor event.player\n}" + "initializer": { + "file": "src\\main\\kotlin\\com\\typewritermc\\example\\ExampleInitializer.kt", + "content": "Not found", + "startLine": "N/A", + "endLine": 17 } } \ No newline at end of file