From c67d3bea26d691a3a23746d5289e4125f5cf6505 Mon Sep 17 00:00:00 2001 From: Sam Magura Date: Sun, 12 Sep 2021 15:46:32 -0400 Subject: [PATCH 1/2] fix basic example by adding index.ts fixes #1692 --- examples/basic/src/index.ts | 15 +++++++++++++++ examples/basic/tsconfig.json | 3 ++- 2 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 examples/basic/src/index.ts diff --git a/examples/basic/src/index.ts b/examples/basic/src/index.ts new file mode 100644 index 000000000..984455985 --- /dev/null +++ b/examples/basic/src/index.ts @@ -0,0 +1,15 @@ +export * from "./access"; +export * from "./classes"; +export * from "./default-export"; +export * from "./enumerations"; +export * from "./flattened"; +export * from "./functions"; +export * from "./generics"; +export * from "./hidden"; +export * from "./markdown"; +export * from "./mixin"; +export * from "./mod"; +export * from "./mod2"; +export * from "./modules"; +export { default as SingleExportedClass } from "./single-export"; +export * from "./weird-names"; diff --git a/examples/basic/tsconfig.json b/examples/basic/tsconfig.json index c28564409..ca47d4a1f 100644 --- a/examples/basic/tsconfig.json +++ b/examples/basic/tsconfig.json @@ -5,7 +5,8 @@ "jsx": "react", "experimentalDecorators": true, "resolveJsonModule": true, - "rootDir": "." + "rootDir": ".", + "esModuleInterop": true }, "include": ["."] } From 27425f305c5735e4a6fcf80121af56179692c3da Mon Sep 17 00:00:00 2001 From: Sam Magura Date: Sun, 12 Sep 2021 15:57:41 -0400 Subject: [PATCH 2/2] Automatically add a .nojekyll file to support GitHub Pages This behavior is controlled by the new githubPages option which defaults to true. Fixes #1680. --- src/lib/output/plugins/index.ts | 2 +- src/lib/output/renderer.ts | 23 ++++++++++++++++++++++- src/lib/utils/options/declaration.ts | 1 + src/lib/utils/options/sources/typedoc.ts | 6 ++++++ 4 files changed, 30 insertions(+), 2 deletions(-) diff --git a/src/lib/output/plugins/index.ts b/src/lib/output/plugins/index.ts index 50b003be3..18bce1ddd 100644 --- a/src/lib/output/plugins/index.ts +++ b/src/lib/output/plugins/index.ts @@ -1,5 +1,5 @@ export { AssetsPlugin } from "./AssetsPlugin"; export { JavascriptIndexPlugin } from "./JavascriptIndexPlugin"; export { MarkedLinksPlugin } from "./MarkedLinksPlugin"; -export { MarkedPlugin as MarkedPlugin } from "../themes/MarkedPlugin"; +export { MarkedPlugin } from "../themes/MarkedPlugin"; export { LegendPlugin } from "./LegendPlugin"; diff --git a/src/lib/output/renderer.ts b/src/lib/output/renderer.ts index 5f123a372..3df5cf83b 100644 --- a/src/lib/output/renderer.ts +++ b/src/lib/output/renderer.ts @@ -8,6 +8,7 @@ */ import type * as ts from "typescript"; import * as fs from "fs"; +import * as path from "path"; import type { Application } from "../application"; import type { Theme } from "./theme"; @@ -95,6 +96,10 @@ export class Renderer extends ChildableComponent< @BindOption("gaSite") gaSite!: string; + /** @internal */ + @BindOption("githubPages") + githubPages!: boolean; + /** @internal */ @BindOption("hideGenerator") hideGenerator!: boolean; @@ -301,11 +306,27 @@ export class Renderer extends ChildableComponent< fs.mkdirSync(directory, { recursive: true }); } catch (error) { this.application.logger.error( - `Could not create output directory ${directory}` + `Could not create output directory ${directory}.` ); return false; } + if (this.githubPages) { + try { + const text = + "TypeDoc added this file to prevent GitHub Pages from " + + "using Jekyll. You can turn off this behavior by setting " + + "the `githubPages` option to false."; + + fs.writeFileSync(path.join(directory, ".nojekyll"), text); + } catch (error) { + this.application.logger.warn( + "Could not create .nojekyll file." + ); + return false; + } + } + return true; } } diff --git a/src/lib/utils/options/declaration.ts b/src/lib/utils/options/declaration.ts index e1c84d173..0ed608984 100644 --- a/src/lib/utils/options/declaration.ts +++ b/src/lib/utils/options/declaration.ts @@ -86,6 +86,7 @@ export interface TypeDocOptionMap { gitRemote: string; gaID: string; gaSite: string; + githubPages: boolean; hideGenerator: boolean; hideLegend: boolean; cleanOutputDir: boolean; diff --git a/src/lib/utils/options/sources/typedoc.ts b/src/lib/utils/options/sources/typedoc.ts index 8b9f3c7a3..6c9bd135d 100644 --- a/src/lib/utils/options/sources/typedoc.ts +++ b/src/lib/utils/options/sources/typedoc.ts @@ -248,6 +248,12 @@ export function addTypeDocOptions(options: Pick) { help: "Set the site name for Google Analytics. Defaults to `auto`.", defaultValue: "auto", }); + options.addDeclaration({ + name: "githubPages", + help: "Generate a .nojekyll file to prevent 404 errors in GitHub Pages. Defaults to `true`.", + type: ParameterType.Boolean, + defaultValue: true, + }); options.addDeclaration({ name: "hideGenerator", help: "Do not print the TypeDoc link at the end of the page.",