Skip to content

Commit 444c442

Browse files
authored
Merge pull request #53 from TheLazySquid/typedoc
Update api reference to use typedoc
2 parents f16bacf + 6e8cd0c commit 444c442

286 files changed

Lines changed: 13739 additions & 28572 deletions

File tree

Some content is hidden

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

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "bd-source"]
2+
path = bd-source
3+
url = https://github.com/BetterDiscord/BetterDiscord.git

.vitepress/config.ts

Lines changed: 41 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import {DefaultTheme, defineConfig, UserConfig} from "vitepress";
2-
import {withSidebar, generateSidebar} from "vitepress-sidebar";
2+
import {generateSidebar} from "vitepress-sidebar";
33
import {bundledLanguages, LanguageRegistration} from "shiki";
44
import {groupIconMdPlugin, groupIconVitePlugin, localIconLoader} from "vitepress-plugin-group-icons";
5+
import {readFileSync} from "node:fs";
56

67

78
const bdIcon = localIconLoader(import.meta.url, "../docs/public/branding/logo_small.svg");
@@ -232,17 +233,6 @@ const SIDEBARS: Parameters<typeof generateSidebar>[0] = [
232233
frontmatterOrderDefaultValue: 1,
233234
manualSortFileNameByPriority: ["getting-started", "guides"],
234235
},
235-
// {
236-
// documentRootPath: "docs",
237-
// scanStartPath: "developers",
238-
// basePath: "/developers/",
239-
// resolvePath: "/developers/",
240-
// useTitleFromFileHeading: true,
241-
// includeRootIndexFile: true,
242-
// sortFolderTo: "bottom",
243-
// sortMenusByFrontmatterOrder: true,
244-
// frontmatterOrderDefaultValue: 1,
245-
// },
246236
{
247237
documentRootPath: "docs",
248238
scanStartPath: "plugins",
@@ -280,5 +270,42 @@ const SIDEBARS: Parameters<typeof generateSidebar>[0] = [
280270
},
281271
];
282272

283-
const userConfig: Partial<UserConfig> = withSidebar(VITEPRESS_CONFIG, SIDEBARS);
284-
export default defineConfig(userConfig);
273+
// Read the BdApi file to get items that should be in the sidebar
274+
const bdConfig = readFileSync("./docs/api/BdApi.md", "utf-8");
275+
const propertyRegex = /\n> `static` \*\*(.+)\*\*.+\((.+)\.md\)/g;
276+
277+
const properties: Record<string, string> = {};
278+
for(const match of bdConfig.matchAll(propertyRegex)) {
279+
const [, name, path] = match;
280+
281+
if(properties[path]) properties[path] += `/${name}`;
282+
else properties[path] = name;
283+
}
284+
285+
const propertyItems = Object.entries(properties).map(([path, name]) => ({
286+
text: name,
287+
link: path
288+
}));
289+
290+
VITEPRESS_CONFIG.themeConfig ??= {};
291+
VITEPRESS_CONFIG.themeConfig.sidebar = {
292+
...generateSidebar(SIDEBARS),
293+
"/api/": {
294+
base: "/api/",
295+
items: [
296+
{
297+
text: "Overview",
298+
link: "index.md"
299+
},
300+
{
301+
text: "API Reference",
302+
items: [
303+
{ text: "BdApi", link: "BdApi" },
304+
...propertyItems
305+
]
306+
}
307+
]
308+
}
309+
}
310+
311+
export default defineConfig(VITEPRESS_CONFIG);

bd-source

Submodule bd-source added at c7ef1c5

bun.lock

Lines changed: 84 additions & 99 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/api/Addon.md

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
# Interface: Addon
2+
3+
## Properties
4+
5+
### added
6+
7+
> **added**: `number`
8+
9+
***
10+
11+
### author
12+
13+
> **author**: `string`
14+
15+
***
16+
17+
### authorId?
18+
19+
> `optional` **authorId?**: `string`
20+
21+
***
22+
23+
### authorLink?
24+
25+
> `optional` **authorLink?**: `string`
26+
27+
***
28+
29+
### description
30+
31+
> **description**: `string`
32+
33+
***
34+
35+
### donate?
36+
37+
> `optional` **donate?**: `string`
38+
39+
***
40+
41+
### fileContent?
42+
43+
> `optional` **fileContent?**: `string`
44+
45+
***
46+
47+
### filename
48+
49+
> **filename**: `string`
50+
51+
***
52+
53+
### format
54+
55+
> **format**: `string`
56+
57+
***
58+
59+
### icon?
60+
61+
> `optional` **icon?**: `string`
62+
63+
***
64+
65+
### id
66+
67+
> **id**: `string`
68+
69+
***
70+
71+
### invite?
72+
73+
> `optional` **invite?**: `string`
74+
75+
***
76+
77+
### modified
78+
79+
> **modified**: `number`
80+
81+
***
82+
83+
### name
84+
85+
> **name**: `string`
86+
87+
***
88+
89+
### partial?
90+
91+
> `optional` **partial?**: `boolean`
92+
93+
***
94+
95+
### patreon?
96+
97+
> `optional` **patreon?**: `string`
98+
99+
***
100+
101+
### runAt?
102+
103+
> `optional` **runAt?**: `string`
104+
105+
***
106+
107+
### size
108+
109+
> **size**: `number`
110+
111+
***
112+
113+
### slug
114+
115+
> **slug**: `string`
116+
117+
***
118+
119+
### source?
120+
121+
> `optional` **source?**: `string`
122+
123+
***
124+
125+
### version
126+
127+
> **version**: `string`
128+
129+
***
130+
131+
### website?
132+
133+
> `optional` **website?**: `string`

docs/api/AddonAPI.md

Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# Class: AddonAPI
2+
3+
`AddonAPI` is a utility class for working with plugins and themes. Instances are available on [BdApi](BdApi.md).
4+
5+
## Accessors
6+
7+
### folder
8+
9+
#### Get Signature
10+
11+
> **get** **folder**(): `string`
12+
13+
The path to the addon folder.
14+
15+
##### Returns
16+
17+
`string`
18+
19+
## Methods
20+
21+
### disable()
22+
23+
> **disable**(`idOrFile`): `boolean` \| `undefined`
24+
25+
Disables the given addon.
26+
27+
#### Parameters
28+
29+
| Parameter | Type | Description |
30+
| ------ | ------ | ------ |
31+
| `idOrFile` | `string` | Addon ID or filename |
32+
33+
#### Returns
34+
35+
`boolean` \| `undefined`
36+
37+
***
38+
39+
### enable()
40+
41+
> **enable**(`idOrFile`): `boolean` \| `undefined`
42+
43+
Enables the given addon.
44+
45+
#### Parameters
46+
47+
| Parameter | Type | Description |
48+
| ------ | ------ | ------ |
49+
| `idOrFile` | `string` | Addon ID or filename |
50+
51+
#### Returns
52+
53+
`boolean` \| `undefined`
54+
55+
***
56+
57+
### get()
58+
59+
> **get**(`idOrFile`): [`Addon`](Addon.md) \| `undefined`
60+
61+
Gets a particular addon.
62+
63+
#### Parameters
64+
65+
| Parameter | Type | Description |
66+
| ------ | ------ | ------ |
67+
| `idOrFile` | `string` | Addon ID or filename |
68+
69+
#### Returns
70+
71+
[`Addon`](Addon.md) \| `undefined`
72+
73+
Addon instance
74+
75+
***
76+
77+
### getAll()
78+
79+
> **getAll**(): ([`Addon`](Addon.md) \| `undefined`)[]
80+
81+
Gets all addons of this type.
82+
83+
#### Returns
84+
85+
([`Addon`](Addon.md) \| `undefined`)[]
86+
87+
Array of all addon instances
88+
89+
***
90+
91+
### isEnabled()
92+
93+
> **isEnabled**(`idOrFile`): `boolean`
94+
95+
Determines if a particular addon is enabled.
96+
97+
#### Parameters
98+
99+
| Parameter | Type | Description |
100+
| ------ | ------ | ------ |
101+
| `idOrFile` | `string` | Addon ID or filename |
102+
103+
#### Returns
104+
105+
`boolean`
106+
107+
***
108+
109+
### reload()
110+
111+
> **reload**(`idOrFile`): `boolean`
112+
113+
Reloads a particular addon if it is enabled.
114+
115+
#### Parameters
116+
117+
| Parameter | Type | Description |
118+
| ------ | ------ | ------ |
119+
| `idOrFile` | `string` | Addon ID or filename |
120+
121+
#### Returns
122+
123+
`boolean`
124+
125+
***
126+
127+
### toggle()
128+
129+
> **toggle**(`idOrFile`): `void`
130+
131+
Toggles if a particular addon is enabled.
132+
133+
#### Parameters
134+
135+
| Parameter | Type | Description |
136+
| ------ | ------ | ------ |
137+
| `idOrFile` | `string` | Addon ID or filename |
138+
139+
#### Returns
140+
141+
`void`

0 commit comments

Comments
 (0)