Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "bd-source"]
path = bd-source
url = https://github.com/BetterDiscord/BetterDiscord.git
55 changes: 41 additions & 14 deletions .vitepress/config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import {DefaultTheme, defineConfig, UserConfig} from "vitepress";
import {withSidebar, generateSidebar} from "vitepress-sidebar";
import {generateSidebar} from "vitepress-sidebar";
import {bundledLanguages, LanguageRegistration} from "shiki";
import {groupIconMdPlugin, groupIconVitePlugin, localIconLoader} from "vitepress-plugin-group-icons";
import {readFileSync} from "node:fs";


const bdIcon = localIconLoader(import.meta.url, "../docs/public/branding/logo_small.svg");
Expand Down Expand Up @@ -232,17 +233,6 @@ const SIDEBARS: Parameters<typeof generateSidebar>[0] = [
frontmatterOrderDefaultValue: 1,
manualSortFileNameByPriority: ["getting-started", "guides"],
},
// {
// documentRootPath: "docs",
// scanStartPath: "developers",
// basePath: "/developers/",
// resolvePath: "/developers/",
// useTitleFromFileHeading: true,
// includeRootIndexFile: true,
// sortFolderTo: "bottom",
// sortMenusByFrontmatterOrder: true,
// frontmatterOrderDefaultValue: 1,
// },
{
documentRootPath: "docs",
scanStartPath: "plugins",
Expand Down Expand Up @@ -280,5 +270,42 @@ const SIDEBARS: Parameters<typeof generateSidebar>[0] = [
},
];

const userConfig: Partial<UserConfig> = withSidebar(VITEPRESS_CONFIG, SIDEBARS);
export default defineConfig(userConfig);
// Read the BdApi file to get items that should be in the sidebar
const bdConfig = readFileSync("./docs/api/BdApi.md", "utf-8");
const propertyRegex = /\n> `static` \*\*(.+)\*\*.+\((.+)\.md\)/g;

const properties: Record<string, string> = {};
for(const match of bdConfig.matchAll(propertyRegex)) {
const [, name, path] = match;

if(properties[path]) properties[path] += `/${name}`;
else properties[path] = name;
}

const propertyItems = Object.entries(properties).map(([path, name]) => ({
text: name,
link: path
}));

VITEPRESS_CONFIG.themeConfig ??= {};
VITEPRESS_CONFIG.themeConfig.sidebar = {
...generateSidebar(SIDEBARS),
"/api/": {
base: "/api/",
items: [
{
text: "Overview",
link: "index.md"
},
{
text: "API Reference",
items: [
{ text: "BdApi", link: "BdApi" },
...propertyItems
]
}
]
}
}

export default defineConfig(VITEPRESS_CONFIG);
1 change: 1 addition & 0 deletions bd-source
Submodule bd-source added at 00f204
183 changes: 84 additions & 99 deletions bun.lock

Large diffs are not rendered by default.

133 changes: 133 additions & 0 deletions docs/api/Addon.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
# Interface: Addon

## Properties

### added

> **added**: `number`

***

### author

> **author**: `string`

***

### authorId?

> `optional` **authorId?**: `string`

***

### authorLink?

> `optional` **authorLink?**: `string`

***

### description

> **description**: `string`

***

### donate?

> `optional` **donate?**: `string`

***

### fileContent?

> `optional` **fileContent?**: `string`

***

### filename

> **filename**: `string`

***

### format

> **format**: `string`

***

### icon?

> `optional` **icon?**: `string`

***

### id

> **id**: `string`

***

### invite?

> `optional` **invite?**: `string`

***

### modified

> **modified**: `number`

***

### name

> **name**: `string`

***

### partial?

> `optional` **partial?**: `boolean`

***

### patreon?

> `optional` **patreon?**: `string`

***

### runAt?

> `optional` **runAt?**: `string`

***

### size

> **size**: `number`

***

### slug

> **slug**: `string`

***

### source?

> `optional` **source?**: `string`

***

### version

> **version**: `string`

***

### website?

> `optional` **website?**: `string`
141 changes: 141 additions & 0 deletions docs/api/AddonAPI.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
# Class: AddonAPI

`AddonAPI` is a utility class for working with plugins and themes. Instances are available on [BdApi](BdApi.md).

## Accessors

### folder

#### Get Signature

> **get** **folder**(): `string`

The path to the addon folder.

##### Returns

`string`

## Methods

### disable()

> **disable**(`idOrFile`): `boolean` \| `undefined`

Disables the given addon.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `idOrFile` | `string` | Addon ID or filename |

#### Returns

`boolean` \| `undefined`

***

### enable()

> **enable**(`idOrFile`): `boolean` \| `undefined`

Enables the given addon.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `idOrFile` | `string` | Addon ID or filename |

#### Returns

`boolean` \| `undefined`

***

### get()

> **get**(`idOrFile`): [`Addon`](Addon.md) \| `undefined`

Gets a particular addon.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `idOrFile` | `string` | Addon ID or filename |

#### Returns

[`Addon`](Addon.md) \| `undefined`

Addon instance

***

### getAll()

> **getAll**(): ([`Addon`](Addon.md) \| `undefined`)[]

Gets all addons of this type.

#### Returns

([`Addon`](Addon.md) \| `undefined`)[]

Array of all addon instances

***

### isEnabled()

> **isEnabled**(`idOrFile`): `boolean`

Determines if a particular addon is enabled.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `idOrFile` | `string` | Addon ID or filename |

#### Returns

`boolean`

***

### reload()

> **reload**(`idOrFile`): `boolean`

Reloads a particular addon if it is enabled.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `idOrFile` | `string` | Addon ID or filename |

#### Returns

`boolean`

***

### toggle()

> **toggle**(`idOrFile`): `void`

Toggles if a particular addon is enabled.

#### Parameters

| Parameter | Type | Description |
| ------ | ------ | ------ |
| `idOrFile` | `string` | Addon ID or filename |

#### Returns

`void`
Loading