Skip to content

Commit

Permalink
feat(website): add support for source file links (#9048)
Browse files Browse the repository at this point in the history
Co-authored-by: Noel <buechler.noel@outlook.com>
  • Loading branch information
suneettipirneni and iCrawl authored Jan 12, 2023
1 parent a580768 commit f6506e9
Show file tree
Hide file tree
Showing 32 changed files with 333 additions and 245 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pids

# Dist
dist/
dist-docs/

# Miscellaneous
.tmp/
Expand Down
2 changes: 1 addition & 1 deletion api-extractor.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
*
* SUPPORTED TOKENS: <projectFolder>, <packageName>, <unscopedPackageName>
*/
"mainEntryPointFilePath": "<projectFolder>/dist/index.d.ts",
"mainEntryPointFilePath": "<projectFolder>/dist-docs/index.d.ts",

/**
* A list of NPM package names whose exports should be treated as part of this package.
Expand Down
6 changes: 3 additions & 3 deletions apps/website/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@
"@discordjs/api-extractor-utils": "workspace:^",
"@discordjs/scripts": "workspace:^",
"@discordjs/ui": "workspace:^",
"@microsoft/api-extractor-model": "7.24.0",
"@microsoft/tsdoc": "0.14.1",
"@microsoft/api-extractor-model": "7.25.3",
"@microsoft/tsdoc": "0.14.2",
"@react-icons/all-files": "^4.1.0",
"@vercel/og": "^0.0.26",
"@vscode/codicons": "^0.0.32",
Expand All @@ -62,7 +62,7 @@
"react-dom": "^18.2.0",
"react-syntax-highlighter": "^15.5.0",
"react-use": "^17.4.0",
"rehype-ignore": "^1.0.3",
"rehype-ignore": "^1.0.4",
"rehype-pretty-code": "^0.8.1",
"rehype-raw": "^6.1.1",
"rehype-slug": "^5.1.0",
Expand Down
20 changes: 16 additions & 4 deletions apps/website/src/components/documentation/Header.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { ApiItemKind } from '@microsoft/api-extractor-model';
import { VscFileCode } from '@react-icons/all-files/vsc/VscFileCode';
import { VscSymbolClass } from '@react-icons/all-files/vsc/VscSymbolClass';
import { VscSymbolEnum } from '@react-icons/all-files/vsc/VscSymbolEnum';
import { VscSymbolInterface } from '@react-icons/all-files/vsc/VscSymbolInterface';
Expand All @@ -24,12 +25,23 @@ function generateIcon(kind: ApiItemKind) {
}
}

export function Header({ kind, name }: PropsWithChildren<{ kind: ApiItemKind; name: string }>) {
export function Header({
kind,
name,
sourceURL,
}: PropsWithChildren<{ kind: ApiItemKind; name: string; sourceURL?: string | undefined }>) {
return (
<div className="flex flex-col">
<h2 className="flex flex-row place-items-center gap-2 break-all text-2xl font-bold">
<span>{generateIcon(kind)}</span>
{name}
<h2 className="flex flex-row place-items-center justify-between gap-2 break-all text-2xl font-bold">
<span className="row flex flex place-items-center gap-2">
<span>{generateIcon(kind)}</span>
{name}
</span>
{sourceURL ? (
<a className="text-blurple" href={sourceURL}>
<VscFileCode />
</a>
) : null}
</h2>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion apps/website/src/components/documentation/ObjectHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export interface ObjectHeaderProps {
export function ObjectHeader({ item }: ObjectHeaderProps) {
return (
<>
<Header kind={item.kind} name={item.displayName} />
<Header kind={item.kind} name={item.displayName} sourceURL={item.sourceLocation.fileUrl} />
<SyntaxHighlighter code={item.excerpt.text} />
<SummarySection item={item} />
</>
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
"vitest": "^0.27.1"
},
"resolutions": {
"@microsoft/tsdoc-config": "patch:@microsoft/tsdoc-config@npm:0.16.1#.yarn/patches/@microsoft-tsdoc-config-npm-0.16.1-81031b1bbf.patch"
"@microsoft/tsdoc-config": "patch:@microsoft/tsdoc-config@npm:0.16.2#.yarn/patches/@microsoft-tsdoc-config-npm-0.16.2-81031b1bbf.patch"
},
"engines": {
"node": ">=16.9.0"
Expand Down
4 changes: 2 additions & 2 deletions packages/api-extractor-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
},
"homepage": "https://discord.js.org",
"dependencies": {
"@microsoft/api-extractor-model": "7.24.0",
"@microsoft/tsdoc": "0.14.1"
"@microsoft/api-extractor-model": "7.25.3",
"@microsoft/tsdoc": "0.14.2"
},
"devDependencies": {
"@types/node": "16.18.11",
Expand Down
5 changes: 4 additions & 1 deletion packages/brokers/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/brokers"
}
}
3 changes: 2 additions & 1 deletion packages/brokers/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"fmt": "yarn format",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn lint && yarn test && yarn build",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/brokers/*'",
"release": "cliff-jumper"
Expand Down
5 changes: 4 additions & 1 deletion packages/builders/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/builders"
}
}
4 changes: 3 additions & 1 deletion packages/builders/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\" && yarn downlevel-dts ./dist-docs ./dist-docs",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"fmt": "yarn format",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn lint && yarn test && yarn build",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/builders/*'",
"release": "cliff-jumper"
Expand Down Expand Up @@ -68,6 +69,7 @@
"@types/node": "16.18.11",
"@vitest/coverage-c8": "^0.27.1",
"cross-env": "^7.0.3",
"downlevel-dts": "^0.11.0",
"esbuild-plugin-version-injector": "^1.0.2",
"eslint": "^8.31.0",
"eslint-config-neon": "^0.1.40",
Expand Down
5 changes: 4 additions & 1 deletion packages/collection/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/collection"
}
}
6 changes: 4 additions & 2 deletions packages/collection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"fmt": "yarn format",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn lint && yarn test && yarn build",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/collection/*'",
"release": "cliff-jumper"
"release": "cliff-jumper",
"docs:declarations": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist\""
},
"main": "./dist/index.js",
"module": "./dist/index.mjs",
Expand Down
5 changes: 4 additions & 1 deletion packages/core/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/core"
}
}
3 changes: 2 additions & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"lint": "prettier --check . && cross-env TIMING=1 eslint src --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src --ext .mjs,.js,.ts --fix --format=pretty",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn build && yarn lint",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/core/*'",
"release": "cliff-jumper"
Expand Down
5 changes: 4 additions & 1 deletion packages/formatters/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/formatters"
}
}
3 changes: 2 additions & 1 deletion packages/formatters/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn build && yarn lint",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/formatters/*'",
"release": "cliff-jumper"
Expand Down
5 changes: 4 additions & 1 deletion packages/next/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/next"
}
}
3 changes: 2 additions & 1 deletion packages/next/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn build && yarn lint",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/next/*'",
"release": "cliff-jumper"
Expand Down
5 changes: 4 additions & 1 deletion packages/proxy/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/proxy"
}
}
3 changes: 2 additions & 1 deletion packages/proxy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"fmt": "yarn format",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn lint && yarn test && yarn build",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/proxy/*'",
"release": "cliff-jumper"
Expand Down
5 changes: 4 additions & 1 deletion packages/rest/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/rest"
}
}
3 changes: 2 additions & 1 deletion packages/rest/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"fmt": "yarn format",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn lint && yarn test && yarn build",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/rest/*'",
"release": "cliff-jumper"
Expand Down
6 changes: 3 additions & 3 deletions packages/scripts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,9 @@
"homepage": "https://discord.js.org",
"dependencies": {
"@discordjs/api-extractor-utils": "workspace:^",
"@microsoft/api-extractor-model": "7.24.0",
"@microsoft/tsdoc": "0.14.1",
"@microsoft/tsdoc-config": "0.16.1",
"@microsoft/api-extractor-model": "7.25.3",
"@microsoft/tsdoc": "0.14.2",
"@microsoft/tsdoc-config": "0.16.2",
"commander": "^9.5.0",
"fs-extra": "^11.1.0",
"tslib": "^2.4.1",
Expand Down
5 changes: 4 additions & 1 deletion packages/util/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/util"
}
}
3 changes: 2 additions & 1 deletion packages/util/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"description": "Utilities shared across Discord.js packages",
"scripts": {
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"test": "vitest run && tsd",
"lint": "prettier --check . && TIMING=1 eslint src --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && TIMING=1 eslint src --ext .mjs,.js,.ts --fix --format=pretty",
"fmt": "yarn format",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn lint && yarn test && yarn build",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/util/*'",
"release": "cliff-jumper"
Expand Down
5 changes: 4 additions & 1 deletion packages/voice/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/voice"
}
}
3 changes: 2 additions & 1 deletion packages/voice/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"description": "Implementation of the Discord Voice API for node.js",
"scripts": {
"build": "tsup && node scripts/postbuild.mjs",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"test": "jest --coverage",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"fmt": "yarn format",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn lint && yarn test && yarn build",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/voice/*'",
"release": "cliff-jumper"
Expand Down
5 changes: 4 additions & 1 deletion packages/ws/api-extractor.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{
"extends": "../../api-extractor.json"
"extends": "../../api-extractor.json",
"docModel": {
"projectFolderUrl": "https://github.com/discordjs/discord.js/tree/main/packages/ws"
}
}
3 changes: 2 additions & 1 deletion packages/ws/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@
"scripts": {
"test": "vitest run",
"build": "tsup",
"build:docs": "tsc --emitDeclarationOnly --declarationMap --skipLibCheck --outDir \"dist-docs\"",
"lint": "prettier --check . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --format=pretty",
"format": "prettier --write . && cross-env TIMING=1 eslint src __tests__ --ext .mjs,.js,.ts --fix --format=pretty",
"docs": "api-extractor run --local",
"docs": "yarn build:docs && api-extractor run --local",
"prepack": "yarn build && yarn lint",
"changelog": "git cliff --prepend ./CHANGELOG.md -u -c ./cliff.toml -r ../../ --include-path 'packages/ws/*'",
"release": "cliff-jumper"
Expand Down
Loading

2 comments on commit f6506e9

@vercel
Copy link

@vercel vercel bot commented on f6506e9 Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on f6506e9 Jan 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.