From ba7bc22c404d285baa451855ec415c06efcb7349 Mon Sep 17 00:00:00 2001 From: twlite <46562212+twlite@users.noreply.github.com> Date: Tue, 24 Jun 2025 18:51:16 +0545 Subject: [PATCH] docs: generate api docs --- CONTRIBUTING.md | 1 - .../classes/app-command-handler.mdx | 2 +- .../commandkit/classes/command-kit.mdx | 12 +++- .../commandkit/classes/noop-logger.mdx | 62 +++++++++++++++++++ .../functions/on-application-bootstrap.mdx | 2 +- .../commandkit/functions/on-bootstrap.mdx | 2 +- .../interfaces/command-kit-config.mdx | 6 ++ .../interfaces/command-kit-configuration.mdx | 2 +- .../interfaces/custom-app-command-props.mdx | 2 +- .../commandkit/interfaces/loaded-command.mdx | 2 +- .../prepared-app-command-execution.mdx | 2 +- .../commandkit/types/app-command.mdx | 2 +- .../commandkit/types/bootstrap-function.mdx | 2 +- .../commandkit/types/command-builder-like.mdx | 2 +- .../types/command-data-schema-key.mdx | 2 +- .../types/command-data-schema-value.mdx | 2 +- .../commandkit/types/command-data-schema.mdx | 2 +- .../commandkit/types/command-data.mdx | 1 + .../commandkit/types/command-type-data.mdx | 2 +- .../commandkit/types/resolvable-command.mdx | 2 +- .../commandkit/variables/commandkit.mdx | 2 +- .../04-commandkit-config.mdx | 1 - .../05-using-commandkit-cli.mdx | 2 - .../04-caching/01-caching-in-commandkit.mdx | 5 -- .../guide/04-caching/02-cacheTag-function.mdx | 2 - .../04-caching/03-cacheLife-function.mdx | 2 - .../04-caching/05-revalidateTag-function.mdx | 2 - .../guide/04-caching/06-cleanup-function.mdx | 2 - .../docs/guide/14-useful-utilities/index.mdx | 1 - package.json | 4 +- pnpm-lock.yaml | 2 +- 31 files changed, 97 insertions(+), 40 deletions(-) create mode 100644 apps/website/docs/api-reference/commandkit/classes/noop-logger.mdx diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index f1de93ca..524a9a1f 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -39,7 +39,6 @@ git checkout -b your-feature-or-bugfix 2. Make your changes. Please make sure to use the [Prettier](https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode) extension for consistent formatting and comments wherever necessary. 3. Ensure that your changes don't break any existing functionality. You can test the functionality of your code depending on where you've made changes: - 1. If you've made changes to the CommandKit package, you can use the "apps/test-bot" project to test your own bot. Just make sure to create a new `.env` file with the template from the `.env.example` file provided. This also requires you to build the commandkit package locally (after you make your changes) because it's symlinked with pnpm workspaces. 2. If you've made changes to the docs, you can run `pnpm dev` inside "apps/website" to spin up a local development server. diff --git a/apps/website/docs/api-reference/commandkit/classes/app-command-handler.mdx b/apps/website/docs/api-reference/commandkit/classes/app-command-handler.mdx index 1d67f03e..edcffda6 100644 --- a/apps/website/docs/api-reference/commandkit/classes/app-command-handler.mdx +++ b/apps/website/docs/api-reference/commandkit/classes/app-command-handler.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## AppCommandHandler - + Handles application commands for CommandKit, including loading, registration, and execution. Manages both slash commands and message commands with middleware support. diff --git a/apps/website/docs/api-reference/commandkit/classes/command-kit.mdx b/apps/website/docs/api-reference/commandkit/classes/command-kit.mdx index 93790fe0..0e042d4d 100644 --- a/apps/website/docs/api-reference/commandkit/classes/command-kit.mdx +++ b/apps/website/docs/api-reference/commandkit/classes/command-kit.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## CommandKit - + The commandkit class that serves as the main entry point for the CommandKit framework. @@ -22,10 +22,11 @@ class CommandKit extends EventEmitter { public eventInterceptor!: EventInterceptor; public static readonly createElement = createElement; public static readonly Fragment = Fragment; - public readonly config: CommandKitConfiguration = { + public readonly appConfig: CommandKitConfiguration = { defaultLocale: Locale.EnglishUS, getMessageCommandPrefix: () => '!', }; + public config: ResolvedCommandKitConfig = getConfig(); public readonly store = new Map(); public readonly flags = new FlagStore(); public commandsRouter!: CommandsRouter; @@ -73,11 +74,16 @@ The static createElement function to create jsx elements The static Fragment component to create jsx fragments -### config +### appConfig CommandKitConfiguration`} /> The configuration for the CommandKit instance. +### config + +ResolvedCommandKitConfig`} /> + +The configuration for the CommandKit environment. ### store diff --git a/apps/website/docs/api-reference/commandkit/classes/noop-logger.mdx b/apps/website/docs/api-reference/commandkit/classes/noop-logger.mdx new file mode 100644 index 00000000..1c90cb69 --- /dev/null +++ b/apps/website/docs/api-reference/commandkit/classes/noop-logger.mdx @@ -0,0 +1,62 @@ +--- +title: "NoopLogger" +isDefaultIndex: false +generated: true +--- + +import MemberInfo from '@site/src/components/MemberInfo'; +import GenerationInfo from '@site/src/components/GenerationInfo'; +import MemberDescription from '@site/src/components/MemberDescription'; + + + + +## NoopLogger + + + +Noop logger implementation that does nothing. + +```ts title="Signature" +class NoopLogger implements ILogger { + debug(args: any[]) => void; + error(args: any[]) => void; + log(args: any[]) => void; + info(args: any[]) => void; + warn(args: any[]) => void; +} +``` +* Implements: ILogger + + + +
+ +### debug + + void`} /> + +Logs a debug message. +### error + + void`} /> + +Logs an error message. +### log + + void`} /> + +Logs a default message. +### info + + void`} /> + +Logs an info message. +### warn + + void`} /> + +Logs a warning message. + + +
diff --git a/apps/website/docs/api-reference/commandkit/functions/on-application-bootstrap.mdx b/apps/website/docs/api-reference/commandkit/functions/on-application-bootstrap.mdx index 51308577..ba56cde8 100644 --- a/apps/website/docs/api-reference/commandkit/functions/on-application-bootstrap.mdx +++ b/apps/website/docs/api-reference/commandkit/functions/on-application-bootstrap.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## onApplicationBootstrap - + Registers a bootstrap hook that will be called when the CommandKit instance is created. This is useful for plugins that need to run some code after the CommandKit instance is fully initialized. diff --git a/apps/website/docs/api-reference/commandkit/functions/on-bootstrap.mdx b/apps/website/docs/api-reference/commandkit/functions/on-bootstrap.mdx index cdc0e9a8..231edfab 100644 --- a/apps/website/docs/api-reference/commandkit/functions/on-bootstrap.mdx +++ b/apps/website/docs/api-reference/commandkit/functions/on-bootstrap.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## onBootstrap - + Registers a bootstrap hook that will be called when the CommandKit instance is created. This is useful for plugins that need to run some code after the CommandKit instance is fully initialized. diff --git a/apps/website/docs/api-reference/commandkit/interfaces/command-kit-config.mdx b/apps/website/docs/api-reference/commandkit/interfaces/command-kit-config.mdx index fbb793a3..f151ab8f 100644 --- a/apps/website/docs/api-reference/commandkit/interfaces/command-kit-config.mdx +++ b/apps/website/docs/api-reference/commandkit/interfaces/command-kit-config.mdx @@ -54,6 +54,7 @@ interface CommandKitConfig { }; typedCommands?: boolean; disablePrefixCommands?: boolean; + showUnknownPrefixCommandsWarning?: boolean; } ``` @@ -110,6 +111,11 @@ Whether or not to enable the typed commands. Whether or not to disable the prefix commands. +### showUnknownPrefixCommandsWarning + + + +Whether or not to show a warning when a prefix command is not found. This only affects development mode. diff --git a/apps/website/docs/api-reference/commandkit/interfaces/command-kit-configuration.mdx b/apps/website/docs/api-reference/commandkit/interfaces/command-kit-configuration.mdx index 6c5c7f5d..681bc7f5 100644 --- a/apps/website/docs/api-reference/commandkit/interfaces/command-kit-configuration.mdx +++ b/apps/website/docs/api-reference/commandkit/interfaces/command-kit-configuration.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## CommandKitConfiguration - + Configurations for the CommandKit instance. diff --git a/apps/website/docs/api-reference/commandkit/interfaces/custom-app-command-props.mdx b/apps/website/docs/api-reference/commandkit/interfaces/custom-app-command-props.mdx index b482ad50..13705da7 100644 --- a/apps/website/docs/api-reference/commandkit/interfaces/custom-app-command-props.mdx +++ b/apps/website/docs/api-reference/commandkit/interfaces/custom-app-command-props.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## CustomAppCommandProps - + Custom properties that can be added to an AppCommand. This allows for additional metadata or configuration to be associated with a command. diff --git a/apps/website/docs/api-reference/commandkit/interfaces/loaded-command.mdx b/apps/website/docs/api-reference/commandkit/interfaces/loaded-command.mdx index 13d1c314..998315f2 100644 --- a/apps/website/docs/api-reference/commandkit/interfaces/loaded-command.mdx +++ b/apps/website/docs/api-reference/commandkit/interfaces/loaded-command.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## LoadedCommand - + Represents a loaded command with its metadata and configuration. diff --git a/apps/website/docs/api-reference/commandkit/interfaces/prepared-app-command-execution.mdx b/apps/website/docs/api-reference/commandkit/interfaces/prepared-app-command-execution.mdx index 9ef995db..31c33be2 100644 --- a/apps/website/docs/api-reference/commandkit/interfaces/prepared-app-command-execution.mdx +++ b/apps/website/docs/api-reference/commandkit/interfaces/prepared-app-command-execution.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## PreparedAppCommandExecution - + Represents a prepared command execution with all necessary data and middleware. diff --git a/apps/website/docs/api-reference/commandkit/types/app-command.mdx b/apps/website/docs/api-reference/commandkit/types/app-command.mdx index 7e1b4d52..6c08f161 100644 --- a/apps/website/docs/api-reference/commandkit/types/app-command.mdx +++ b/apps/website/docs/api-reference/commandkit/types/app-command.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## AppCommand - + Represents a command in the CommandKit application, including its metadata and handlers. This type extends the native command structure with additional properties. diff --git a/apps/website/docs/api-reference/commandkit/types/bootstrap-function.mdx b/apps/website/docs/api-reference/commandkit/types/bootstrap-function.mdx index 6b57edf3..91ea849e 100644 --- a/apps/website/docs/api-reference/commandkit/types/bootstrap-function.mdx +++ b/apps/website/docs/api-reference/commandkit/types/bootstrap-function.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## BootstrapFunction - + Represents the function executed during the bootstrap phase of CommandKit. diff --git a/apps/website/docs/api-reference/commandkit/types/command-builder-like.mdx b/apps/website/docs/api-reference/commandkit/types/command-builder-like.mdx index 93c373fd..30c3ed1f 100644 --- a/apps/website/docs/api-reference/commandkit/types/command-builder-like.mdx +++ b/apps/website/docs/api-reference/commandkit/types/command-builder-like.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## CommandBuilderLike - + Type representing command builder objects supported by CommandKit. diff --git a/apps/website/docs/api-reference/commandkit/types/command-data-schema-key.mdx b/apps/website/docs/api-reference/commandkit/types/command-data-schema-key.mdx index 39f66319..d5fe2e01 100644 --- a/apps/website/docs/api-reference/commandkit/types/command-data-schema-key.mdx +++ b/apps/website/docs/api-reference/commandkit/types/command-data-schema-key.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## CommandDataSchemaKey - + diff --git a/apps/website/docs/api-reference/commandkit/types/command-data-schema-value.mdx b/apps/website/docs/api-reference/commandkit/types/command-data-schema-value.mdx index d0bc09c5..196a32fc 100644 --- a/apps/website/docs/api-reference/commandkit/types/command-data-schema-value.mdx +++ b/apps/website/docs/api-reference/commandkit/types/command-data-schema-value.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## CommandDataSchemaValue - + diff --git a/apps/website/docs/api-reference/commandkit/types/command-data-schema.mdx b/apps/website/docs/api-reference/commandkit/types/command-data-schema.mdx index e14a0d40..e4284f18 100644 --- a/apps/website/docs/api-reference/commandkit/types/command-data-schema.mdx +++ b/apps/website/docs/api-reference/commandkit/types/command-data-schema.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## CommandDataSchema - + diff --git a/apps/website/docs/api-reference/commandkit/types/command-data.mdx b/apps/website/docs/api-reference/commandkit/types/command-data.mdx index 47a36f34..e6385440 100644 --- a/apps/website/docs/api-reference/commandkit/types/command-data.mdx +++ b/apps/website/docs/api-reference/commandkit/types/command-data.mdx @@ -22,6 +22,7 @@ type CommandData = Prettify< Omit & { description?: string; guilds?: string[]; + aliases?: string[]; } > ``` diff --git a/apps/website/docs/api-reference/commandkit/types/command-type-data.mdx b/apps/website/docs/api-reference/commandkit/types/command-type-data.mdx index 7e6528b3..b2a06c35 100644 --- a/apps/website/docs/api-reference/commandkit/types/command-type-data.mdx +++ b/apps/website/docs/api-reference/commandkit/types/command-type-data.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## CommandTypeData - + Type representing command data identifier. diff --git a/apps/website/docs/api-reference/commandkit/types/resolvable-command.mdx b/apps/website/docs/api-reference/commandkit/types/resolvable-command.mdx index f7c894eb..be379f6b 100644 --- a/apps/website/docs/api-reference/commandkit/types/resolvable-command.mdx +++ b/apps/website/docs/api-reference/commandkit/types/resolvable-command.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## ResolvableCommand - + Type for commands that can be resolved by the handler. diff --git a/apps/website/docs/api-reference/commandkit/variables/commandkit.mdx b/apps/website/docs/api-reference/commandkit/variables/commandkit.mdx index b4d6345f..008c5e95 100644 --- a/apps/website/docs/api-reference/commandkit/variables/commandkit.mdx +++ b/apps/website/docs/api-reference/commandkit/variables/commandkit.mdx @@ -13,7 +13,7 @@ import MemberDescription from '@site/src/components/MemberDescription'; ## commandkit - + The singleton instance of CommandKit. diff --git a/apps/website/docs/guide/01-getting-started/04-commandkit-config.mdx b/apps/website/docs/guide/01-getting-started/04-commandkit-config.mdx index bc6d4fbb..62b58f3a 100644 --- a/apps/website/docs/guide/01-getting-started/04-commandkit-config.mdx +++ b/apps/website/docs/guide/01-getting-started/04-commandkit-config.mdx @@ -109,7 +109,6 @@ export default defineConfig({ 1. **Type Safety**: Always use `commandkit.config.ts` for better type checking and IDE support. 2. **Security**: Always store sensitive information in `.env` file and make sure it is not committed to your version control system. 3. **Plugin Management**: - - Only include necessary plugins to keep build times fast - Plugins have full access to your discord bot. So always be careful when installing the plugins. diff --git a/apps/website/docs/guide/01-getting-started/05-using-commandkit-cli.mdx b/apps/website/docs/guide/01-getting-started/05-using-commandkit-cli.mdx index da72defd..8849212f 100644 --- a/apps/website/docs/guide/01-getting-started/05-using-commandkit-cli.mdx +++ b/apps/website/docs/guide/01-getting-started/05-using-commandkit-cli.mdx @@ -93,13 +93,11 @@ npx commandkit create event ready ## Best Practices 1. **Development Workflow**: - - Use `commandkit dev` during development for instant feedback - Enable debug mode when troubleshooting issues - Keep your `.env` file updated with all required variables 2. **Production Deployment**: - - Always run `commandkit build` before deploying - Test the production build locally before deployment - Use environment variables for sensitive data diff --git a/apps/website/docs/guide/04-caching/01-caching-in-commandkit.mdx b/apps/website/docs/guide/04-caching/01-caching-in-commandkit.mdx index 7ba787bb..ee727bdc 100644 --- a/apps/website/docs/guide/04-caching/01-caching-in-commandkit.mdx +++ b/apps/website/docs/guide/04-caching/01-caching-in-commandkit.mdx @@ -72,13 +72,11 @@ When you call this function multiple times with the same `userId`, it will only CommandKit's caching system works by: 1. **Generating a Cache Key**: Each cached function call generates a unique key based on: - - The function's identity - The arguments passed to the function - A build ID for stability 2. **Storing Results**: When a function is called: - - If the result isn't cached, the function executes and stores its result - If the result is cached, it's returned immediately without executing the function @@ -107,19 +105,16 @@ async function fetchUserData(userId: string) { ## Best Practices 1. **Choose What to Cache**: - - Cache expensive operations (API calls, database queries) - Cache data that doesn't change frequently - Don't cache sensitive or frequently changing data 2. **Set Appropriate TTL**: - - Use shorter TTL for frequently changing data - Use longer TTL for static data - Consider your data's update frequency 3. **Use Tags for Revalidation**: - - Add meaningful tags to your cache entries - Group related cache entries with the same tag - Use tags for targeted cache invalidation diff --git a/apps/website/docs/guide/04-caching/02-cacheTag-function.mdx b/apps/website/docs/guide/04-caching/02-cacheTag-function.mdx index 40b24836..190c2bc7 100644 --- a/apps/website/docs/guide/04-caching/02-cacheTag-function.mdx +++ b/apps/website/docs/guide/04-caching/02-cacheTag-function.mdx @@ -79,13 +79,11 @@ await revalidateTag('user:123'); ## Best Practices 1. **Use Consistent Naming**: - - Follow a consistent pattern (e.g., `type:id`) - Make tags descriptive and meaningful - Use hierarchical tags when appropriate 2. **Group Related Data**: - - Tag related cache entries with the same tag - Use multiple tags for cross-category entries - Consider data relationships when tagging diff --git a/apps/website/docs/guide/04-caching/03-cacheLife-function.mdx b/apps/website/docs/guide/04-caching/03-cacheLife-function.mdx index ff5cabc5..b3088481 100644 --- a/apps/website/docs/guide/04-caching/03-cacheLife-function.mdx +++ b/apps/website/docs/guide/04-caching/03-cacheLife-function.mdx @@ -99,13 +99,11 @@ async function fetchData(type: 'frequent' | 'rare') { ## Best Practices 1. **Choose Appropriate Duration**: - - Use shorter TTL for frequently changing data - Use longer TTL for static content - Consider your data update patterns 2. **Balance Freshness and Performance**: - - Don't cache too long if data changes often - Don't cache too short if data is static - Consider your application's needs diff --git a/apps/website/docs/guide/04-caching/05-revalidateTag-function.mdx b/apps/website/docs/guide/04-caching/05-revalidateTag-function.mdx index e36039ed..1f6cd6b4 100644 --- a/apps/website/docs/guide/04-caching/05-revalidateTag-function.mdx +++ b/apps/website/docs/guide/04-caching/05-revalidateTag-function.mdx @@ -66,13 +66,11 @@ setInterval( ## Best Practices 1. **Strategic Invalidation**: - - Invalidate only what needs to be refreshed - Use specific tags for targeted invalidation - Consider the impact on performance 2. **Timing**: - - Invalidate after data changes - Consider using scheduled revalidation - Balance freshness and performance diff --git a/apps/website/docs/guide/04-caching/06-cleanup-function.mdx b/apps/website/docs/guide/04-caching/06-cleanup-function.mdx index 81155258..5cf46b14 100644 --- a/apps/website/docs/guide/04-caching/06-cleanup-function.mdx +++ b/apps/website/docs/guide/04-caching/06-cleanup-function.mdx @@ -66,13 +66,11 @@ async function performConservativeCleanup() { ## Best Practices 1. **Choose Appropriate Time Period**: - - Consider your application's memory constraints - Balance between memory usage and cache effectiveness - Monitor cache hit rates 2. **Schedule Regular Cleanup**: - - Set up automated cleanup tasks - Choose appropriate intervals - Handle cleanup errors gracefully diff --git a/apps/website/docs/guide/14-useful-utilities/index.mdx b/apps/website/docs/guide/14-useful-utilities/index.mdx index 2bd7bc6f..bd6d78fa 100644 --- a/apps/website/docs/guide/14-useful-utilities/index.mdx +++ b/apps/website/docs/guide/14-useful-utilities/index.mdx @@ -156,7 +156,6 @@ try { ## Best Practices 1. **Choose the right tool**: Think about what you're trying to achieve: - - Need to limit how often something happens? Use a rate limiter - Need to ensure only one thing accesses a resource? Use a mutex - Need to limit how many things happen at once? Use a semaphore diff --git a/package.json b/package.json index 6cbbc041..c881a3ef 100644 --- a/package.json +++ b/package.json @@ -14,11 +14,11 @@ "publish-package": "pnpm publish-package", "build-docs": "pnpm run --filter=\"./apps/website\" build", "docgen": "tsx ./scripts/docs/generate-typescript-docs.ts && pnpm format", - "format": "prettier --write ./ --ignore-path=.prettierignore" + "format": "prettier --experimental-cli --write ./ --ignore-path=.prettierignore" }, "devDependencies": { "@types/node": "^22.10.2", - "prettier": "^3.0.3", + "prettier": "^3.6.0", "tsx": "^4.7.0", "turbo": "^2.5.3" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index e4e5429f..a822837b 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -49,7 +49,7 @@ importers: specifier: ^22.10.2 version: 22.15.32 prettier: - specifier: ^3.0.3 + specifier: ^3.6.0 version: 3.6.0 tsx: specifier: ^4.7.0