fix: generateSplitDocumentation for external docs on main (#10827)

* fix: generateSplitDocumentation for external docs on main

* fix: remove console.log

* chore: apply suggestion

Co-authored-by: Almeida <github@almeidx.dev>

* fix: mixes tag

* chore: docs include collection

---------

Co-authored-by: Almeida <github@almeidx.dev>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
This commit is contained in:
Qjuh
2025-04-24 21:19:52 +02:00
committed by GitHub
parent 891fe277bf
commit 5a4de953fa
5 changed files with 29 additions and 14 deletions

View File

@@ -71,6 +71,7 @@
"@betaDocumentation": true, "@betaDocumentation": true,
"@internalRemarks": true, "@internalRemarks": true,
"@mixes": true,
"@preapproved": true "@preapproved": true
} }
} }

View File

@@ -1,3 +1,4 @@
/* eslint-disable jsdoc/valid-types */
import { ApplicationCommandType, type RESTPostAPIChatInputApplicationCommandsJSONBody } from 'discord-api-types/v10'; import { ApplicationCommandType, type RESTPostAPIChatInputApplicationCommandsJSONBody } from 'discord-api-types/v10';
import { Mixin } from 'ts-mixer'; import { Mixin } from 'ts-mixer';
import { validate } from '../../../util/validation.js'; import { validate } from '../../../util/validation.js';
@@ -10,10 +11,10 @@ import { SharedChatInputCommandSubcommands } from './mixins/SharedSubcommands.js
/** /**
* A builder that creates API-compatible JSON data for chat input commands. * A builder that creates API-compatible JSON data for chat input commands.
* *
* @mixes CommandBuilder<RESTPostAPIChatInputApplicationCommandsJSONBody> * @mixes {@link CommandBuilder}\<{@link discord-api-types/v10#(RESTPostAPIChatInputApplicationCommandsJSONBody:interface)}\>
* @mixes SharedChatInputCommandOptions * @mixes {@link SharedChatInputCommandOptions}
* @mixes SharedNameAndDescription * @mixes {@link SharedNameAndDescription}
* @mixes SharedChatInputCommandSubcommands * @mixes {@link SharedChatInputCommandSubcommands}
*/ */
export class ChatInputCommandBuilder extends Mixin( export class ChatInputCommandBuilder extends Mixin(
CommandBuilder<RESTPostAPIChatInputApplicationCommandsJSONBody>, CommandBuilder<RESTPostAPIChatInputApplicationCommandsJSONBody>,

View File

@@ -1,9 +1,4 @@
{ {
"$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json", "$schema": "https://developer.microsoft.com/json-schemas/tsdoc/v0/tsdoc.schema.json",
"tagDefinitions": [ "extends": ["@discordjs/api-extractor/extends/tsdoc-base.json"]
{
"tagName": "@mixes",
"syntaxKind": "block"
}
]
} }

View File

@@ -4,6 +4,7 @@
"bundledPackages": [ "bundledPackages": [
"discord-api-types", "discord-api-types",
"@discordjs/builders", "@discordjs/builders",
"@discordjs/collection",
"@discordjs/formatters", "@discordjs/formatters",
"@discordjs/rest", "@discordjs/rest",
"@discordjs/util", "@discordjs/util",

View File

@@ -457,13 +457,15 @@ function itemTsDoc(item: DocNode, apiItem: ApiItem) {
const comment = node as DocComment; const comment = node as DocComment;
const exampleBlocks = comment.customBlocks.filter( const exampleBlocks = comment.customBlocks.filter(
(block) => block.blockTag.tagName.toUpperCase() === StandardTags.example.tagNameWithUpperCase, (block) => block.blockTag.tagNameWithUpperCase === StandardTags.example.tagNameWithUpperCase,
); );
const defaultValueBlock = comment.customBlocks.find( const defaultValueBlock = comment.customBlocks.find(
(block) => block.blockTag.tagName.toUpperCase() === StandardTags.defaultValue.tagNameWithUpperCase, (block) => block.blockTag.tagNameWithUpperCase === StandardTags.defaultValue.tagNameWithUpperCase,
); );
const mixesBlocks = comment.customBlocks.filter((block) => block.blockTag.tagNameWithUpperCase === '@MIXES');
return { return {
kind: DocNodeKind.Comment, kind: DocNodeKind.Comment,
deprecatedBlock: comment.deprecatedBlock deprecatedBlock: comment.deprecatedBlock
@@ -497,6 +499,9 @@ function itemTsDoc(item: DocNode, apiItem: ApiItem) {
seeBlocks: comment.seeBlocks seeBlocks: comment.seeBlocks
.flatMap((block) => createNode(block.content).flat(1)) .flatMap((block) => createNode(block.content).flat(1))
.filter((val: any) => val.kind !== DocNodeKind.SoftBreak), .filter((val: any) => val.kind !== DocNodeKind.SoftBreak),
mixesBlocks: mixesBlocks
.flatMap((block) => createNode(block.content).flat(1))
.filter((val: any) => val.kind !== DocNodeKind.SoftBreak),
}; };
} }
@@ -522,8 +527,7 @@ function itemInfo(item: ApiDeclaredItem) {
const isAbstract = ApiAbstractMixin.isBaseClassOf(item) && item.isAbstract; const isAbstract = ApiAbstractMixin.isBaseClassOf(item) && item.isAbstract;
const isOptional = ApiOptionalMixin.isBaseClassOf(item) && item.isOptional; const isOptional = ApiOptionalMixin.isBaseClassOf(item) && item.isOptional;
const isDeprecated = Boolean(item.tsdocComment?.deprecatedBlock); const isDeprecated = Boolean(item.tsdocComment?.deprecatedBlock);
const isExternal = Boolean(item.sourceLocation.fileUrl?.includes('node_modules')); const isExternal = Boolean(sourceLine === undefined);
const hasSummary = Boolean(item.tsdocComment?.summarySection); const hasSummary = Boolean(item.tsdocComment?.summarySection);
return { return {
@@ -587,6 +591,19 @@ function resolveFileUrl(item: ApiDeclaredItem) {
sourceURL: href, sourceURL: href,
}; };
} }
} else if (fileUrl?.includes('/dist/') && fileUrl.includes('/main/packages/')) {
const [, pkg] = fileUrl.split('/main/packages/');
const pkgName = pkg!.split('/')[0];
const version = 'main';
// https://github.com/discordjs/discord.js/tree/main/packages/builders/dist/index.d.ts
let currentItem = item;
while (currentItem.parent && currentItem.parent.kind !== ApiItemKind.EntryPoint)
currentItem = currentItem.parent as ApiDeclaredItem;
return {
sourceURL: `/docs/packages/${pkgName}/${version}/${currentItem.displayName}:${currentItem.kind}`,
};
} }
return { return {