Skip to content

Commit

Permalink
docs(website): Fix typedoc source links when deployed through vercel
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mlaursen committed May 18, 2021
1 parent a7d7429 commit a4eed1b
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 5 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"styles": "dev-utils styles",
"variables": "dev-utils variables",
"run-indexer": "dev-utils doc-index",
"generate-typedoc": "typedoc",
"prebuild-docs": "npm-run-all sandbox sassdoc run-indexer generate-typedoc",
"generate-typedoc": "dev-utils typedoc",
"build-docs-meta": "npm-run-all sandbox sassdoc run-indexer generate-typedoc",
"build-docs": "yarn workspace documentation build",
"build-website": "npm-run-all prebuild-docs build-docs",
"build-website": "npm-run-all build-docs-meta build-docs",
"build-dev-utils": "yarn workspace @react-md/dev-utils build",
"build-ejs": "tsc -b tsconfig.ejs.json",
"build-cjs": "tsc -b tsconfig.cjs.json",
Expand Down
1 change: 1 addition & 0 deletions packages/dev-utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
"sassdoc": "^2.7.2",
"ts-morph": "^10.0.2",
"typedoc": "^0.20.36",
"typedoc-plugin-sourcefile-url": "^1.0.6",
"typescript": "^4.2.4"
},
"devDependencies": {
Expand Down
7 changes: 7 additions & 0 deletions packages/dev-utils/src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { sandbox } from "./sandbox";
import { sassdoc } from "./sassdoc";
import { shared } from "./shared";
import { themes } from "./themes";
import { typedoc } from "./typedoc";
import { umd } from "./umd";
import { copyStyles } from "./utils";
import { variables } from "./variables";
Expand Down Expand Up @@ -201,4 +202,10 @@ createCommand("watch")
)
.action(({ cjs = false }) => watch(cjs));

createCommand("typedoc")
.description(
"A wrapper for the typedoc cli that is really used to just work with vercel deployments"
)
.action(() => typedoc());

commander.parse(process.argv);
13 changes: 13 additions & 0 deletions packages/dev-utils/src/typedoc.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { execSync } from "child_process";
import log from "loglevel";

export function typedoc(): void {
const commitSha = process.env.VERCEL_GIT_COMMIT_SHA;
let command = "typedoc";
if (commitSha) {
command = `${command} --sourcefile-url-prefix "https://github.com/mlaursen/react-md/blob/${commitSha}/"`;
}

log.info(command);
execSync(command, { stdio: "inherit" });
}
3 changes: 1 addition & 2 deletions packages/documentation/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,8 @@
"description": "The documentation site for react-md",
"private": true,
"scripts": {
"prebuild": "npm-run-all run-indexer update-env",
"prebuild": "node updateProdEnv.js",
"run-indexer": "dev-utils doc-index",
"update-env": "node updateProdEnv.js",
"dev": "cross-env NEXT_TELEMETRY_DISABLED=1 next dev",
"build": "cross-env NEXT_TELEMETRY_DISABLED=1 next build",
"start": "cross-env NEXT_TELEMETRY_DISABLED=1 NODE_ENV=production next start",
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14420,6 +14420,11 @@ typedoc-default-themes@^0.12.10:
resolved "https://registry.yarnpkg.com/typedoc-default-themes/-/typedoc-default-themes-0.12.10.tgz#614c4222fe642657f37693ea62cad4dafeddf843"
integrity sha512-fIS001cAYHkyQPidWXmHuhs8usjP5XVJjWB8oZGqkTowZaz3v7g3KDZeeqE82FBrmkAnIBOY3jgy7lnPnqATbA==

typedoc-plugin-sourcefile-url@^1.0.6:
version "1.0.6"
resolved "https://registry.yarnpkg.com/typedoc-plugin-sourcefile-url/-/typedoc-plugin-sourcefile-url-1.0.6.tgz#e0199806616fe6370b3cb7889f647df698438b96"
integrity sha512-xHq9DzkoQywS7FyPneMm2/Hr9GRoCpjSQXkVN0W6SCJKP7fguqg2tasgh+8l5/mW6YSYvqCqEbkSYLbuD4Y6gA==

typedoc@^0.20.36:
version "0.20.36"
resolved "https://registry.yarnpkg.com/typedoc/-/typedoc-0.20.36.tgz#ee5523c32f566ad8283fc732aa8ea322d1a45f6a"
Expand Down

0 comments on commit a4eed1b

Please sign in to comment.