Skip to content

Commit b522c3a

Browse files
committed
fix(lua.ts): handle types with modifiers correctly
Also fixed some prettier configs, using tabs now.
1 parent a9a298b commit b522c3a

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+1734
-1734
lines changed

.prettierrc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"tabWidth": 2,
3-
"useTabs": false
2+
"tabWidth": 2,
3+
"useTabs": true
44
}

.vscode/extensions.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"recommendations": ["astro-build.astro-vscode"],
3-
"unwantedRecommendations": []
2+
"recommendations": ["astro-build.astro-vscode"],
3+
"unwantedRecommendations": []
44
}

.vscode/launch.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
{
2-
"version": "0.2.0",
3-
"configurations": [
4-
{
5-
"command": "./node_modules/.bin/astro dev",
6-
"name": "Development server",
7-
"request": "launch",
8-
"type": "node-terminal"
9-
}
10-
]
2+
"version": "0.2.0",
3+
"configurations": [
4+
{
5+
"command": "./node_modules/.bin/astro dev",
6+
"name": "Development server",
7+
"request": "launch",
8+
"type": "node-terminal"
9+
}
10+
]
1111
}

.vscode/settings.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
2-
"typescript.tsdk": "node_modules/typescript/lib",
3-
"luau-lsp.require.mode": "relativeToFile",
4-
"luau-lsp.require.directoryAliases": {
5-
"@lune/": "~/.lune/.typedefs/0.8.4/"
6-
}
2+
"typescript.tsdk": "node_modules/typescript/lib",
3+
"luau-lsp.require.mode": "relativeToFile",
4+
"luau-lsp.require.directoryAliases": {
5+
"@lune/": "~/.lune/.typedefs/0.8.4/"
6+
}
77
}

astro.config.ts

Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,44 @@ import deno from "@deno/astro-adapter";
44

55
// https://astro.build/config
66
export default defineConfig({
7-
output: "server",
8-
adapter: deno(),
9-
image: {
10-
service: passthroughImageService(),
11-
},
12-
integrations: [
13-
starlight({
14-
title: "DiscordLuau Docs",
15-
social: {
16-
github: "https://github.com/DiscordLuau/discord-luau",
17-
},
18-
sidebar: [
19-
{
20-
label: "Guides",
21-
items: [
22-
// Each item here is one entry in the navigation menu.
23-
{
24-
label: "Example Guide",
25-
link: "/guides/example/",
26-
},
27-
],
28-
},
29-
{
30-
label: "Classes",
31-
autogenerate: {
32-
directory: "classes",
33-
},
34-
},
35-
],
36-
customCss: [
37-
"./src/styles/landing.css",
38-
"./src/styles/starlight.css",
39-
"./src/styles/lua.css",
40-
],
41-
components: {
42-
Hero: "./src/components/Hero.astro",
43-
Pagination: "./src/components/Pagination.astro",
44-
},
45-
}),
46-
],
7+
output: "server",
8+
adapter: deno(),
9+
image: {
10+
service: passthroughImageService(),
11+
},
12+
integrations: [
13+
starlight({
14+
title: "DiscordLuau Docs",
15+
social: {
16+
github: "https://github.com/DiscordLuau/discord-luau",
17+
},
18+
sidebar: [
19+
{
20+
label: "Guides",
21+
items: [
22+
// Each item here is one entry in the navigation menu.
23+
{
24+
label: "Example Guide",
25+
link: "/guides/example/",
26+
},
27+
],
28+
},
29+
{
30+
label: "Classes",
31+
autogenerate: {
32+
directory: "classes",
33+
},
34+
},
35+
],
36+
customCss: [
37+
"./src/styles/landing.css",
38+
"./src/styles/starlight.css",
39+
"./src/styles/lua.css",
40+
],
41+
components: {
42+
Hero: "./src/components/Hero.astro",
43+
Pagination: "./src/components/Pagination.astro",
44+
},
45+
}),
46+
],
4747
});

deno.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"deploy": {
3-
"project": "03cbb534-69ad-4381-a372-b25d5caa869c",
4-
"exclude": ["**/node_modules"],
5-
"include": [],
6-
"entrypoint": "dist/server/entry.mjs"
7-
}
2+
"deploy": {
3+
"project": "03cbb534-69ad-4381-a372-b25d5caa869c",
4+
"exclude": ["**/node_modules"],
5+
"include": [],
6+
"entrypoint": "dist/server/entry.mjs"
7+
}
88
}

package.json

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
{
2-
"name": "@discordluau/docs",
3-
"private": true,
4-
"type": "module",
5-
"version": "0.0.1",
6-
"packageManager": "[email protected]",
7-
"scripts": {
8-
"postinstall": "deno install -Arf jsr:@deno/deployctl",
9-
"dev": "astro dev",
10-
"start": "astro dev",
11-
"astro:build": "astro check && astro build",
12-
"build": "./lunew generateReference && pnpm astro:build",
13-
"preview": "astro preview",
14-
"astro": "astro",
15-
"deploy": "deployctl deploy --prod --entrypoint dist/server/entry.mjs",
16-
"fmt": "prettier -w ."
17-
},
18-
"dependencies": {
19-
"@astrojs/check": "^0.7.0",
20-
"@astrojs/starlight": "^0.23.1",
21-
"@deno/astro-adapter": "^0.1.2",
22-
"astro": "^4.8.6",
23-
"typescript": "^5.4.5"
24-
},
25-
"devDependencies": {
26-
"prettier": "^3.2.5"
27-
}
2+
"name": "@discordluau/docs",
3+
"private": true,
4+
"type": "module",
5+
"version": "0.0.1",
6+
"packageManager": "[email protected]",
7+
"scripts": {
8+
"postinstall": "deno install -Arf jsr:@deno/deployctl",
9+
"dev": "astro dev",
10+
"start": "astro dev",
11+
"astro:build": "astro check && astro build",
12+
"build": "./lunew generateReference && pnpm astro:build",
13+
"preview": "astro preview",
14+
"astro": "astro",
15+
"deploy": "deployctl deploy --prod --entrypoint dist/server/entry.mjs",
16+
"fmt": "prettier -w ."
17+
},
18+
"dependencies": {
19+
"@astrojs/check": "^0.7.0",
20+
"@astrojs/starlight": "^0.23.1",
21+
"@deno/astro-adapter": "^0.1.2",
22+
"astro": "^4.8.6",
23+
"typescript": "^5.4.5"
24+
},
25+
"devDependencies": {
26+
"prettier": "^3.2.5"
27+
}
2828
}

src/components/utils/lua.ts

Lines changed: 45 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,76 +1,76 @@
11
export type LuaType =
2-
| "nil"
3-
| ("boolean" | "bool")
4-
| "number"
5-
| "string"
6-
| "table"
7-
| ("tuple" | "...")
8-
| ("userdata" | "proxy");
2+
| "nil"
3+
| ("boolean" | "bool")
4+
| "number"
5+
| "string"
6+
| "table"
7+
| ("tuple" | "...")
8+
| ("userdata" | "proxy");
99

1010
export type LuaParam = {
11-
name: string;
12-
type: LuaType | string;
11+
name: string;
12+
type: LuaType | string;
1313
};
1414

1515
export const luaTypeDocs: Record<LuaType, string> = {
16-
nil: "2.1",
17-
boolean: "2.2",
18-
bool: "2.2",
19-
number: "2.3",
20-
string: "2.4",
21-
table: "2.5",
22-
tuple: "5.1",
23-
"...": "5.1",
24-
userdata: "28.1",
25-
proxy: "28.1",
16+
nil: "2.1",
17+
boolean: "2.2",
18+
bool: "2.2",
19+
number: "2.3",
20+
string: "2.4",
21+
table: "2.5",
22+
tuple: "5.1",
23+
"...": "5.1",
24+
userdata: "28.1",
25+
proxy: "28.1",
2626
};
2727

2828
export const removeTypeModifiers = (type: string) => {
29-
return type.replaceAll(/\?/g, "") as LuaType;
29+
return type.replaceAll(/\?/g, "") as LuaType;
3030
};
3131

32-
export const getLuaDocs = (luaType: LuaType | string) => {
33-
const normalizedType = removeTypeModifiers(luaType);
34-
const luaDocsBaseUrl = new URL("https://www.lua.org/pil");
35-
luaDocsBaseUrl.pathname += "/" + luaTypeDocs[normalizedType] + ".html";
32+
export const getLuaDocs = (luaType: LuaType) => {
33+
const luaDocsBaseUrl = new URL("https://www.lua.org/pil");
34+
luaDocsBaseUrl.pathname += "/" + luaTypeDocs[luaType] + ".html";
3635

37-
return luaDocsBaseUrl.toString();
36+
return luaDocsBaseUrl.toString();
3837
};
3938

4039
export const getCustomTypeDocs = (type: string) => {
41-
if (type == "()" || type == "any") {
42-
return null;
43-
}
40+
if (type == "()" || type == "any") {
41+
return null;
42+
}
4443

45-
const path =
46-
"/classes/" +
47-
type
48-
.split(".")
49-
.map((component) => component.toLocaleLowerCase())
50-
.join("/");
44+
const path =
45+
"/classes/" +
46+
type
47+
.split(".")
48+
.map((component) => component.toLocaleLowerCase())
49+
.join("/");
5150

52-
return path;
51+
return path;
5352
};
5453

5554
export const getTypeDocs = (type: string) => {
56-
return type in luaTypeDocs
57-
? getLuaDocs(type as LuaType)
58-
: getCustomTypeDocs(type);
55+
const normalizedType = removeTypeModifiers(type);
56+
return normalizedType in luaTypeDocs
57+
? getLuaDocs(normalizedType)
58+
: getCustomTypeDocs(type);
5959
};
6060

6161
export const typeOrDefault = (type?: string) => {
62-
return type ?? "()";
62+
return type ?? "()";
6363
};
6464

6565
export const getKvPairs = (tblInner: string) => {
66-
tblInner = tblInner.trim();
67-
const pairs = tblInner
68-
.split(",")
69-
.map((pair) => pair.split(":").map((elem) => elem.trim()));
66+
tblInner = tblInner.trim();
67+
const pairs = tblInner
68+
.split(",")
69+
.map((pair) => pair.split(":").map((elem) => elem.trim()));
7070

71-
return pairs;
71+
return pairs;
7272
};
7373

7474
export const isObject = (tblInner: string) => {
75-
return tblInner.match(/(.*):(.*)/) !== null;
75+
return tblInner.match(/(.*):(.*)/) !== null;
7676
};

src/content/config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import { defineCollection } from "astro:content";
22
import { docsSchema } from "@astrojs/starlight/schema";
33

44
export const collections = {
5-
docs: defineCollection({ schema: docsSchema() }),
5+
docs: defineCollection({ schema: docsSchema() }),
66
};

src/content/docs/classes/Builders/ActivityBuilder.mdx

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,44 +48,44 @@ An enumeration of activity types.
4848
### setActivityName
4949

5050
> <LuaDeclaration
51-
> name="setActivityName"
52-
> className="ActivityBuilder"
53-
> args={[{ name: "activityName", type: "string" }]}
54-
> returnType="Builders.ActivityBuilder"
55-
> isMethod
51+
> name="setActivityName"
52+
> className="ActivityBuilder"
53+
> args={[{ name: "activityName", type: "string" }]}
54+
> returnType="Builders.ActivityBuilder"
55+
> isMethod
5656
> />
5757
> Sets the name of the activity.
5858
5959
### setActivityType
6060

6161
> <LuaDeclaration
62-
> name="setActivityType"
63-
> className="ActivityBuilder"
64-
> args={[{ name: "activityType", type: "number" }]}
65-
> returnType="Builders.ActivityBuilder"
66-
> isMethod
62+
> name="setActivityType"
63+
> className="ActivityBuilder"
64+
> args={[{ name: "activityType", type: "number" }]}
65+
> returnType="Builders.ActivityBuilder"
66+
> isMethod
6767
> />
6868
> Sets the type of the activity.
6969
7070
### setStreamingURL
7171

7272
> <LuaDeclaration
73-
> name="setStreamingURL"
74-
> className="ActivityBuilder"
75-
> args={[{ name: "streamURL", type: "string" }]}
76-
> returnType="Builders.ActivityBuilder"
77-
> isMethod
73+
> name="setStreamingURL"
74+
> className="ActivityBuilder"
75+
> args={[{ name: "streamURL", type: "string" }]}
76+
> returnType="Builders.ActivityBuilder"
77+
> isMethod
7878
> />
7979
> Sets the streaming URL of the activity. Only YouTube and Twitch URLs are allowed.
8080
8181
### toPayloadObject
8282

8383
> <LuaDeclaration
84-
> name="toPayloadObject"
85-
> className="ActivityBuilder"
86-
> args={[]}
87-
> returnType="Network.Resolvable"
88-
> isMethod
84+
> name="toPayloadObject"
85+
> className="ActivityBuilder"
86+
> args={[]}
87+
> returnType="Network.Resolvable"
88+
> isMethod
8989
> />
9090
> Converts the activity to a JSON object that can be sent to the Discord API.
9191

0 commit comments

Comments
 (0)