From d8b983df45c9f7d1dc3ae5873f3cee1dc5076394 Mon Sep 17 00:00:00 2001 From: tgreyuk Date: Wed, 10 Jul 2024 22:54:48 +0100 Subject: [PATCH] feat(core): write `.nojekyll` file if TypeDocs "githubPages" option is true (#650) --- .changeset/nice-rabbits-yell.md | 5 +++++ docs/pages/docs/typedoc-usage.mdx | 4 +++- .../src/renderer/overrides.ts | 15 +++++++++++++++ .../test/fixtures/config.ts | 3 ++- .../test/specs/__snapshots__/urls.spec.ts.snap | 2 ++ 5 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 .changeset/nice-rabbits-yell.md diff --git a/.changeset/nice-rabbits-yell.md b/.changeset/nice-rabbits-yell.md new file mode 100644 index 000000000..50d09af86 --- /dev/null +++ b/.changeset/nice-rabbits-yell.md @@ -0,0 +1,5 @@ +--- +'typedoc-plugin-markdown': patch +--- + +- Write `.nojekyll` file if TypeDocs "githubPages" option is true (#650) diff --git a/docs/pages/docs/typedoc-usage.mdx b/docs/pages/docs/typedoc-usage.mdx index 5ef0526f5..ad36fc835 100644 --- a/docs/pages/docs/typedoc-usage.mdx +++ b/docs/pages/docs/typedoc-usage.mdx @@ -29,6 +29,9 @@ Below is a list of which TypeDoc Output options are supported or not: - `--theme` Yes ✅ (theme should be MarkdownTheme instance) - `--cleanOutputDir` Yes ✅ - `--basePath` Yes ✅ +- `--lang` Yes ✅ +- `--locale` Yes ✅ +- `--githubPages` Yes ✅ (defaults to `false`) - `--hideParameterTypesInTitle` No ❌ (use ) - `--navigation` No ❌ (use ) - `--titleLink` No ❌ @@ -42,7 +45,6 @@ Below is a list of which TypeDoc Output options are supported or not: - `--cname` No ❌ - `--sourceLinkExternal` No ❌ - `--htmlLang` No ❌ -- `--githubPages` No ❌ - `--cacheBust` No ❌ - `--gaID` No ❌ - `--hideGenerator` No ❌ diff --git a/packages/typedoc-plugin-markdown/src/renderer/overrides.ts b/packages/typedoc-plugin-markdown/src/renderer/overrides.ts index ecec564bc..b9fb27b25 100644 --- a/packages/typedoc-plugin-markdown/src/renderer/overrides.ts +++ b/packages/typedoc-plugin-markdown/src/renderer/overrides.ts @@ -50,6 +50,21 @@ export async function render( return; } + if ( + this.application.options.isSet('githubPages') && + this.application.options.getValue('githubPages') === true + ) { + try { + fs.writeFileSync(path.join(outputDirectory, '.nojekyll'), ''); + } catch (error) { + this.application.logger.warn( + this.application.i18n.could_not_write_0( + path.join(outputDirectory, '.nojekyll'), + ), + ); + } + } + this.prepareTheme(); const output = new MarkdownRendererEvent( diff --git a/packages/typedoc-plugin-markdown/test/fixtures/config.ts b/packages/typedoc-plugin-markdown/test/fixtures/config.ts index 18d0766ce..f4445e606 100644 --- a/packages/typedoc-plugin-markdown/test/fixtures/config.ts +++ b/packages/typedoc-plugin-markdown/test/fixtures/config.ts @@ -219,10 +219,11 @@ const config: Record = { name: '@scope/entryfile', }, options: [ - { entryFileName: 'README.md' }, + { entryFileName: 'README.md', githubPages: true }, { readme: 'none', excludeScopesInPaths: true, + githubPages: false, }, ], }, diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/urls.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/urls.spec.ts.snap index d08f63784..cf6764387 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/urls.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/urls.spec.ts.snap @@ -249,6 +249,7 @@ exports[`Urls should gets Urls for documents single module: outputFileStrategy: exports[`Urls should gets Urls for entry module: outputFileStrategy: members 1`] = ` [ + ".nojekyll", "@scope/module-1/README.mdx", "@scope/module-1/classes/ModuleClass.mdx", "README.mdx", @@ -272,6 +273,7 @@ exports[`Urls should gets Urls for entry module: outputFileStrategy: members 2`] exports[`Urls should gets Urls for entry module: outputFileStrategy: modules 1`] = ` [ + ".nojekyll", "@scope/module-1.mdx", "README.mdx", "module-2.mdx",