Skip to content

Commit 0409969

Browse files
committed
fix(docs): fix api docs pages, add plugin pub date
1 parent 43c6c21 commit 0409969

17 files changed

+171
-147
lines changed

apps/docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"lint": "next lint",
1111
"vercel-build": "prisma generate && next build",
1212
"prisma:generate": "prisma generate",
13-
"docgen": "rm -rf src/pages/docs && node src/utils/docgen.mjs && node src/utils/docgen.mjs"
13+
"docgen": "rm -rf src/pages/docs/api && node src/utils/docgen.mjs && node src/utils/docgen.mjs"
1414
},
1515
"author": "DuroCodes",
1616
"license": "MIT",

apps/docs/src/components/Plugin.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ interface PluginProps {
1212
name: string;
1313
id: string;
1414
author: Author;
15+
createdAt: Date;
1516
}
1617

1718
export function PluginCard({ plugin }: { plugin: PluginProps; }) {
@@ -29,7 +30,13 @@ export function PluginCard({ plugin }: { plugin: PluginProps; }) {
2930
objectFit="cover"
3031
/>
3132
</div>
32-
{plugin.author.name}
33+
{plugin.author.name}{
34+
plugin.createdAt.toLocaleDateString('en-us', {
35+
year: 'numeric',
36+
month: 'short',
37+
day: 'numeric',
38+
})
39+
}
3340
</div>
3441
<style jsx global>{`
3542
html.dark .icon-circle {

apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkClient.mdx renamed to apps/docs/src/pages/docs/classes/SparkClient.mdx

Lines changed: 39 additions & 73 deletions
Large diffs are not rendered by default.

apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkCommand.mdx renamed to apps/docs/src/pages/docs/classes/SparkCommand.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: SparkCommand
3+
---
4+
15
## SparkCommand implements BaseCommand
26

37
The event class. Use this class to create new commands in your bot.
@@ -16,18 +20,18 @@ new SparkCommand(options)
1620

1721
The description of the command. Will default to
1822

19-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkCommand.ts#L42)
23+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/structures/sparkCommand.ts#L42)
2024

2125
### public name: string
2226

2327
The name of the command. Will default to the file's name without the shortcut.
2428
Example:
2529

26-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkCommand.ts#L37)
30+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/structures/sparkCommand.ts#L37)
2731

2832
### public type: CommandType
2933

3034
The type of the command.
3135
You can use the
3236

33-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkCommand.ts#L48)
37+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/structures/sparkCommand.ts#L48)

apps/docs/src/pages/docs/classes/@spark.ts/handler/SparkEvent.mdx renamed to apps/docs/src/pages/docs/classes/SparkEvent.mdx

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: SparkEvent
3+
---
4+
15
## SparkEvent implements EventOptions\<Key>
26

37
The event class. Use this class to create new events in your bot.
@@ -16,16 +20,16 @@ new SparkEvent(options)
1620

1721
The name of the event. (Such as
1822

19-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkEvent.ts#L37)
23+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/structures/sparkEvent.ts#L37)
2024

2125
### public once: boolean
2226

2327
Whether the event should run once.
2428

25-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkEvent.ts#L47)
29+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/structures/sparkEvent.ts#L47)
2630

2731
### public run: EventRunner\<Key>
2832

2933
The run function for the event.
3034

31-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/structures/sparkEvent.ts#L42)
35+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/structures/sparkEvent.ts#L42)

apps/docs/src/pages/docs/types/@spark.ts/handler/Command.mdx

Lines changed: 0 additions & 3 deletions
This file was deleted.

apps/docs/src/pages/docs/types/@spark.ts/handler/EventRunner.mdx

Lines changed: 0 additions & 3 deletions
This file was deleted.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: Command
3+
---
4+
5+
## Command
6+
7+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/types/command.ts#L107)

apps/docs/src/pages/docs/types/@spark.ts/handler/CommandPlugin.mdx renamed to apps/docs/src/pages/docs/types/CommandPlugin.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: CommandPlugin
3+
---
4+
15
## CommandPlugin
26

37
Represents a plugin that is ran upon the command being used.
@@ -9,4 +13,4 @@ Good for guards, reusability.
913
| name | string | N/A | - |
1014
| run | (options: CommandPluginOptionsDefs\[T]) => Awaitable\<Result\<void, void>> | N/A | - |
1115

12-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/plugin.ts#L87)
16+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/types/plugin.ts#L87)
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: CommandType
3+
---
4+
15
## CommandType
26

37
| Property | Type | Value | Description |
@@ -6,4 +10,4 @@
610
| Slash | 'slash' | N/A | - |
711
| Text | 'text' | N/A | - |
812

9-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/command.ts#L15)
13+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/types/command.ts#L15)

apps/docs/src/pages/docs/types/@spark.ts/handler/Controller.mdx renamed to apps/docs/src/pages/docs/types/Controller.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: Controller
3+
---
4+
15
## Controller
26

37
Represents the controller object
@@ -7,4 +11,4 @@ Represents the controller object
711
| next | (...args: unknown\[]) => Ok\<void> | N/A | Continues plugin execution, runs the next plugin. |
812
| stop | (...args: unknown\[]) => Err\<void> | N/A | Stops plugin execution, doesn't run the next plugin. |
913

10-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/plugin.ts#L19)
14+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/types/plugin.ts#L19)
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: EventOptions
3+
---
4+
15
## EventOptions
26

37
| Property | Type | Value | Description |
@@ -6,4 +10,4 @@
610
| once | boolean | N/A | Whether the event should be ran once or multiple times. |
711
| run | EventRunner\<Key> | N/A | - |
812

9-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/event.ts#L7)
13+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/types/event.ts#L7)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
title: EventRunner
3+
---
4+
5+
## EventRunner
6+
7+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/types/event.ts#L3)

apps/docs/src/pages/docs/types/@spark.ts/handler/InitPlugin.mdx renamed to apps/docs/src/pages/docs/types/InitPlugin.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: InitPlugin
3+
---
4+
15
## InitPlugin
26

37
Represents a plugin that is ran upon the command being loaded.
@@ -9,4 +13,4 @@ Good for pre-processing, or doing something with the data of the command.
913
| name | string | N/A | - |
1014
| run | (options: InitPluginOptionsDefs\[T]) => Awaitable\<Result\<void, void>> | N/A | - |
1115

12-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/plugin.ts#L97)
16+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/types/plugin.ts#L97)

apps/docs/src/pages/docs/types/@spark.ts/handler/SlashCommand.mdx renamed to apps/docs/src/pages/docs/types/SlashCommand.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: SlashCommand
3+
---
4+
15
## SlashCommand
26

37
| Property | Type | Value | Description |
@@ -10,4 +14,4 @@
1014
| run | (options: \{ args: CommandInteractionOptionResolver\<CacheType>,client: Client\<boolean>,interaction: ChatInputCommandInteraction\<CacheType> }) => unknown | N/A | - |
1115
| type | Slash | N/A | - |
1216

13-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/command.ts#L62)
17+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/types/command.ts#L62)

apps/docs/src/pages/docs/types/@spark.ts/handler/TextCommand.mdx renamed to apps/docs/src/pages/docs/types/TextCommand.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
---
2+
title: TextCommand
3+
---
4+
15
## TextCommand
26

37
A text command. Ran with a prefix, and can have aliases.
@@ -13,4 +17,4 @@ A text command. Ran with a prefix, and can have aliases.
1317
| run | (options: \{ args: Array\<string>,client: Client\<boolean>,message: Message\<boolean> }) => unknown | N/A | - |
1418
| type | Text | N/A | - |
1519

16-
- [Source](https://github.com/DuroCodes/spark/blob/d7098ec/packages/handler/src/types/command.ts#L44)
20+
- [Source](https://github.com/DuroCodes/spark/blob/43c6c21/packages/handler/src/types/command.ts#L44)

apps/docs/src/utils/docgen.mjs

Lines changed: 60 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -2,67 +2,71 @@ import { createDocumentation } from 'typedoc-nextra';
22
import glob from 'fast-glob';
33
import fs from 'fs';
44

5-
await createDocumentation({
6-
input: [`${process.cwd()}/../../packages/handler/src/index.ts`],
7-
output: `${process.cwd()}/src/pages/docs`,
8-
tsconfigPath: `${process.cwd()}/../../packages/handler/tsconfig-base.json`,
9-
markdown: true,
10-
});
11-
12-
const docFiles = await glob('src/pages/docs/**/*.mdx');
13-
14-
const paths = docFiles.map((v) => ({
15-
path: v,
16-
name: v.split('/').at(-1),
17-
folder: v.split('/').at(-4),
18-
}));
19-
20-
paths.forEach(({ path, folder, name }) => {
21-
fs.renameSync(path, `src/pages/docs/${folder}/${name}`);
22-
});
23-
24-
const folders = [...new Set(paths.map(({ folder }) => folder))];
25-
folders.forEach((folder) => {
26-
fs.rmdirSync(`src/pages/docs/${folder}/@spark.ts/handler`);
27-
fs.rmdirSync(`src/pages/docs/${folder}/@spark.ts`);
28-
});
29-
30-
const newFiles = await glob('src/pages/docs/**/*.mdx');
31-
32-
newFiles.forEach((file) => {
33-
const data = fs.readFileSync(file, 'utf-8');
34-
35-
const replacedData = data
36-
.split('\n')
37-
.map((v) => {
38-
if (v.includes('node_modules/discord.js/typings/index.d.ts')) {
39-
return '- [Source](https://github.com/discordjs/discord.js/blob/main/packages/discord.js/typings/index.d.ts)';
40-
}
41-
42-
if (v.includes('node_modules/@types/node')) {
43-
return '';
44-
}
45-
46-
return v;
47-
})
48-
.join('\n');
49-
50-
const newData = `\
5+
async function main() {
6+
const docFiles = (await glob('src/pages/docs/**/*.mdx')).filter((v) => !v.includes('index.mdx'));
7+
8+
if (!docFiles.length) {
9+
return createDocumentation({
10+
input: [`${process.cwd()}/../../packages/handler/src/index.ts`],
11+
output: `${process.cwd()}/src/pages/docs`,
12+
tsconfigPath: `${process.cwd()}/../../packages/handler/tsconfig-base.json`,
13+
markdown: true,
14+
});
15+
}
16+
17+
const paths = docFiles.map((v) => ({
18+
path: v,
19+
name: v.split('/').at(-1),
20+
folder: v.split('/').at(-4),
21+
}));
22+
23+
paths.forEach(({ path, folder, name }) => {
24+
fs.renameSync(path, `src/pages/docs/${folder}/${name}`);
25+
});
26+
27+
const folders = [...new Set(paths.map(({ folder }) => folder))];
28+
29+
folders.forEach((folder) => {
30+
fs.rmdirSync(`src/pages/docs/${folder}/@spark.ts/handler`);
31+
fs.rmdirSync(`src/pages/docs/${folder}/@spark.ts`);
32+
});
33+
34+
const newFiles = await glob('src/pages/docs/**/*.mdx');
35+
36+
newFiles.forEach((file) => {
37+
const data = fs.readFileSync(file, 'utf-8');
38+
39+
const replacedData = data
40+
.split('\n')
41+
.map((v) => {
42+
if (v.includes('node_modules/discord.js/typings/index.d.ts')) {
43+
return '- [Source](https://github.com/discordjs/discord.js/blob/main/packages/discord.js/typings/index.d.ts)';
44+
}
45+
46+
if (v.includes('node_modules/@types/node')) {
47+
return '';
48+
}
49+
50+
return v;
51+
})
52+
.join('\n');
53+
54+
const newData = `\
5155
---
5256
title: ${file.split('/').at(-1).split('.')[0]}
5357
---
5458
5559
${replacedData}`;
5660

57-
fs.writeFileSync(file, newData);
58-
});
61+
fs.writeFileSync(file, newData);
62+
});
5963

60-
fs.writeFileSync('src/pages/docs/_meta.json', JSON.stringify({
61-
classes: 'Classes',
62-
types: 'Types',
63-
}, null, 2));
64+
fs.writeFileSync('src/pages/docs/_meta.json', JSON.stringify({
65+
classes: 'Classes',
66+
types: 'Types',
67+
}, null, 2));
6468

65-
fs.writeFileSync('src/pages/docs/index.mdx', `---
69+
fs.writeFileSync('src/pages/docs/index.mdx', `---
6670
title: API Docs
6771
description: View the Spark API Docs
6872
---
@@ -78,3 +82,6 @@ In this section of the docs, you can view info on the classes and types, and vie
7882
For now, it's best to use the \`Guide\` section to learn more.
7983
</Callout>
8084
`);
85+
}
86+
87+
await main();

0 commit comments

Comments
 (0)