Skip to content

Commit a4eed1b

Browse files
committed
docs(website): Fix typedoc source links when deployed through vercel
This also fixes the issue where prebuild-docs is called twice since it looks like the `pre` hook is enabled for this even if it isn't a "native" npm script.
1 parent a7d7429 commit a4eed1b

File tree

6 files changed

+30
-5
lines changed

6 files changed

+30
-5
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@
1717
"styles": "dev-utils styles",
1818
"variables": "dev-utils variables",
1919
"run-indexer": "dev-utils doc-index",
20-
"generate-typedoc": "typedoc",
21-
"prebuild-docs": "npm-run-all sandbox sassdoc run-indexer generate-typedoc",
20+
"generate-typedoc": "dev-utils typedoc",
21+
"build-docs-meta": "npm-run-all sandbox sassdoc run-indexer generate-typedoc",
2222
"build-docs": "yarn workspace documentation build",
23-
"build-website": "npm-run-all prebuild-docs build-docs",
23+
"build-website": "npm-run-all build-docs-meta build-docs",
2424
"build-dev-utils": "yarn workspace @react-md/dev-utils build",
2525
"build-ejs": "tsc -b tsconfig.ejs.json",
2626
"build-cjs": "tsc -b tsconfig.cjs.json",

packages/dev-utils/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@
4242
"sassdoc": "^2.7.2",
4343
"ts-morph": "^10.0.2",
4444
"typedoc": "^0.20.36",
45+
"typedoc-plugin-sourcefile-url": "^1.0.6",
4546
"typescript": "^4.2.4"
4647
},
4748
"devDependencies": {

packages/dev-utils/src/cli.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import { sandbox } from "./sandbox";
1313
import { sassdoc } from "./sassdoc";
1414
import { shared } from "./shared";
1515
import { themes } from "./themes";
16+
import { typedoc } from "./typedoc";
1617
import { umd } from "./umd";
1718
import { copyStyles } from "./utils";
1819
import { variables } from "./variables";
@@ -201,4 +202,10 @@ createCommand("watch")
201202
)
202203
.action(({ cjs = false }) => watch(cjs));
203204

205+
createCommand("typedoc")
206+
.description(
207+
"A wrapper for the typedoc cli that is really used to just work with vercel deployments"
208+
)
209+
.action(() => typedoc());
210+
204211
commander.parse(process.argv);

packages/dev-utils/src/typedoc.ts

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import { execSync } from "child_process";
2+
import log from "loglevel";
3+
4+
export function typedoc(): void {
5+
const commitSha = process.env.VERCEL_GIT_COMMIT_SHA;
6+
let command = "typedoc";
7+
if (commitSha) {
8+
command = `${command} --sourcefile-url-prefix "https://github.com/mlaursen/react-md/blob/${commitSha}/"`;
9+
}
10+
11+
log.info(command);
12+
execSync(command, { stdio: "inherit" });
13+
}

packages/documentation/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
"description": "The documentation site for react-md",
55
"private": true,
66
"scripts": {
7-
"prebuild": "npm-run-all run-indexer update-env",
7+
"prebuild": "node updateProdEnv.js",
88
"run-indexer": "dev-utils doc-index",
9-
"update-env": "node updateProdEnv.js",
109
"dev": "cross-env NEXT_TELEMETRY_DISABLED=1 next dev",
1110
"build": "cross-env NEXT_TELEMETRY_DISABLED=1 next build",
1211
"start": "cross-env NEXT_TELEMETRY_DISABLED=1 NODE_ENV=production next start",

yarn.lock

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14420,6 +14420,11 @@ typedoc-default-themes@^0.12.10:
1442014420
resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.12.10.tgz#614c4222fe642657f37693ea62cad4dafeddf843"
1442114421
integrity sha512-fIS001cAYHkyQPidWXmHuhs8usjP5XVJjWB8oZGqkTowZaz3v7g3KDZeeqE82FBrmkAnIBOY3jgy7lnPnqATbA==
1442214422

14423+
typedoc-plugin-sourcefile-url@^1.0.6:
14424+
version "1.0.6"
14425+
resolved "https://registry.yarnpkg.com/typedoc-plugin-sourcefile-url/-/typedoc-plugin-sourcefile-url-1.0.6.tgz#e0199806616fe6370b3cb7889f647df698438b96"
14426+
integrity sha512-xHq9DzkoQywS7FyPneMm2/Hr9GRoCpjSQXkVN0W6SCJKP7fguqg2tasgh+8l5/mW6YSYvqCqEbkSYLbuD4Y6gA==
14427+
1442314428
typedoc@^0.20.36:
1442414429
version "0.20.36"
1442514430
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.20.36.tgz#ee5523c32f566ad8283fc732aa8ea322d1a45f6a"

0 commit comments

Comments
 (0)