diff --git a/.changeset/slow-worms-provide.md b/.changeset/slow-worms-provide.md new file mode 100644 index 00000000..8237d19b --- /dev/null +++ b/.changeset/slow-worms-provide.md @@ -0,0 +1,5 @@ +--- +"typedoc-plugin-markdown": patch +--- + +- remove header readme labell diff --git a/docs/pages/docs/options.mdx b/docs/pages/docs/options.mdx index e8bb49a0..398aa243 100644 --- a/docs/pages/docs/options.mdx +++ b/docs/pages/docs/options.mdx @@ -513,7 +513,6 @@ Only keys that require translation need to be added to the object. { "textContentMappings": { "header.title": "{projectName} {version}", - "header.readme": "Readme", "header.docs": "Docs", "breadcrumbs.home": "{projectName} {version}", "title.indexPage": "{projectName} {version}", diff --git a/packages/typedoc-plugin-markdown/src/options/option-types.ts b/packages/typedoc-plugin-markdown/src/options/option-types.ts index 04d1cb4c..49e654f5 100644 --- a/packages/typedoc-plugin-markdown/src/options/option-types.ts +++ b/packages/typedoc-plugin-markdown/src/options/option-types.ts @@ -205,7 +205,6 @@ export interface PluginOptions { */ export interface TextContentMappings { 'header.title': string; - 'header.readme': string; 'header.docs': string; 'breadcrumbs.home': string; 'title.indexPage': string; diff --git a/packages/typedoc-plugin-markdown/src/options/text-mappings/text-mapping-defaults.ts b/packages/typedoc-plugin-markdown/src/options/text-mappings/text-mapping-defaults.ts index 8620e035..4d4b0c79 100644 --- a/packages/typedoc-plugin-markdown/src/options/text-mappings/text-mapping-defaults.ts +++ b/packages/typedoc-plugin-markdown/src/options/text-mappings/text-mapping-defaults.ts @@ -2,7 +2,6 @@ import { KIND_DEFAULTS } from './kind-defaults'; export const TEXT_MAPPING_DEFAULTS = { 'header.title': '{projectName} {version}', - 'header.readme': 'Readme', 'header.docs': 'Docs', 'breadcrumbs.home': '{projectName} {version}', 'title.indexPage': '{projectName} {version}', diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.header.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.header.ts index 71b6f837..dabc9c5b 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.header.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/page.header.ts @@ -39,7 +39,6 @@ export function header(this: MarkdownThemeContext): string { .replace(/\s+/g, ' ') .trim(); - const readmeLabel = this.getText('header.readme'); const indexLabel = this.getText('header.docs'); if (this.page.url === entryFileName) { @@ -47,7 +46,6 @@ export function header(this: MarkdownThemeContext): string { } else { md.push(link(title, this.getRelativeUrl(entryFileName))); } - md.push('•'); const preserveReadme = Boolean(this.page.project.readme) && @@ -63,33 +61,24 @@ export function header(this: MarkdownThemeContext): string { false; if (preserveReadme) { - const links: string[] = []; const readMeUrl = useEntryModule ? `readme_${fileExtension}` : entryFileName; - if (this.page.url === readMeUrl) { - links.push(readmeLabel); - } else { - links.push(link(readmeLabel, this.getRelativeUrl(readMeUrl))); - } - - links.push('\\|'); - const indexUrl = useEntryModule ? entryFileName : this.page.project.url; - if (this.page.url === readMeUrl) { - links.push(link(indexLabel, this.getRelativeUrl(indexUrl || ''))); - } else { - links.push(indexLabel); + if (indexLabel) { + if (this.page.url === readMeUrl) { + md.push(link(indexLabel, this.getRelativeUrl(indexUrl || ''))); + } else { + md.push(indexLabel); + } } - - md.push(`${links.join(' ')}`); } else { md.push(indexLabel); } - return `${md.join(' ')}\n\n***\n`; + return `${md.join(' • ')}\n\n***\n`; }; const getPackageHeader = () => { @@ -103,7 +92,6 @@ export function header(this: MarkdownThemeContext): string { const md: string[] = []; - const readmeLabel = this.getText('header.readme'); const indexLabel = this.getText('header.docs'); const fileExtension = this.options.getValue('fileExtension'); @@ -121,36 +109,22 @@ export function header(this: MarkdownThemeContext): string { md.push(link(packageItemName, this.getRelativeUrl(packageEntryFile))); } - md.push('•'); - const preservePackageReadme = Boolean(packageItem.readme) && !this.options.getValue('mergeReadme'); if (preservePackageReadme) { - const links: string[] = []; - - if (this.page.url === packageEntryFile) { - links.push(readmeLabel); - } else { - links.push(link(readmeLabel, this.getRelativeUrl(packageEntryFile))); + if (indexLabel) { + if (this.page.url === packageEntryFile) { + md.push(link(indexLabel, this.getRelativeUrl(packageItem.url || ''))); + } else { + md.push(indexLabel); + } } - - links.push('\\|'); - - if (this.page.url === packageEntryFile) { - links.push( - link(indexLabel, this.getRelativeUrl(packageItem.url || '')), - ); - } else { - links.push(indexLabel); - } - - md.push(`${links.join(' ')}`); } else { md.push(indexLabel); } - return `${md.join(' ')}\n\n***\n`; + return `${md.join(' • ')}\n\n***\n`; }; function findPackage(model: DeclarationReflection | ProjectReflection) { diff --git a/packages/typedoc-plugin-markdown/test/fixtures/typedoc.text-options.cjs b/packages/typedoc-plugin-markdown/test/fixtures/typedoc.text-options.cjs index 98b0760a..f4997cef 100644 --- a/packages/typedoc-plugin-markdown/test/fixtures/typedoc.text-options.cjs +++ b/packages/typedoc-plugin-markdown/test/fixtures/typedoc.text-options.cjs @@ -3,8 +3,7 @@ module.exports = { ...baseOptions, textContentMappings: { 'header.title': 'My API - {version}', - 'header.readme': 'My Readme', - 'header.docs': 'Docs', + 'header.docs': 'API', 'title.indexPage': ':tada: Custom Index Title', 'title.memberPage': '{name}', 'title.modulePage': '{kind} - {name}', diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/entryfiles.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/entryfiles.spec.ts.snap index 49eef0ce..6ec0055b 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/entryfiles.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/entryfiles.spec.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`EntryFiles should get entry module: (Output File Strategy "members") (Option Group "1") 1`] = ` -"@scope/entryfile • [Readme](readme_.mdx) \\| Docs +"@scope/entryfile • Docs *** @@ -31,7 +31,7 @@ exports[`EntryFiles should get entry module: (Output File Strategy "members") (O `; exports[`EntryFiles should get module member for members: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[@scope/entryfile](../../README.mdx) • [Readme](../../readme_.mdx) \\| Docs +"[@scope/entryfile](../../README.mdx) • Docs *** @@ -73,7 +73,7 @@ exports[`EntryFiles should get module member for members: (Output File Strategy `; exports[`EntryFiles should get readme file: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[@scope/entryfile](README.mdx) • Readme \\| [Docs](README.mdx) +"[@scope/entryfile](README.mdx) • [Docs](README.mdx) *** diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/groups.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/groups.spec.ts.snap index 088effe8..6a910240 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/groups.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/groups.spec.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Groups should compile basic module index page: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[typedoc-stubs](../index.md) • [Readme](../index.md) \\| Docs +"[typedoc-stubs](../index.md) • Docs *** @@ -74,7 +74,7 @@ A basic module `; exports[`Groups should compile basic module index page: (Output File Strategy "modules") (Option Group "1") 1`] = ` -"[typedoc-stubs](index.md) • [Readme](index.md) \\| Docs +"[typedoc-stubs](index.md) • Docs *** @@ -254,7 +254,7 @@ A basic module `; exports[`Groups should compile categories group page: (Output File Strategy "modules") (Option Group "1") 1`] = ` -"[typedoc-stubs](index.md) • [Readme](index.md) \\| Docs +"[typedoc-stubs](index.md) • Docs *** @@ -384,7 +384,7 @@ A module that contains categories `; exports[`Groups should compile categories index page: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[typedoc-stubs](../index.md) • [Readme](../index.md) \\| Docs +"[typedoc-stubs](../index.md) • Docs *** @@ -471,7 +471,7 @@ A module that contains categories `; exports[`Groups should compile custom groups index page: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[typedoc-stubs](../index.md) • [Readme](../index.md) \\| Docs +"[typedoc-stubs](../index.md) • Docs *** @@ -544,7 +544,7 @@ Default grouping `; exports[`Groups should compile index page for project: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[typedoc-stubs](index.md) • [Readme](index.md) \\| Docs +"[typedoc-stubs](index.md) • Docs *** @@ -586,7 +586,7 @@ exports[`Groups should compile index page for project: (Output File Strategy "me `; exports[`Groups should compile index page for project: (Output File Strategy "modules") (Option Group "1") 1`] = ` -"[typedoc-stubs](index.md) • [Readme](index.md) \\| Docs +"[typedoc-stubs](index.md) • Docs *** @@ -628,7 +628,7 @@ exports[`Groups should compile index page for project: (Output File Strategy "mo `; exports[`Groups should compile module index for a namespace: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[typedoc-stubs](../../../index.md) • [Readme](../../../index.md) \\| Docs +"[typedoc-stubs](../../../index.md) • Docs *** @@ -667,7 +667,7 @@ exports[`Groups should compile module index for a namespace: (Output File Strate `; exports[`Groups should compile module index for a namespace: (Output File Strategy "modules") (Option Group "1") 1`] = ` -"[typedoc-stubs](../../../index.md) • [Readme](../../../index.md) \\| Docs +"[typedoc-stubs](../../../index.md) • Docs *** @@ -709,7 +709,7 @@ exports[`Groups should compile module index for a namespace: (Output File Strate `; exports[`Groups should compile module index with namespaces index page: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[typedoc-stubs](../index.md) • [Readme](../index.md) \\| Docs +"[typedoc-stubs](../index.md) • Docs *** @@ -839,7 +839,7 @@ A module that contains namespaces `; exports[`Groups should compile module index with namespaces index page: (Output File Strategy "modules") (Option Group "1") 1`] = ` -"[typedoc-stubs](../index.md) • [Readme](../index.md) \\| Docs +"[typedoc-stubs](../index.md) • Docs *** @@ -1081,7 +1081,7 @@ A module that contains namespaces `; exports[`Groups should compile readme for a project: (Output File Strategy "modules") (Option Group "1") 1`] = ` -"typedoc-stubs • Readme \\| [Docs](modules.md) +"typedoc-stubs • [Docs](modules.md) *** @@ -1098,7 +1098,7 @@ Some text. `; exports[`Groups should compile references group page: (Output File Strategy "modules") (Option Group "1") 1`] = ` -"[typedoc-stubs](index.md) • [Readme](index.md) \\| Docs +"[typedoc-stubs](index.md) • Docs *** @@ -1176,7 +1176,7 @@ Renames and re-exports [defaultFunction](has-references.md#defaultfunction) `; exports[`Groups should compile references index page: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[typedoc-stubs](../index.md) • [Readme](../index.md) \\| Docs +"[typedoc-stubs](../index.md) • Docs *** diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/packages.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/packages.spec.ts.snap index 94fa1f1f..3fe82ed6 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/packages.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/packages.spec.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Packages should compile index for a single package: (Output File Strategy "members") (Option Group "1") 1`] = ` -"@scope/package-1 v1.0.0 • Readme \\| [Docs](packages.md) +"@scope/package-1 v1.0.0 • [Docs](packages.md) *** @@ -12,7 +12,7 @@ Readme content `; exports[`Packages should compile index page for packages: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[packages-example](index.md) • [Readme](index.md) \\| Docs +"[packages-example](index.md) • Docs *** @@ -32,7 +32,7 @@ exports[`Packages should compile index page for packages: (Output File Strategy `; exports[`Packages should compile index page for packages: (Output File Strategy "members") (Option Group "1") 2`] = ` -"[@scope/package-1 v1.0.0](index.md) • [Readme](index.md) \\| Docs +"[@scope/package-1 v1.0.0](index.md) • Docs *** @@ -51,7 +51,7 @@ Some more comments for package-1 `; exports[`Packages should compile index page for packages: (Output File Strategy "members") (Option Group "1") 3`] = ` -"[package-2 v1.0.0](index.md) • [Readme](index.md) \\| Docs +"[package-2 v1.0.0](index.md) • Docs *** @@ -78,7 +78,7 @@ exports[`Packages should compile member for relative entry module package: (Outp `; exports[`Packages should compile member page for a single package: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[@scope/package-1 v1.0.0](../README.md) • [Readme](../README.md) \\| Docs +"[@scope/package-1 v1.0.0](../README.md) • Docs *** @@ -95,7 +95,7 @@ exports[`Packages should compile member page for a single package: (Output File `; exports[`Packages should compile member page for packages: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[@scope/package-1 v1.0.0](../index.md) • [Readme](../index.md) \\| Docs +"[@scope/package-1 v1.0.0](../index.md) • Docs *** @@ -129,7 +129,7 @@ exports[`Packages should compile member page for packages: (Output File Strategy `; exports[`Packages should compile readmes for a packages: (Output File Strategy "members") (Option Group "1") 1`] = ` -"packages-example • Readme \\| [Docs](packages.md) +"packages-example • [Docs](packages.md) *** @@ -146,7 +146,7 @@ Some text. `; exports[`Packages should compile readmes for a packages: (Output File Strategy "members") (Option Group "1") 2`] = ` -"@scope/package-1 v1.0.0 • Readme \\| [Docs](globals.md) +"@scope/package-1 v1.0.0 • [Docs](globals.md) *** diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/text.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/text.spec.ts.snap index 16f73a4a..86876b61 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/text.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/text.spec.ts.snap @@ -1,7 +1,7 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP exports[`Text should get translations for index page: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[My API - v0.0](README.md) • [My Readme](README.md) \\| Docs +"[My API - v0.0](README.md) • API *** @@ -15,7 +15,7 @@ exports[`Text should get translations for index page: (Output File Strategy "mem `; exports[`Text should get translations for member page: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[My API - v0.0](../../README.md) • [My Readme](../../README.md) \\| Docs +"[My API - v0.0](../../README.md) • API *** @@ -38,7 +38,7 @@ exports[`Text should get translations for member page: (Output File Strategy "me `; exports[`Text should get translations for module page: (Output File Strategy "members") (Option Group "1") 1`] = ` -"[My API - v0.0](../README.md) • [My Readme](../README.md) \\| Docs +"[My API - v0.0](../README.md) • API *** @@ -55,7 +55,7 @@ exports[`Text should get translations for module page: (Output File Strategy "me `; exports[`Text should get translations for modules page: (Output File Strategy "modules") (Option Group "1") 1`] = ` -"[My API - v0.0](README.md) • [My Readme](README.md) \\| Docs +"[My API - v0.0](README.md) • API ***