From 843351a57fb283de551a3990e8ff0e90bb73e26a Mon Sep 17 00:00:00 2001
From: XQuestCode <9934145215aditya@gmail.com>
Date: Tue, 5 Dec 2023 06:12:07 +1100
Subject: [PATCH] UPDATE: Automatic page routing script. Dynamic Scripting for
components. Added enums and structures.
---
.gitignore | 8 +-
package-lock.json | 147 ++++--
package.json | 10 +-
{test => scripts}/api.json | 0
scripts/components.cjs | 438 ++++++++++++++++++
scripts/guides.cjs | 150 ++++++
.../guides/Animations/Using Animation.mdx | 6 +-
src/content/docs/guides/Animations/index.mdx | 27 --
.../docs/guides/Audio/GettingStartedAudio.mdx | 2 +
src/content/docs/guides/Audio/index.mdx | 19 -
.../docs/guides/Camera/about-camera.mdx | 2 +
src/content/docs/guides/Camera/index.mdx | 21 -
src/content/docs/guides/Database/index.mdx | 20 -
.../docs/guides/Database/using-databases.mdx | 4 +-
src/content/docs/guides/Inputs/index.mdx | 20 -
src/content/docs/guides/JSON/index.mdx | 21 -
src/content/docs/guides/Networking/index.mdx | 31 --
.../docs/guides/Others/Cmake/1 Get started.md | 30 ++
.../guides/Others/Cmake/1. Get started.md | 41 --
...st Cmake.md => 2 Build our First Cmake.md} | 3 +
.../Cmake/{3. Variables.md => 3 Variables.md} | 2 +
...tatement.md => 4 Conditional Statement.md} | 6 +
... Loop statement.md => 5 Loop statement.md} | 6 +
...ding Library.md => 6 Including Library.md} | 7 +
...tom Command.md => 7 Add Custom Command.md} | 2 +
...-platforming.md => 8 Cross-platforming.md} | 4 +
...SplashKit.md => 9 Cmake with SplashKit.md} | 3 +-
src/content/docs/guides/Others/index.mdx | 21 -
src/content/docs/guides/Sprites/index.mdx | 23 -
src/content/docs/guides/Starter/index.mdx | 42 --
src/content/docs/guides/Utilities/index.mdx | 22 -
src/content/docs/guides/index.mdx | 123 +++--
test/script-old.js | 233 ----------
test/script.js | 311 -------------
34 files changed, 834 insertions(+), 971 deletions(-)
rename {test => scripts}/api.json (100%)
create mode 100644 scripts/components.cjs
create mode 100644 scripts/guides.cjs
delete mode 100644 src/content/docs/guides/Animations/index.mdx
delete mode 100644 src/content/docs/guides/Audio/index.mdx
delete mode 100644 src/content/docs/guides/Camera/index.mdx
delete mode 100644 src/content/docs/guides/Database/index.mdx
delete mode 100644 src/content/docs/guides/Inputs/index.mdx
delete mode 100644 src/content/docs/guides/JSON/index.mdx
delete mode 100644 src/content/docs/guides/Networking/index.mdx
create mode 100644 src/content/docs/guides/Others/Cmake/1 Get started.md
delete mode 100644 src/content/docs/guides/Others/Cmake/1. Get started.md
rename src/content/docs/guides/Others/Cmake/{2. Build our First Cmake.md => 2 Build our First Cmake.md} (97%)
rename src/content/docs/guides/Others/Cmake/{3. Variables.md => 3 Variables.md} (96%)
rename src/content/docs/guides/Others/Cmake/{4. Conditional Statement.md => 4 Conditional Statement.md} (93%)
rename src/content/docs/guides/Others/Cmake/{5. Loop statement.md => 5 Loop statement.md} (92%)
rename src/content/docs/guides/Others/Cmake/{6. Including Library.md => 6 Including Library.md} (97%)
rename src/content/docs/guides/Others/Cmake/{7. Add Custom Command.md => 7 Add Custom Command.md} (95%)
rename src/content/docs/guides/Others/Cmake/{8. Cross-platforming.md => 8 Cross-platforming.md} (91%)
rename src/content/docs/guides/Others/Cmake/{9. Cmake with SplashKit.md => 9 Cmake with SplashKit.md} (97%)
delete mode 100644 src/content/docs/guides/Others/index.mdx
delete mode 100644 src/content/docs/guides/Sprites/index.mdx
delete mode 100644 src/content/docs/guides/Starter/index.mdx
delete mode 100644 src/content/docs/guides/Utilities/index.mdx
delete mode 100644 test/script-old.js
delete mode 100644 test/script.js
diff --git a/.gitignore b/.gitignore
index 7825c6e7..207ed3ba 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,8 +3,7 @@ dist/
# generated types
.astro/
.vscode/
-# incase we testedmdx script locally
-src/content/docs/components/
+
# dependencies
node_modules/
@@ -14,6 +13,11 @@ yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
+#mdx output files
+src/components/components/*.mdx
+src/components/guides/**/index.mdx
+src/components/guides/index.mdx
+
# environment variables
.env
diff --git a/package-lock.json b/package-lock.json
index dea8fefd..b6f5cace 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -14,7 +14,15 @@
"@astrojs/starlight": "^0.13.1",
"astro": "^3.6.3",
"astro-expressive-code": "^0.29.2",
+ "chalk": "^5.3.0",
+ "cli-spinners": "^2.9.2",
+ "front-matter": "^4.0.2",
"fs": "^0.0.1-security",
+ "gray-matter": "^4.0.3",
+ "js-yaml": "^4.1.0",
+ "kleur": "^4.1.5",
+ "ora": "^7.0.1",
+ "path": "^0.12.7",
"sharp": "^0.32.6",
"solid-js": "^1.8.6",
"tailwindcss": "^3.3.5"
@@ -212,6 +220,19 @@
"node": ">=6.9.0"
}
},
+ "node_modules/@babel/code-frame/node_modules/chalk": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
+ "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "dependencies": {
+ "ansi-styles": "^3.2.1",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^5.3.0"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/@babel/compat-data": {
"version": "7.23.3",
"resolved": "https://registry.npmjs.org/@babel/compat-data/-/compat-data-7.23.3.tgz",
@@ -524,6 +545,19 @@
"node": ">=6.9.0"
}
},
+ "node_modules/@babel/highlight/node_modules/chalk": {
+ "version": "2.4.2",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
+ "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
+ "dependencies": {
+ "ansi-styles": "^3.2.1",
+ "escape-string-regexp": "^1.0.5",
+ "supports-color": "^5.3.0"
+ },
+ "engines": {
+ "node": ">=4"
+ }
+ },
"node_modules/@babel/parser": {
"version": "7.23.4",
"resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.23.4.tgz",
@@ -1747,17 +1781,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/boxen/node_modules/chalk": {
- "version": "5.3.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
- "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
- "engines": {
- "node": "^12.17.0 || ^14.13 || >=16.0.0"
- },
- "funding": {
- "url": "https://github.com/chalk/chalk?sponsor=1"
- }
- },
"node_modules/boxen/node_modules/emoji-regex": {
"version": "9.2.2",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-9.2.2.tgz",
@@ -1901,16 +1924,14 @@
}
},
"node_modules/chalk": {
- "version": "2.4.2",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz",
- "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==",
- "dependencies": {
- "ansi-styles": "^3.2.1",
- "escape-string-regexp": "^1.0.5",
- "supports-color": "^5.3.0"
- },
+ "version": "5.3.0",
+ "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
+ "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
"engines": {
- "node": ">=4"
+ "node": "^12.17.0 || ^14.13 || >=16.0.0"
+ },
+ "funding": {
+ "url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/character-entities": {
@@ -2020,9 +2041,9 @@
}
},
"node_modules/cli-spinners": {
- "version": "2.9.1",
- "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.1.tgz",
- "integrity": "sha512-jHgecW0pxkonBJdrKsqxgRX9AcG+u/5k0Q7WPDfi8AogLAdwxEkyYYNWwZ5GvVFoFx2uiY1eNcSK00fh+1+FyQ==",
+ "version": "2.9.2",
+ "resolved": "https://registry.npmjs.org/cli-spinners/-/cli-spinners-2.9.2.tgz",
+ "integrity": "sha512-ywqV+5MmyL4E7ybXgKys4DugZbX0FC6LnwrhjuykIjnK9k8OQacQ7axGKnjDXWNhns0xot3bZI5h55H8yo9cJg==",
"engines": {
"node": ">=6"
},
@@ -2586,6 +2607,34 @@
"pkg-dir": "^4.2.0"
}
},
+ "node_modules/front-matter": {
+ "version": "4.0.2",
+ "resolved": "https://registry.npmjs.org/front-matter/-/front-matter-4.0.2.tgz",
+ "integrity": "sha512-I8ZuJ/qG92NWX8i5x1Y8qyj3vizhXS31OxjKDu3LKP+7/qBgfIKValiZIEwoVoJKUHlhWtYrktkxV1XsX+pPlg==",
+ "dependencies": {
+ "js-yaml": "^3.13.1"
+ }
+ },
+ "node_modules/front-matter/node_modules/argparse": {
+ "version": "1.0.10",
+ "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz",
+ "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==",
+ "dependencies": {
+ "sprintf-js": "~1.0.2"
+ }
+ },
+ "node_modules/front-matter/node_modules/js-yaml": {
+ "version": "3.14.1",
+ "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.14.1.tgz",
+ "integrity": "sha512-okMH7OXXJ7YrN9Ok3/SXrnu4iX9yOk+25nqX4imS2npuvTYDmo/QEZoqwZkYaIDk3jVvBOTOIEgEhaLOynBS9g==",
+ "dependencies": {
+ "argparse": "^1.0.7",
+ "esprima": "^4.0.0"
+ },
+ "bin": {
+ "js-yaml": "bin/js-yaml.js"
+ }
+ },
"node_modules/fs": {
"version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
@@ -3437,17 +3486,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/log-symbols/node_modules/chalk": {
- "version": "5.3.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
- "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
- "engines": {
- "node": "^12.17.0 || ^14.13 || >=16.0.0"
- },
- "funding": {
- "url": "https://github.com/chalk/chalk?sponsor=1"
- }
- },
"node_modules/longest-streak": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/longest-streak/-/longest-streak-3.1.0.tgz",
@@ -4869,17 +4907,6 @@
"url": "https://github.com/sponsors/sindresorhus"
}
},
- "node_modules/ora/node_modules/chalk": {
- "version": "5.3.0",
- "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.3.0.tgz",
- "integrity": "sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==",
- "engines": {
- "node": "^12.17.0 || ^14.13 || >=16.0.0"
- },
- "funding": {
- "url": "https://github.com/chalk/chalk?sponsor=1"
- }
- },
"node_modules/p-limit": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-4.0.0.tgz",
@@ -5020,6 +5047,15 @@
"resolved": "https://registry.npmjs.org/parse5/-/parse5-6.0.1.tgz",
"integrity": "sha512-Ofn/CTFzRGTTxwpNEs9PP93gXShHcTq255nzRYSKe8AkVpZY7e1fpmTfOyoIvjP5HG7Z2ZM7VS9PPhQGW2pOpw=="
},
+ "node_modules/path": {
+ "version": "0.12.7",
+ "resolved": "https://registry.npmjs.org/path/-/path-0.12.7.tgz",
+ "integrity": "sha512-aXXC6s+1w7otVF9UletFkFcDsJeO7lSZBPUQhtb5O0xJe8LtYhj/GxldoL09bBj9+ZmE2hNoHqQSFMN5fikh4Q==",
+ "dependencies": {
+ "process": "^0.11.1",
+ "util": "^0.10.3"
+ }
+ },
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
@@ -5421,6 +5457,14 @@
"stream-parser": "~0.3.1"
}
},
+ "node_modules/process": {
+ "version": "0.11.10",
+ "resolved": "https://registry.npmjs.org/process/-/process-0.11.10.tgz",
+ "integrity": "sha512-cdGef/drWFoydD1JsMzuFf8100nZl+GT+yacc2bEced5f9Rjk4z+WtFUTBu9PhOi9j/jfmBPu0mMEY4wIdAF8A==",
+ "engines": {
+ "node": ">= 0.6.0"
+ }
+ },
"node_modules/prompts": {
"version": "2.4.2",
"resolved": "https://registry.npmjs.org/prompts/-/prompts-2.4.2.tgz",
@@ -7055,11 +7099,24 @@
"resolved": "https://registry.npmjs.org/urlpattern-polyfill/-/urlpattern-polyfill-8.0.2.tgz",
"integrity": "sha512-Qp95D4TPJl1kC9SKigDcqgyM2VDVO4RiJc2d4qe5GrYm+zbIQCWWKAFaJNQ4BhdFeDGwBmAxqJBwWSJDb9T3BQ=="
},
+ "node_modules/util": {
+ "version": "0.10.4",
+ "resolved": "https://registry.npmjs.org/util/-/util-0.10.4.tgz",
+ "integrity": "sha512-0Pm9hTQ3se5ll1XihRic3FDIku70C+iHUdT/W926rSgHV5QgXsYbKZN8MSC3tJtSkhuROzvsQjAaFENRXr+19A==",
+ "dependencies": {
+ "inherits": "2.0.3"
+ }
+ },
"node_modules/util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw=="
},
+ "node_modules/util/node_modules/inherits": {
+ "version": "2.0.3",
+ "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
+ "integrity": "sha512-x00IRNXNy63jwGkJmzPigoySHbaqpNuzKbBOmzK+g2OdZpQ9w+sxCN+VSB3ja7IAge2OP2qpfxTjeNcyjmW1uw=="
+ },
"node_modules/uvu": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/uvu/-/uvu-0.5.6.tgz",
diff --git a/package.json b/package.json
index 3832186d..e4f8a092 100644
--- a/package.json
+++ b/package.json
@@ -8,7 +8,7 @@
"build": "astro build",
"preview": "astro preview",
"astro": "astro",
- "generate-mdx": "node ./test/script.js"
+ "generate-mdx": "node ./scripts/components.cjs node ./scripts/guides.cjs"
},
"dependencies": {
"@astrojs/netlify": "^3.0.4",
@@ -17,7 +17,15 @@
"@astrojs/starlight": "^0.13.1",
"astro": "^3.6.3",
"astro-expressive-code": "^0.29.2",
+ "chalk": "^5.3.0",
+ "cli-spinners": "^2.9.2",
+ "front-matter": "^4.0.2",
"fs": "^0.0.1-security",
+ "gray-matter": "^4.0.3",
+ "js-yaml": "^4.1.0",
+ "kleur": "^4.1.5",
+ "ora": "^7.0.1",
+ "path": "^0.12.7",
"sharp": "^0.32.6",
"solid-js": "^1.8.6",
"tailwindcss": "^3.3.5"
diff --git a/test/api.json b/scripts/api.json
similarity index 100%
rename from test/api.json
rename to scripts/api.json
diff --git a/scripts/components.cjs b/scripts/components.cjs
new file mode 100644
index 00000000..07fb9a81
--- /dev/null
+++ b/scripts/components.cjs
@@ -0,0 +1,438 @@
+// Script to generate .mdx file in a specific format to adapt to Starlight from JSON data.
+const fs = require("fs");
+const kleur = require("kleur");
+const spinners = require('cli-spinners');
+
+
+// Define type mappings
+const typeMappings = {
+ int: "`Integer`",
+ double: "`Double`",
+ bool: "`Boolean`",
+ char: "`Char`",
+ string: "`String`",
+ void: "`Void`",
+ float: "`Float`",
+ vector: "`Vector`",
+ // Add more type mappings as needed
+};
+
+const guidesAvailable = {
+ animations: true,
+ audio: true,
+ camera: true,
+ database: true,
+ inputs: true,
+ json: true,
+ networking: true,
+ sprites: true,
+ utilities: true
+
+};
+// Define language label mappings
+const languageLabelMappings = {
+ pascal: "Pascal",
+ python: "Python",
+ cpp: "C++",
+ csharp: "C#",
+ // Add more mappings as needed
+};
+
+
+// Define language order
+const languageOrder = ["cpp", "csharp", "python", "pascal"];
+var name = "";
+
+
+
+
+function Mappings(jsonData) {
+ //generate mappings from API
+ for (const categoryKey in jsonData) {
+ const category = jsonData[categoryKey];
+ category.typedefs.forEach((typedef) => {
+ // Add typedef to typeMappings
+ const name = typedef.name.split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+
+ typeMappings[typedef.name] = `[\`${name}\`](/components/${categoryKey.toLowerCase().replace(/\s+/g, "-")}/#${name.toLowerCase().replace(/\s+/g, "-")})`;
+ });
+ category.structs.forEach((struct) => {
+ // Add structs to typeMappings
+ const name = struct.name.split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+
+ typeMappings[struct.name] = `[\`${name}\`](/components/${categoryKey.toLowerCase().replace(/\s+/g, "-")}/#${name.toLowerCase().replace(/\s+/g, "-")})`;
+ });
+ category.enums.forEach((enumm) => {
+ // Add structs to typeMappings
+ const name = enumm.name.split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+
+ typeMappings[enumm.name] = `[\`${name}\`](/components/${categoryKey.toLowerCase().replace(/\s+/g, "-")}/#${name.toLowerCase().replace(/\s+/g, "-")})`;
+ });
+ }
+}
+fs.readFile("./test/api.json", "utf8", (err, data) => {
+ if (err) {
+ console.error(kleur.red("Error reading JSON file:"), err);
+ console.error("Error reading JSON file:", err);
+ return;
+ }
+
+ try {
+ const jsonData = JSON.parse(data);
+ Mappings(jsonData);
+ const spinner = createSpinner(`Generating MDX files for components`);
+
+
+
+
+ // Please select an option: "animations, audio, camera, color, database, geometry, graphics, input, json, networking, physics, resource_bundles, resources, social, sprites, terminal, timers, types, utilities, windows"
+ for (const categoryKey in jsonData) {
+ const category = jsonData[categoryKey];
+ let input = categoryKey;
+ const categoryFunctions = category.functions;
+ let mdxContent = "";
+ name = input.split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" "); //name of the category
+ const functionNames = category.functions.map((func) => func.name);
+
+ mdxContent += "---\n";
+ mdxContent += `title: ${name}\n`;
+ if (category.brief != "") { mdxContent += `description: ${category.brief.replace(/\n/g, '')}\n`; }
+ else { mdxContent += `description: Some description....\n`; }
+
+ mdxContent += "---\n\n";
+ if (category.brief != "") {
+ if (categoryFunctions.description != null) {
+ mdxContent += `:::tip[${category.brief}]\n`;
+ mdxContent += `${category.description}\n`
+ mdxContent += `:::\n`
+ }
+ else {
+ mdxContent += `:::tip[${name}]\n`;
+ mdxContent += `${category.brief}\n`
+ mdxContent += `:::\n`
+ }
+ }
+ mdxContent += `\nimport { Tabs, TabItem } from "@astrojs/starlight/components";\nimport { LinkCard, CardGrid } from "@astrojs/starlight/components";
+\n `;
+ if (guidesAvailable[categoryKey]) {
+ mdxContent += "\n## \n";
+ mdxContent += "## Animations Guides\n";
+ mdxContent += `\n\n`;
+ }
+ mdxContent += "## \n";
+ mdxContent += "## Functions\n";
+ mdxContent += "## \n";
+ const functionGroups = {}; // Store functions grouped by name
+ categoryFunctions.forEach((func) => {
+ const functionName = func.name;
+ if (!functionGroups[functionName]) {
+ functionGroups[functionName] = [];
+ }
+ functionGroups[functionName].push(func);
+ });
+
+ for (const functionName in functionGroups) {
+ const overloads = functionGroups[functionName];
+ const isOverloaded = overloads.length > 1;
+
+ if (isOverloaded) {
+ // Create a section for overloaded functions
+
+ const formattedFunctionName = functionName
+ .split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+ const formattedLink = formattedFunctionName.toLowerCase().replace(/\s+/g, "-");
+
+ const formattedGroupLink = `group-${formattedLink}`;
+ mdxContent += `## ${formattedFunctionName} [๐](#${formattedGroupLink})\n\n`;
+ mdxContent += ":::note\n\n";
+ mdxContent += "This function is overloaded. The following versions exist:\n\n";
+
+ overloads.forEach((func, index) => {
+ mdxContent += `- [**${formattedFunctionName}** (`;
+ for (const paramName in func.parameters) {
+ const param = func.parameters[paramName];
+ const paramType = param.type;
+ if (index > 0) {
+ mdxContent += "";
+ }
+ mdxContent += `${paramName}: ${paramType}, `;
+ }
+ mdxContent += `)](/components/${input}/#${formattedLink.toLowerCase()}--${index + 1})\n`;
+ });
+
+ mdxContent += "\n:::\n\n";
+ }
+
+ overloads.forEach((func, index) => {
+ // Format the header based on whether it's overloaded or not
+ let functionName2 = functionName.split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+ const formattedName3 = func.name
+ .split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+
+ const formattedLink = formattedName3.toLowerCase().replace(/\s+/g, "-");
+
+ const formattedName = isOverloaded
+ ? `### ${functionName2} [๐](#${formattedLink.toLowerCase()}--${index + 1})`
+ : `## ${functionName2} [๐](#${formattedLink})\n\n`;
+
+
+ // Replace type names in the description with formatted versions
+ let description = func.description || "";
+ for (const typeName in typeMappings) {
+ const typeMapping = typeMappings[typeName];
+ description = description.replace(
+ new RegExp(`\`\\b${typeName}\\b\``, "g"),
+ typeMapping
+ );
+ }
+
+ mdxContent += `${formattedName} \n`;
+ for (const names of functionNames) {
+ const normalName = names
+ .split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+ const formattedLink = normalName.toLowerCase().replace(/\s+/g, "-");
+ const link = `[\`${normalName}\`](/components/${input}/${formattedLink})`
+ description = description.replace(new RegExp(`\`\\b${names}\\b\``, "g"), link);
+ }
+ mdxContent += description ? `${description}\n\n` : "";
+ mdxContent += "**Return Type**\n\n- " + typeMappings[func.return.type] + " \n\n";
+
+ // Add Parameters section only if there are parameters
+ if (Object.keys(func.parameters).length > 0) {
+ mdxContent += "**Parameters**\n\n";
+ mdxContent +=
+ "| Name | Type | Description |\n";
+ mdxContent +=
+ "| ------ | -------------------------------------------------- | ---------------------------------------------------------------------------------- |\n";
+
+ for (const paramName in func.parameters) {
+ const param = func.parameters[paramName];
+ const paramType = typeMappings[param.type] || param.type;
+ let description2 = param.description || "";
+ for (const typeName in typeMappings) {
+ const typeMapping = typeMappings[typeName];
+
+ description2 = description2.replace(
+ new RegExp(`\`\\b${typeName}\\b\``, "g"),
+ typeMapping
+ );
+ }
+
+ for (const names of functionNames) {
+ const normalName = names
+ .split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+ const formattedLink = normalName.toLowerCase().replace(/\s+/g, "-");
+ const link = `[\`${normalName}\`](/components/${input}/${formattedLink})`
+ description2 = description2.replace(new RegExp(`\`\\b${names}\\b\``, "g"), link);
+ }
+
+ mdxContent += `| ${paramName} | ${paramType} | ${description2} |\n`;
+ }
+
+ mdxContent += "\n";
+ }
+
+ mdxContent += "**Signatures**\n\n";
+ mdxContent += "\n";
+
+ // Reorder Code tabs
+ languageOrder.forEach((lang) => {
+ if (func.signatures[lang]) {
+ const code = func.signatures[lang].join("\n");
+ const languageLabel = languageLabelMappings[lang] || lang;
+ mdxContent += ` \n`;
+ mdxContent +=
+ "```" + lang + "\n" + code + '\n```\n';
+ mdxContent += " \n";
+ }
+ });
+
+ mdxContent += "\n\n";
+ mdxContent += "---\n"; // Add --- after each function ends
+
+ });
+ }
+ let allTypes = [];
+
+ allTypes.push(...category.typedefs, ...category.enums, ...category.structs);
+ // Remove empty arrays
+ allTypes = allTypes.filter((type) => type.name != undefined); // Assuming name property is present
+
+ const sortedTypes = allTypes.sort((a, b) => a.name.localeCompare(b.name));
+
+ if (sortedTypes.length > 0) {
+ // Add the Types section
+ mdxContent += "## Types\n\n";
+
+ sortedTypes.forEach((type) => {
+ if(type.name != undefined) {
+ const formattedName = type.name
+ .split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+
+ const formattedTypeName = formattedName || `\`${type.name}\``;
+ mdxContent += `### ${formattedTypeName} [๐งพ](#${type.name.toLowerCase()})\n\n`;
+
+ let description = type.description || "";
+ for (const typeName in typeMappings) {
+ const typeMapping = typeMappings[typeName];
+ description = description.replace(new RegExp(`\`\\b${typeName}\\b\``, "g"), typeMapping);
+ }
+
+ for (const names of functionNames) {
+ const normalName = names
+ .split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+ const formattedLink = normalName.toLowerCase().replace(/\s+/g, "-");
+ const link = `[\`${normalName}\`](/components/${input}/${formattedLink})`
+ description = description.replace(new RegExp(`\`\\b${names}\\b\``, "g"), link);
+ }
+
+
+ mdxContent += `${description}\n\n`;
+ // If it's a struct, add a table for its fields
+ if (type.fields) {
+ mdxContent +=
+ "| Field | Type | Description |\n";
+ mdxContent +=
+ "| ------ | -------------------------------------------------- | ---------------------------------------------------------------------------------- |\n";
+
+ for (const fieldName in type.fields) {
+ const field = type.fields[fieldName];
+ const fieldType = typeMappings[field.type] || field.type;
+ let fieldDescription = field.description || "";
+
+ for (const typeName in typeMappings) {
+ const typeMapping = typeMappings[typeName];
+ fieldDescription = fieldDescription.replace(
+ new RegExp(`\`\\b${typeName}\\b\``, "g"),
+ typeMapping
+ );
+ }
+ for (const names of functionNames) {
+ const normalName = names
+ .split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+ const formattedLink = normalName.toLowerCase().replace(/\s+/g, "-");
+ const link = `[\`${normalName}\`](/components/${input}/${formattedLink})`
+ description = description.replace(new RegExp(`\`\\b${names}\\b\``, "g"), link);
+ }
+
+ mdxContent += `| ${fieldName} | ${fieldType} | ${fieldDescription.replace(/\n/g, '')} |\n`;
+ }
+
+ mdxContent += "\n";
+ }
+
+ // If it's an enum, add a table for its constants
+ if (type.constants) {
+ mdxContent +=
+ "| Constant | Value | Description |\n";
+ mdxContent +=
+ "| ------------------- | ----- | -------------------------- |\n";
+
+ for (const constantName in type.constants) {
+ const constant = type.constants[constantName];
+ const constantValue = constant.number !== undefined ? constant.number : "";
+ const constantDescription = constant.description || "";
+
+ mdxContent += `| ${constantName} | ${constantValue} | ${constantDescription.replace(/\n/g, '')} |\n`;
+ }
+
+ mdxContent += "\n";
+ }
+ for (const typeName in typeMappings) {
+ const typeMapping = typeMappings[typeName];
+ description = description.replace(new RegExp(`\`\\b${typeName}\\b\``, "g"), typeMapping);
+ }
+ for (const names of functionNames) {
+ const normalName = names
+ .split("_")
+ .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
+ .join(" ");
+ const formattedLink = normalName.toLowerCase().replace(/\s+/g, "-");
+ const link = `[\`${normalName}\`](/components/${input}/${formattedLink})`
+ description = description.replace(new RegExp(`\`\\b${names}\\b\``, "g"), link);
+ }
+
+ mdxContent += `${description}\n\n`;
+ mdxContent += `---\n`;
+ }});
+ }
+
+
+
+
+ // Write the MDX file
+ fs.writeFile(`./src/content/docs/components/${name}.mdx`, mdxContent, (err) => {
+ if (err) {
+ spinner.fail(kleur.red(`Error writing ${input} MDX file: ${err.message}`));
+
+ } else {
+
+ spinner.succeed(kleur.yellow('Generated')+kleur.green(` -> ${input}`));
+
+ }
+
+ });
+
+ }
+ console.log(kleur.green("All component MDX files generated successfully.\n"));
+ function createSpinner(text) {
+ const spinner = spinners.dots;
+
+ process.stdout.write(`${text}... `);
+
+ const frames = spinner.frames.map(frame => kleur.cyan(frame));
+ const interval = setInterval(() => {
+ const frame = frames.shift();
+ frames.push(frame);
+ process.stdout.write(frame);
+ }, spinner.interval);
+
+ return {
+ succeed: (message) => {
+ clearInterval(interval);
+ process.stdout.clearLine();
+ process.stdout.cursorTo(0);
+ console.log(kleur.green(`${message} โ`));
+ },
+ fail: (message) => {
+ clearInterval(interval);
+ process.stdout.clearLine();
+ process.stdout.cursorTo(0);
+ console.log(kleur.red(`${message} โ`));
+ },
+ };
+ }
+
+ } catch (error) {
+ console.error(kleur.red("Error parsing JSON:"), error);
+ }
+});
+
diff --git a/scripts/guides.cjs b/scripts/guides.cjs
new file mode 100644
index 00000000..72fa0497
--- /dev/null
+++ b/scripts/guides.cjs
@@ -0,0 +1,150 @@
+const fs = require('fs').promises;
+const path = require('path');
+const yaml = require('js-yaml');
+const spinners = require('cli-spinners');
+const kleur = require('kleur');
+
+const rootPath = path.join(__dirname, '..', 'src', 'content', 'docs', 'guides');
+
+try {
+ async function processFolder(folderPath, topLevelFolderName = '') {
+ const folders = folderPath.split(path.sep);
+ const lastTwoFolders = folders.slice(-2);
+ const spinner = createSpinner(`Processing ${lastTwoFolders.join(' -> ')}`);
+
+ try {
+ const files = await fs.readdir(folderPath);
+ const linkCards = [];
+
+ for (const file of files) {
+ const filePath = path.join(folderPath, file);
+ const isDirectory = (await fs.stat(filePath)).isDirectory();
+
+ if (isDirectory) {
+ const subfolderName = path.basename(filePath);
+
+ // Recursive call to process subfolder
+ await processFolder(filePath, `${topLevelFolderName ? `${topLevelFolderName}/` : ''}${subfolderName}`);
+
+ // Add LinkCard for subfolder
+ linkCards.push(
+ ``
+ );
+ } else {
+ const extname = path.extname(filePath);
+
+ if (extname === '.md' || extname === '.mdx') {
+ if (file !== 'index.mdx') {
+ const fileContent = await fs.readFile(filePath, 'utf-8');
+ const frontmatter = extractFrontmatter(fileContent, filePath);
+
+ const author = frontmatter.author || 'Various';
+ const lastupdated = frontmatter.lastupdated ? `on ${frontmatter.lastupdated}` : '';
+
+ // Convert title to lowercase and replace spaces with '-'
+ const folderTitle = path.relative(rootPath, folderPath).split(path.sep).join('/').toLowerCase();
+
+ // Convert file name to lowercase and replace spaces with '-'
+ const fileName = file.replace(/\.mdx?$/, '').toLowerCase().replace(/ /g, '-');
+
+ linkCards.push(
+ ``
+ );
+ }
+ }
+ }
+ }
+
+ const indexMdxContent = generateIndexMdxContent(linkCards);
+ const indexFilePath = path.join(folderPath, 'index.mdx');
+
+ await fs.writeFile(indexFilePath, indexMdxContent);
+ const folders = indexFilePath.split(path.sep);
+ const lastTwoFolders = folders.slice(-2);
+
+ spinner.succeed(kleur.green(`Generated ${lastTwoFolders.join(' -> ')}`));
+ } catch (error) {
+ const folders = folderPath.split(path.sep);
+ const lastTwoFolders = folders.slice(-2);
+
+
+ spinner.fail(kleur.red(`Error processing ${lastTwoFolders.join(' -> ')}: ${error.message}`));
+ }
+ }
+
+ function createSpinner(text) {
+ const spinner = spinners.dots;
+
+ process.stdout.write(`${text}... `);
+
+ const interval = setInterval(() => {
+ process.stdout.write(kleur.cyan(spinner.frame()));
+ }, spinner.interval);
+
+ return {
+ succeed: (message) => {
+ clearInterval(interval);
+ process.stdout.clearLine();
+ process.stdout.cursorTo(0);
+ console.log(kleur.green(`${message} โ`));
+ },
+ fail: (message) => {
+ clearInterval(interval);
+ process.stdout.clearLine();
+ process.stdout.cursorTo(0);
+ console.log(kleur.red(`${message} โ`));
+ },
+ };
+ }
+
+ function extractFrontmatter(content, filePath) {
+ const frontmatterRegex = /^---\n([\s\S]+?)\n---/;
+ const match = content.match(frontmatterRegex);
+
+ if (match && match[1]) {
+ const frontmatterString = match[1];
+
+ try {
+ const frontmatter = yaml.load(frontmatterString);
+
+ // Ensure that the frontmatter is an object
+ if (frontmatter && typeof frontmatter === 'object') {
+ return frontmatter;
+ } else {
+ console.error(`Invalid frontmatter in file: ${filePath}`);
+ }
+ } catch (error) {
+ console.error(`Error parsing frontmatter in file: ${filePath}`);
+ }
+ }
+
+ return {};
+ }
+
+ function generateIndexMdxContent(linkCards) {
+ return `---
+title: Index Routing Page
+sidebar:
+ hidden: true
+---
+
+import { LinkCard, CardGrid } from "@astrojs/starlight/components";
+
+
+ ${linkCards.join('\n ')}
+
+`;
+ }
+
+ processFolder(rootPath);
+} catch (error) {
+ console.log(error);
+}
\ No newline at end of file
diff --git a/src/content/docs/guides/Animations/Using Animation.mdx b/src/content/docs/guides/Animations/Using Animation.mdx
index 4f88a52b..f508bd31 100644
--- a/src/content/docs/guides/Animations/Using Animation.mdx
+++ b/src/content/docs/guides/Animations/Using Animation.mdx
@@ -1,8 +1,8 @@
---
-
title: Using Animations
-description: Animations allow you to switch between different images to make a more visually dynamic entity
- on the screen. SplashKit allows you to create animations and use these together with sprite sheets to create these animations.
+description: Animations allow you to switch between different images to make a more visually dynamic entity on the screen. SplashKit allows you to create animations and use these together with sprite sheets to create these animations.
+author: Andrew Cain
+lastupdated: May 29 2018
sidebar:
order: 1
---
diff --git a/src/content/docs/guides/Animations/index.mdx b/src/content/docs/guides/Animations/index.mdx
deleted file mode 100644
index ff7ee221..00000000
--- a/src/content/docs/guides/Animations/index.mdx
+++ /dev/null
@@ -1,27 +0,0 @@
----
-title: Animation Guide
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/Audio/GettingStartedAudio.mdx b/src/content/docs/guides/Audio/GettingStartedAudio.mdx
index 6669eb21..c7bb3037 100644
--- a/src/content/docs/guides/Audio/GettingStartedAudio.mdx
+++ b/src/content/docs/guides/Audio/GettingStartedAudio.mdx
@@ -1,6 +1,8 @@
---
title: Get started with SplashKit Audio
description: Adding sound effects and music can really help bring an application to life. In this article see how to get started with Audio in SplashKit.
+author: Various
+lastupdated: Jun 10 2018
sidebar:
order: 2
---
diff --git a/src/content/docs/guides/Audio/index.mdx b/src/content/docs/guides/Audio/index.mdx
deleted file mode 100644
index 54ae8122..00000000
--- a/src/content/docs/guides/Audio/index.mdx
+++ /dev/null
@@ -1,19 +0,0 @@
----
-title: Audio Guide
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/Camera/about-camera.mdx b/src/content/docs/guides/Camera/about-camera.mdx
index 7a7c9919..bcb71497 100644
--- a/src/content/docs/guides/Camera/about-camera.mdx
+++ b/src/content/docs/guides/Camera/about-camera.mdx
@@ -2,6 +2,8 @@
title: Using the SplashKit Camera
description: See how the camera works, and how to draw to the different coordinate systems in your program.
+author: Andrew Cain
+lastupdated: Aug 16 2018
sidebar:
order: 3
---
diff --git a/src/content/docs/guides/Camera/index.mdx b/src/content/docs/guides/Camera/index.mdx
deleted file mode 100644
index 1fc2a5c3..00000000
--- a/src/content/docs/guides/Camera/index.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: Camera Guide
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/Database/index.mdx b/src/content/docs/guides/Database/index.mdx
deleted file mode 100644
index 142dc734..00000000
--- a/src/content/docs/guides/Database/index.mdx
+++ /dev/null
@@ -1,20 +0,0 @@
----
-title: Database Guide
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/Database/using-databases.mdx b/src/content/docs/guides/Database/using-databases.mdx
index f72b1f22..de18bfac 100644
--- a/src/content/docs/guides/Database/using-databases.mdx
+++ b/src/content/docs/guides/Database/using-databases.mdx
@@ -1,10 +1,12 @@
---
-
title: Using Databases
description: Databases are powerful tools for persisting, and querying data. In this guide, we'll be looking at SplashKit's SQLite3 database, and how to use it.
+author: Jake Renzella
+lastupdated: Oct 3 2017
sidebar:
order: 4
---
+
*Written by Jake Renzella on Oct 3 2017*
import { Tabs, TabItem } from "@astrojs/starlight/components";
diff --git a/src/content/docs/guides/Inputs/index.mdx b/src/content/docs/guides/Inputs/index.mdx
deleted file mode 100644
index 0868f8da..00000000
--- a/src/content/docs/guides/Inputs/index.mdx
+++ /dev/null
@@ -1,20 +0,0 @@
----
-title: Input Guide
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/JSON/index.mdx b/src/content/docs/guides/JSON/index.mdx
deleted file mode 100644
index 36649e40..00000000
--- a/src/content/docs/guides/JSON/index.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: JSON Guide
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/Networking/index.mdx b/src/content/docs/guides/Networking/index.mdx
deleted file mode 100644
index d055e027..00000000
--- a/src/content/docs/guides/Networking/index.mdx
+++ /dev/null
@@ -1,31 +0,0 @@
----
-title: Networking Guide
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/Others/Cmake/1 Get started.md b/src/content/docs/guides/Others/Cmake/1 Get started.md
new file mode 100644
index 00000000..99241ce8
--- /dev/null
+++ b/src/content/docs/guides/Others/Cmake/1 Get started.md
@@ -0,0 +1,30 @@
+๏ปฟ---
+title: Getting Started With Sprite Layering In SplashKit - C++
+description: CMake
+author: Bryan Taing
+lastupdated: September 6 2023
+sidebar:
+ order: 10
+---
+
+
+Welcome to this CMake tutorial. We'll cover the fundamental features of CMake, a project management tool used to guide the compilation process for various operating systems. CMake is commonly employed for tasks like library management and software testing to ensure proper functionality.
+## Install Pre-requisites
+
+- Download and Install MSYS in https://www.msys2.org/
+- prompt these commands:
+>pacman -S git --noconfirm --disable-download-timeout
+>bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
+- prompt "skm" ensure everything is good to go
+- Install compilers:
+>pacman --disable-download-timeout -S mingw-w64-{x86_64,i686}-gcc mingw-w64-{i686,x86_64}-gdb
+- Install cmake and make:
+>pacman -S mingw-w64-x86_64-cmake
+>pacman -S mingw-w64-x86_64-make
+
+
+
+## Expected Learning Outcomes
+The learning outcome that the reader can expect to have gained after the completion of this tutorial is to have a basic understanding of Cmake, including the understanding of library management for different operating system.
+
+
diff --git a/src/content/docs/guides/Others/Cmake/1. Get started.md b/src/content/docs/guides/Others/Cmake/1. Get started.md
deleted file mode 100644
index 532cdbc9..00000000
--- a/src/content/docs/guides/Others/Cmake/1. Get started.md
+++ /dev/null
@@ -1,41 +0,0 @@
-๏ปฟ---
-title: Getting Started With Sprite Layering In SplashKit - C++
-description: CMake
-sidebar:
- order: 10
----
-
-Welcome to this CMake tutorial. We'll cover the fundamental features of CMake, a project management tool used to guide the compilation process for various operating systems. CMake is commonly employed for tasks like library management and software testing to ensure proper functionality.
-## Install Pre-requisites
-
-- Download and Install MSYS in https://www.msys2.org/
-- prompt these commands:
->pacman -S git --noconfirm --disable-download-timeout
->bash <(curl -s https://raw.githubusercontent.com/splashkit/skm/master/install-scripts/skm-install.sh)
-- prompt "skm" ensure everything is good to go
-- Install compilers:
->pacman --disable-download-timeout -S mingw-w64-{x86_64,i686}-gcc mingw-w64-{i686,x86_64}-gdb
-- Install cmake and make:
->pacman -S mingw-w64-x86_64-cmake
->pacman -S mingw-w64-x86_64-make
-
-## Table of Content
-1. [Build your first project](https://github.com/MangoS9/SplashKit-Tutorial/blob/main/Cmake%20Tutorial/2.%20Build%20our%20First%20Cmake.md)
-2. [Variables](https://github.com/MangoS9/SplashKit-Tutorial/blob/main/Cmake%20Tutorial/3.%20Variables.md)
-3. [Conditional Statement](https://github.com/MangoS9/SplashKit-Tutorial/blob/main/Cmake%20Tutorial/4.%20Conditional%20Statement.md)
-4. [Loop Statement](https://github.com/MangoS9/SplashKit-Tutorial/blob/main/Cmake%20Tutorial/5.%20Loop%20statement.md)
-5. [Including Library](https://github.com/MangoS9/SplashKit-Tutorial/blob/main/Cmake%20Tutorial/6.%20Including%20Library.md)
-6. [Add Custom Command](https://github.com/MangoS9/SplashKit-Tutorial/blob/main/Cmake%20Tutorial/7.%20Add%20Custom%20Command.md)
-7. [Cross-platforming](https://github.com/MangoS9/SplashKit-Tutorial/blob/main/Cmake%20Tutorial/7.%20Add%20Custom%20Command.md)
-1. [Build your first project](./2.%20Build%20our%20First%20Cmake.md)
-2. [Variables](./3.%20Variables.md)
-3. [Conditional Statement](./4.%20Conditional%20Statement.md)
-4. [Loop Statement](./5.%20Loop%20statement.md)
-5. [Including Library](./6.%20Including%20Library.md)
-6. [Add Custom Command](./7.%20Add%20Custom%20Command.md)
-7. [Cross-platforming](./8.%20Cross-platforming.md)
-
-## Expected Learning Outcomes
-The learning outcome that the reader can expect to have gained after the completion of this tutorial is to have a basic understanding of Cmake, including the understanding of library management for different operating system.
-
-
diff --git a/src/content/docs/guides/Others/Cmake/2. Build our First Cmake.md b/src/content/docs/guides/Others/Cmake/2 Build our First Cmake.md
similarity index 97%
rename from src/content/docs/guides/Others/Cmake/2. Build our First Cmake.md
rename to src/content/docs/guides/Others/Cmake/2 Build our First Cmake.md
index 10fdc95d..9d278972 100644
--- a/src/content/docs/guides/Others/Cmake/2. Build our First Cmake.md
+++ b/src/content/docs/guides/Others/Cmake/2 Build our First Cmake.md
@@ -1,8 +1,11 @@
๏ปฟ---
title: Build your first Cmake
description: CMake
+author: Bryan Taing
+lastupdated: September 6 2023
---
+
# Title: Build your first Cmake
- Create a simple "cpp" that prints Hello world:
```cpp
diff --git a/src/content/docs/guides/Others/Cmake/3. Variables.md b/src/content/docs/guides/Others/Cmake/3 Variables.md
similarity index 96%
rename from src/content/docs/guides/Others/Cmake/3. Variables.md
rename to src/content/docs/guides/Others/Cmake/3 Variables.md
index 869256bc..4f68b426 100644
--- a/src/content/docs/guides/Others/Cmake/3. Variables.md
+++ b/src/content/docs/guides/Others/Cmake/3 Variables.md
@@ -1,6 +1,8 @@
๏ปฟ---
title: Variables
description: CMake
+author: Bryan Taing
+lastupdated: September 6 2023
---
In this tutorial we are going to cover how to declare variables in Cmake.
Just like other programming, Cmake has variable for:
diff --git a/src/content/docs/guides/Others/Cmake/4. Conditional Statement.md b/src/content/docs/guides/Others/Cmake/4 Conditional Statement.md
similarity index 93%
rename from src/content/docs/guides/Others/Cmake/4. Conditional Statement.md
rename to src/content/docs/guides/Others/Cmake/4 Conditional Statement.md
index 29027b07..912f836f 100644
--- a/src/content/docs/guides/Others/Cmake/4. Conditional Statement.md
+++ b/src/content/docs/guides/Others/Cmake/4 Conditional Statement.md
@@ -1,8 +1,14 @@
๏ปฟ---
title: Conditional Statement
description: CMake
+author: Bryan Taing
+lastupdated: September 6 2023
---
+
+## Introduction
+
+
In this tutorial we are going to learn how to use the conditional statement in Cmake. This is just like any other language's if-else statement, let's look an an example:
```cpp
cmake_minimum_required(VERSION 3.5)
diff --git a/src/content/docs/guides/Others/Cmake/5. Loop statement.md b/src/content/docs/guides/Others/Cmake/5 Loop statement.md
similarity index 92%
rename from src/content/docs/guides/Others/Cmake/5. Loop statement.md
rename to src/content/docs/guides/Others/Cmake/5 Loop statement.md
index 9de456d1..fdcb531e 100644
--- a/src/content/docs/guides/Others/Cmake/5. Loop statement.md
+++ b/src/content/docs/guides/Others/Cmake/5 Loop statement.md
@@ -1,8 +1,14 @@
๏ปฟ---
title: Loop statement
description: CMake
+author: Bryan Taing
+lastupdated: September 6 2023
---
+
+## Introduction
+
+
In this tutorial we are going to cover the different loop statement in Cmake. Unfortunately, Cmake only has 1 type of loop which is `foreach()` loop, but this is all we needed for this language.
```c
cmake_minimum_required(VERSION 3.5)
diff --git a/src/content/docs/guides/Others/Cmake/6. Including Library.md b/src/content/docs/guides/Others/Cmake/6 Including Library.md
similarity index 97%
rename from src/content/docs/guides/Others/Cmake/6. Including Library.md
rename to src/content/docs/guides/Others/Cmake/6 Including Library.md
index 22312c41..1c18e9cb 100644
--- a/src/content/docs/guides/Others/Cmake/6. Including Library.md
+++ b/src/content/docs/guides/Others/Cmake/6 Including Library.md
@@ -1,8 +1,15 @@
๏ปฟ---
title: Including Library
description: CMake
+author: Bryan Taing
+lastupdated: September 6 2023
---
+
+## Introduction
+
+
+
Now we covered the fundamental of coding in Cmake, in this tutorial we are learning core feature of Cmake, which is how to include a library in our project. Before demonstrating of how it works, first we need to make our own library. In this example we're going to build a custom, library to print string to our console.
first we make a lib folder and create a header file call "print.h"
```cpp
diff --git a/src/content/docs/guides/Others/Cmake/7. Add Custom Command.md b/src/content/docs/guides/Others/Cmake/7 Add Custom Command.md
similarity index 95%
rename from src/content/docs/guides/Others/Cmake/7. Add Custom Command.md
rename to src/content/docs/guides/Others/Cmake/7 Add Custom Command.md
index 4c261bd1..48779f80 100644
--- a/src/content/docs/guides/Others/Cmake/7. Add Custom Command.md
+++ b/src/content/docs/guides/Others/Cmake/7 Add Custom Command.md
@@ -1,6 +1,8 @@
๏ปฟ---
title: Add Custom Command
description: CMake
+author: Bryan Taing
+lastupdated: September 6 2023
---
In this tutorial, we are going to cover how to add custom command to our compiler. This is basically telling what the compiler should do like copy the file, change directory etc. In this example we merely going to learn how to move files in a directory:
diff --git a/src/content/docs/guides/Others/Cmake/8. Cross-platforming.md b/src/content/docs/guides/Others/Cmake/8 Cross-platforming.md
similarity index 91%
rename from src/content/docs/guides/Others/Cmake/8. Cross-platforming.md
rename to src/content/docs/guides/Others/Cmake/8 Cross-platforming.md
index 2f8a8995..f3813c6f 100644
--- a/src/content/docs/guides/Others/Cmake/8. Cross-platforming.md
+++ b/src/content/docs/guides/Others/Cmake/8 Cross-platforming.md
@@ -1,8 +1,12 @@
๏ปฟ---
title: Cross Platforming
description: CMake
+author: Bryan Taing
+lastupdated: September 6 2023
---
+## Inroduction
+
In this tutorial, we are covering how to apply conditions depending on different operating system. It is relatively simple, all you need to do is using the conditional statement and check the special keyword built in Cmake:
```c
```cmake
diff --git a/src/content/docs/guides/Others/Cmake/9. Cmake with SplashKit.md b/src/content/docs/guides/Others/Cmake/9 Cmake with SplashKit.md
similarity index 97%
rename from src/content/docs/guides/Others/Cmake/9. Cmake with SplashKit.md
rename to src/content/docs/guides/Others/Cmake/9 Cmake with SplashKit.md
index 0dd81212..c6ac456d 100644
--- a/src/content/docs/guides/Others/Cmake/9. Cmake with SplashKit.md
+++ b/src/content/docs/guides/Others/Cmake/9 Cmake with SplashKit.md
@@ -1,12 +1,13 @@
---
title: Building the SplashKit Core Library with CMake
description: CMake
+author: Bryan Taing
+lastupdated: September 6 2023
---
## Introduction
-
In this tutorial we are going the cover how to build splashkit core library in our project using Cmake. SplashKit-core already had a pre-made `CmakeLists.txt` file in `splashkit-core\projects\cmake`. Feel free to explore and tinker the setting over there.
diff --git a/src/content/docs/guides/Others/index.mdx b/src/content/docs/guides/Others/index.mdx
deleted file mode 100644
index 1c6e2e15..00000000
--- a/src/content/docs/guides/Others/index.mdx
+++ /dev/null
@@ -1,21 +0,0 @@
----
-title: Other Guides
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
- order: 11
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/Sprites/index.mdx b/src/content/docs/guides/Sprites/index.mdx
deleted file mode 100644
index d15ab0d8..00000000
--- a/src/content/docs/guides/Sprites/index.mdx
+++ /dev/null
@@ -1,23 +0,0 @@
----
-title: Starter Guides
-description: A guide on installing SplashKit SDK
-sidebar:
- order: 8
- hidden: true
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
diff --git a/src/content/docs/guides/Starter/index.mdx b/src/content/docs/guides/Starter/index.mdx
deleted file mode 100644
index 71f9829d..00000000
--- a/src/content/docs/guides/Starter/index.mdx
+++ /dev/null
@@ -1,42 +0,0 @@
----
-title: Starter Guides
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
- order: 9
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/Utilities/index.mdx b/src/content/docs/guides/Utilities/index.mdx
deleted file mode 100644
index 59906ab4..00000000
--- a/src/content/docs/guides/Utilities/index.mdx
+++ /dev/null
@@ -1,22 +0,0 @@
----
-title: Utilities Guide
-description: A guide on installing SplashKit SDK
-sidebar:
- hidden: true
- order: 10
----
-
-import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-
-
-
-
-
-
-
-
-
diff --git a/src/content/docs/guides/index.mdx b/src/content/docs/guides/index.mdx
index dda7cfc0..d2d8a077 100644
--- a/src/content/docs/guides/index.mdx
+++ b/src/content/docs/guides/index.mdx
@@ -1,74 +1,65 @@
---
-title: Guides
-description: A guide on installing SplashKit SDK
+title: Index Routing Page
sidebar:
- hidden: true
+ hidden: true
---
import { LinkCard, CardGrid } from "@astrojs/starlight/components";
-import { ScriptComp } from '../../../assets/ScriptComp'
-
-The subsequent content comprises a collection of guides, articles, and tutorials pertinent to the Splash Kit SDK.
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
-
-
-
\ No newline at end of file
diff --git a/test/script-old.js b/test/script-old.js
deleted file mode 100644
index 4a486aee..00000000
--- a/test/script-old.js
+++ /dev/null
@@ -1,233 +0,0 @@
-// Script to generate .mdx file in a specific format to adapt to Starlight from JSON data.
-
-import { readFile, writeFile } from "fs";
-
-// Define type mappings
-const typeMappings = {
- int: "`Integer`",
- double: "`Double`",
- bool: "`Boolean`",
- char: "`Char`",
- string: "`String`",
- void: "`Void`",
- float: "`Float`",
- vector: "`Vector`",
- animation: "[`Animation`](/components/types/#animation)",
- animation_script: "[`Animation Script`](/components/types/#animation-script)",
- bitmap: "[`Bitmap`](/components/types/#bitmap)",
- circle: "[`Circle`](/components/types/#circle)",
- color: "[`Color`](/components/types/#color)",
- display: "[`Display`](/components/types/#display)",
- drawing_dest: "[`Drawing Dest`](/components/types/#drawing-dest)",
- drawing_options: "[`Drawing Options`](/components/types/#drawing-options)",
- font: "[`Font`](/components/types/#font)",
- font_style: "[`Font Style`](/components/types/#font-style)",
- http_status_code: "[`HTTP Status Code`](/components/types/#http-status-code)",
- line: "[`Line`](/components/types/#line)",
- point_2d: "[`Point 2D`](/components/types/#point-2d)",
- quad: "[`Quad`](/components/types/#quad)",
- rectangle: "[`Rectangle`](/components/types/#rectangle)",
- triangle: "[`Triangle`](/components/types/#triangle)",
- vector_2d: "[`Vector 2D`](/components/types/#vector-2d)",
- database: "[`Database`](/components/database/#database)",
- query_result: "[`Query Result`](/components/database/#query-result)",
- key_callback: "[`Key Callback`](/components/input/#key-callback)",
- key_code: "[`Key Code`](/components/input/#key-code)",
- mouse_button: "[`Mouse Button`](/components/input/#mouse-button)",
- json: "[`JSON`](/components/json/#json)",
- connection: "[`Connection`](/components/networking/#connection)",
- connection_type: "[`Connection Type`](/components/networking/#connection-type)",
- http_method: "[`HTTP Method`](/components/networking/#http-method)",
- http_request: "[`HTTP Request`](/components/networking/#http-request)",
- http_response: "[`HTTP Response`](/components/networking/#http-response)",
- message: "[`Message`](/components/networking/#message)",
- server_socket: "[`Server Socket`](/components/networking/#server-socket)",
- web_server: "[`Web Server`](/components/networking/#web-server)",
- matrix_2d: "[`Matrix 2D`](/components/physics/#matrix-2d)",
- collision_test_kind: "[`Collision Test Kind`](/components/sprites/#collision-test-kind)",
- sprite: "[`Sprite`](/components/sprites/#sprite)",
- sprite_event_handler: "[`Sprite Event Handler`](/components/sprites/#sprite-event-handler)",
- sprite_event_kind: "[`Sprite Event Kind`](/components/sprites/#sprite-event-kind)",
- sprite_float_function: "[`Sprite Float Function`](/components/sprites/#sprite-float-function)",
- sprite_function: "[`Sprite Function`](/components/sprites/#sprite-function)",
- music: "[`Music`](/components/audio/#music)",
- sound_effect: "[`Sound Effect`](/components/audio/#sound-effect)"
- // Add more type mappings as needed
-};
-
-// Define language label mappings
-const languageLabelMappings = {
- pascal: "Pascal",
- python: "Python",
- cpp: "C++",
- csharp: "C#",
- // Add more mappings as needed
-};
-
-
-// Define language order
-const languageOrder = ["cpp", "csharp", "python", "pascal"];
-
-// Read the JSON file
-readFile("./test/api.json", "utf8", (err, data) => {
- if (err) {
- console.error("Error reading JSON file:", err);
- return;
- }
-
- try {
- const jsonData = JSON.parse(data);
-
-// Please select an option: "animations, audio, camera, color, database, geometry, graphics, input, json, networking, physics, resource_bundles, resources, social, sprites, terminal, timers, types, utilities, windows"
-
- let input = "audio" // Channge here
-
-
-
-
- const category = jsonData.audio; // Change the category here
-
- const categoryFunctions = category.functions;
- let mdxContent = "";
- mdxContent += "---\n";
- mdxContent += `title: ${input.charAt(0).toUpperCase()+ input.slice(1)}\n`;
- mdxContent += `description: ${category.brief}\n`;
- mdxContent += "---\n";
- mdxContent += `\nimport { Tabs, TabItem } from "@astrojs/starlight/components";\n`;
- mdxContent += "## \n";
- mdxContent += "## Functions\n";
- mdxContent += "## \n";
- const functionGroups = {}; // Store functions grouped by name
- categoryFunctions.forEach((func) => {
- const functionName = func.name;
- if (!functionGroups[functionName]) {
- functionGroups[functionName] = [];
- }
- functionGroups[functionName].push(func);
- });
-
- for (const functionName in functionGroups) {
- const overloads = functionGroups[functionName];
- const isOverloaded = overloads.length > 1;
-
- if (isOverloaded) {
- // Create a section for overloaded functions
-
- const formattedFunctionName = functionName
- .split("_")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");
- const formattedLink = formattedFunctionName.toLowerCase().replace(/\s+/g, "-");
-
- const formattedGroupLink = `group-${formattedLink}`;
- mdxContent += `## ${formattedFunctionName} [๐งฌ](#${formattedGroupLink})\n\n`;
- mdxContent += ":::note\n\n";
- mdxContent += "This function is overloaded. The following versions exist:\n\n";
-
- overloads.forEach((func, index) => {
- mdxContent += `- [**${formattedFunctionName}** (`;
- for (const paramName in func.parameters) {
- const param = func.parameters[paramName];
- const paramType = param.type;
- if (index > 0) {
- mdxContent += "";
- }
- mdxContent += `${paramName}: ${paramType}, `;
- }
- mdxContent += `)](/components/${input}/#${formattedLink.toLowerCase()}--${index + 1})\n`;
- });
-
- mdxContent += "\n:::\n\n";
- }
-
- overloads.forEach((func, index) => {
- // Format the header based on whether it's overloaded or not
- let functionName2 = functionName.split("_")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");
- const formattedName3 = func.name
- .split("_")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");
-
- const formattedLink = formattedName3.toLowerCase().replace(/\s+/g, "-");
-
- const formattedName = isOverloaded
- ? `### ${functionName2} [๐ค](#${formattedLink.toLowerCase()}--${index + 1})`
- : `## ${functionName2} [๐](#${formattedLink})\n\n`;
-
-
- // Replace type names in the description with formatted versions
- let description = func.description || "";
- for (const typeName in typeMappings) {
- const typeMapping = typeMappings[typeName];
- description = description.replace(
- new RegExp(`\`\\b${typeName}\\b\``, "g"),
- typeMapping
- );
- }
-
- mdxContent += `${formattedName} \n`;
- mdxContent += description ? `${description}\n\n` : "";
- mdxContent += "**Return Type**\n\n- " + typeMappings[func.return.type] + " \n\n";
-
- // Add Parameters section only if there are parameters
- if (Object.keys(func.parameters).length > 0) {
- mdxContent += "**Parameters**\n\n";
- mdxContent +=
- "| Name | Type | Description |\n";
- mdxContent +=
- "| ------ | -------------------------------------------------- | ---------------------------------------------------------------------------------- |\n";
-
- for (const paramName in func.parameters) {
- const param = func.parameters[paramName];
- const paramType = typeMappings[param.type] || param.type;
- let description2 = param.description || "";
- for (const typeName in typeMappings) {
- const typeMapping = typeMappings[typeName];
-
- description2 = description2.replace(
- new RegExp(`\`\\b${typeName}\\b\``, "g"),
- typeMapping
- );
-
- }
-
- mdxContent += `| ${paramName} | ${paramType} | ${description2} |\n`;
- }
-
- mdxContent += "\n";
- }
-
- mdxContent += "**Signatures**\n\n";
- mdxContent += "\n";
-
- // Reorder Code tabs
- languageOrder.forEach((lang) => {
- if (func.signatures[lang]) {
- const code = func.signatures[lang].join("\n");
- const languageLabel = languageLabelMappings[lang] || lang;
- mdxContent += ` \n`;
- mdxContent +=
- "```"+lang+"\n" + code + '\n```\n';
- mdxContent += " \n";
- }
- });
-
- mdxContent += "\n\n";
- mdxContent += "---\n"; // Add --- after each function ends
- });
- }
-
- // Write the MDX file
- writeFile(`./test/${input}.mdx`, mdxContent, (err) => {
- if (err) {
- console.error("Error writing MDX file:", err);
- } else {
- console.log("MDX file generated successfully.");
- }
- });
- } catch (error) {
- console.error("Error parsing JSON:", error);
- }
-});
diff --git a/test/script.js b/test/script.js
deleted file mode 100644
index c6671713..00000000
--- a/test/script.js
+++ /dev/null
@@ -1,311 +0,0 @@
-// Script to generate .mdx file in a specific format to adapt to Starlight from JSON data.
-
-import { readFile, writeFile } from "fs";
-
-// Define type mappings
-const typeMappings = {
- int: "`Integer`",
- double: "`Double`",
- bool: "`Boolean`",
- char: "`Char`",
- string: "`String`",
- void: "`Void`",
- float: "`Float`",
- vector: "`Vector`",
- animation: "[`Animation`](/components/types/#animation)",
- animation_script: "[`Animation Script`](/components/types/#animation-script)",
- bitmap: "[`Bitmap`](/components/types/#bitmap)",
- circle: "[`Circle`](/components/types/#circle)",
- color: "[`Color`](/components/types/#color)",
- display: "[`Display`](/components/types/#display)",
- drawing_dest: "[`Drawing Dest`](/components/types/#drawing-dest)",
- drawing_options: "[`Drawing Options`](/components/types/#drawing-options)",
- font: "[`Font`](/components/types/#font)",
- font_style: "[`Font Style`](/components/types/#font-style)",
- http_status_code: "[`HTTP Status Code`](/components/types/#http-status-code)",
- line: "[`Line`](/components/types/#line)",
- point_2d: "[`Point 2D`](/components/types/#point-2d)",
- quad: "[`Quad`](/components/types/#quad)",
- rectangle: "[`Rectangle`](/components/types/#rectangle)",
- triangle: "[`Triangle`](/components/types/#triangle)",
- vector_2d: "[`Vector 2D`](/components/types/#vector-2d)",
- database: "[`Database`](/components/database/#database)",
- query_result: "[`Query Result`](/components/database/#query-result)",
- key_callback: "[`Key Callback`](/components/input/#key-callback)",
- key_code: "[`Key Code`](/components/input/#key-code)",
- mouse_button: "[`Mouse Button`](/components/input/#mouse-button)",
- json: "[`JSON`](/components/json/#json)",
- connection: "[`Connection`](/components/networking/#connection)",
- connection_type: "[`Connection Type`](/components/networking/#connection-type)",
- http_method: "[`HTTP Method`](/components/networking/#http-method)",
- http_request: "[`HTTP Request`](/components/networking/#http-request)",
- http_response: "[`HTTP Response`](/components/networking/#http-response)",
- message: "[`Message`](/components/networking/#message)",
- server_socket: "[`Server Socket`](/components/networking/#server-socket)",
- web_server: "[`Web Server`](/components/networking/#web-server)",
- matrix_2d: "[`Matrix 2D`](/components/physics/#matrix-2d)",
- collision_test_kind: "[`Collision Test Kind`](/components/sprites/#collision-test-kind)",
- sprite: "[`Sprite`](/components/sprites/#sprite)",
- sprite_event_handler: "[`Sprite Event Handler`](/components/sprites/#sprite-event-handler)",
- sprite_event_kind: "[`Sprite Event Kind`](/components/sprites/#sprite-event-kind)",
- sprite_float_function: "[`Sprite Float Function`](/components/sprites/#sprite-float-function)",
- sprite_function: "[`Sprite Function`](/components/sprites/#sprite-function)",
- music: "[`Music`](/components/audio/#music)",
- sound_effect: "[`Sound Effect`](/components/audio/#sound-effect)"
- // Add more type mappings as needed
-};
-const guidesAvailable = {
-animations: true,
-audio: true,
-camera: true,
-database: true,
-inputs: true,
-json: true,
-networking: true,
-sprites: true,
-utilities: true
-
-};
-// Define language label mappings
-const languageLabelMappings = {
- pascal: "Pascal",
- python: "Python",
- cpp: "C++",
- csharp: "C#",
- // Add more mappings as needed
-};
-
-
-// Define language order
-const languageOrder = ["cpp", "csharp", "python", "pascal"];
-var name = "";
-// Read the JSON file
-readFile("./test/api.json", "utf8", (err, data) => {
- if (err) {
- console.error("Error reading JSON file:", err);
- return;
- }
-
- try {
- const jsonData = JSON.parse(data);
-
- // Please select an option: "animations, audio, camera, color, database, geometry, graphics, input, json, networking, physics, resource_bundles, resources, social, sprites, terminal, timers, types, utilities, windows"
- for (const categoryKey in jsonData) {
- const category = jsonData[categoryKey];
- let input = categoryKey;
- const categoryFunctions = category.functions;
- let mdxContent = "";
- name = input.split("_")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");; //name of the category
-
- mdxContent += "---\n";
- mdxContent += `title: ${name}\n`;
- if(category.brief != "") {mdxContent += `description: ${category.brief.replace(/\n/g, '')}\n`;}
- else {mdxContent += `description: Some description....\n`;}
-
- mdxContent += "---\n\n";
- if(category.brief != "") {
- if(categoryFunctions.description != null) {
- mdxContent += `:::tip[${category.brief}]\n`;
- mdxContent += `${category.description}\n`
- mdxContent += `:::\n`
- }
- else {
- mdxContent += `:::tip[${name}]\n`;
- mdxContent += `${category.brief}\n`
- mdxContent += `:::\n`
- }
- }
- mdxContent += `\nimport { Tabs, TabItem } from "@astrojs/starlight/components";\nimport { LinkCard, CardGrid } from "@astrojs/starlight/components";
-\n `;
-if(guidesAvailable[categoryKey]) {
- mdxContent += "\n## \n";
- mdxContent += "## Animations Guides\n";
- mdxContent += `\n\n`;
- }
- mdxContent += "## \n";
- mdxContent += "## Functions\n";
- mdxContent += "## \n";
- const functionGroups = {}; // Store functions grouped by name
- categoryFunctions.forEach((func) => {
- const functionName = func.name;
- if (!functionGroups[functionName]) {
- functionGroups[functionName] = [];
- }
- functionGroups[functionName].push(func);
- });
-
- for (const functionName in functionGroups) {
- const overloads = functionGroups[functionName];
- const isOverloaded = overloads.length > 1;
-
- if (isOverloaded) {
- // Create a section for overloaded functions
-
- const formattedFunctionName = functionName
- .split("_")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");
- const formattedLink = formattedFunctionName.toLowerCase().replace(/\s+/g, "-");
-
- const formattedGroupLink = `group-${formattedLink}`;
- mdxContent += `## ${formattedFunctionName} [๐](#${formattedGroupLink})\n\n`;
- mdxContent += ":::note\n\n";
- mdxContent += "This function is overloaded. The following versions exist:\n\n";
-
- overloads.forEach((func, index) => {
- mdxContent += `- [**${formattedFunctionName}** (`;
- for (const paramName in func.parameters) {
- const param = func.parameters[paramName];
- const paramType = param.type;
- if (index > 0) {
- mdxContent += "";
- }
- mdxContent += `${paramName}: ${paramType}, `;
- }
- mdxContent += `)](/components/${input}/#${formattedLink.toLowerCase()}--${index + 1})\n`;
- });
-
- mdxContent += "\n:::\n\n";
- }
-
- overloads.forEach((func, index) => {
- // Format the header based on whether it's overloaded or not
- let functionName2 = functionName.split("_")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");
- const formattedName3 = func.name
- .split("_")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");
-
- const formattedLink = formattedName3.toLowerCase().replace(/\s+/g, "-");
-
- const formattedName = isOverloaded
- ? `### ${functionName2} [๐](#${formattedLink.toLowerCase()}--${index + 1})`
- : `## ${functionName2} [๐](#${formattedLink})\n\n`;
-
-
- // Replace type names in the description with formatted versions
- let description = func.description || "";
- for (const typeName in typeMappings) {
- const typeMapping = typeMappings[typeName];
- description = description.replace(
- new RegExp(`\`\\b${typeName}\\b\``, "g"),
- typeMapping
- );
- }
-
- mdxContent += `${formattedName} \n`;
- mdxContent += description ? `${description}\n\n` : "";
- mdxContent += "**Return Type**\n\n- " + typeMappings[func.return.type] + " \n\n";
-
- // Add Parameters section only if there are parameters
- if (Object.keys(func.parameters).length > 0) {
- mdxContent += "**Parameters**\n\n";
- mdxContent +=
- "| Name | Type | Description |\n";
- mdxContent +=
- "| ------ | -------------------------------------------------- | ---------------------------------------------------------------------------------- |\n";
-
- for (const paramName in func.parameters) {
- const param = func.parameters[paramName];
- const paramType = typeMappings[param.type] || param.type;
- let description2 = param.description || "";
- for (const typeName in typeMappings) {
- const typeMapping = typeMappings[typeName];
-
- description2 = description2.replace(
- new RegExp(`\`\\b${typeName}\\b\``, "g"),
- typeMapping
- );
-
- }
-
- mdxContent += `| ${paramName} | ${paramType} | ${description2} |\n`;
- }
-
- mdxContent += "\n";
- }
-
- mdxContent += "**Signatures**\n\n";
- mdxContent += "\n";
-
- // Reorder Code tabs
- languageOrder.forEach((lang) => {
- if (func.signatures[lang]) {
- const code = func.signatures[lang].join("\n");
- const languageLabel = languageLabelMappings[lang] || lang;
- mdxContent += ` \n`;
- mdxContent +=
- "```" + lang + "\n" + code + '\n```\n';
- mdxContent += " \n";
- }
- });
-
- mdxContent += "\n\n";
- mdxContent += "---\n"; // Add --- after each function ends
-
- });
- }
- if (category.typedefs.length > 0) {
- // Add the Types section
- mdxContent += "## Types\n\n";
- category.typedefs.forEach((typedef) => {
- const formattedName3 = typedef.name
- .split("_")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");
-
- const formattedTypeName = formattedName3 || `\`${typedef.name}\``;
- mdxContent += `### ${formattedTypeName} [๐งพ](#${typedef.name.toLowerCase()})\n\n`;
-
- let description = typedef.description || "";
- for (const typeName in typeMappings) {
- const typeMapping = typeMappings[typeName];
- description = description.replace(new RegExp(`\`\\b${typeName}\\b\``, "g"), typeMapping);
- }
- const functionNames = category.functions.map((func) => func.name);
- for (const names of functionNames) {
- const normalName = names
- .split("_")
- .map((word) => word.charAt(0).toUpperCase() + word.slice(1))
- .join(" ");
- const formattedLink = normalName.toLowerCase().replace(/\s+/g, "-");
- const link = `[\`${normalName}\`](/components/${input}/${formattedLink})`
- description = description.replace(new RegExp(`\`\\b${names}\\b\``, "g"), link);
- }
-
-
- mdxContent += `${description}\n\n`;
-
-
-
- mdxContent += `---\n`;
- });
- }
-
-
-
- // Write the MDX file
- writeFile(`./src/content/docs/components/${name}.mdx`, mdxContent, (err) => {
- if (err) {
- console.error(`Error writing ${input} MDX file:`, err);
-
- } else {
- console.log(input)
- }
-
- });
- }
- console.log("MDX files generated successfully: \n");
- } catch (error) {
- console.error("Error parsing JSON:", error);
- }
-});
-