From 8962a9f98abc74d512ccc1e1fe8b5c36af95c661 Mon Sep 17 00:00:00 2001 From: tgreyuk Date: Sat, 11 May 2024 23:10:32 +0100 Subject: [PATCH] fix(core): remove superfluous spaces and symbol on external links (#614) --- .changeset/young-wombats-applaud.md | 3 ++- .../resources/partials/type.reference.ts | 4 ++-- .../objects-and-params.spec.ts.snap | 24 +++++++++---------- .../reflection.function.spec.ts.snap | 6 ++--- .../reflection.type-alias.spec.ts.snap | 14 +++++------ 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/.changeset/young-wombats-applaud.md b/.changeset/young-wombats-applaud.md index 81f1c7105..9e8a5e5a2 100644 --- a/.changeset/young-wombats-applaud.md +++ b/.changeset/young-wombats-applaud.md @@ -1,7 +1,8 @@ --- -"typedoc-plugin-markdown": patch +'typedoc-plugin-markdown': patch --- +- Remove superfluous spaces and symbol on external links (#614) - Escape all angle brackets with "santizeComments" (#612) - Correctly handle quoted symbol names (#611) - Correctly handle excludeScopesInPaths in windows (#610) diff --git a/packages/typedoc-plugin-markdown/src/theme/resources/partials/type.reference.ts b/packages/typedoc-plugin-markdown/src/theme/resources/partials/type.reference.ts index a54274e65..539e22285 100644 --- a/packages/typedoc-plugin-markdown/src/theme/resources/partials/type.reference.ts +++ b/packages/typedoc-plugin-markdown/src/theme/resources/partials/type.reference.ts @@ -22,7 +22,7 @@ export function referenceType( } else { reflection.push( model.externalUrl - ? `[${backTicks(model.name + ' ↗️')}]( ${model.externalUrl} )` + ? link(backTicks(model.name), model.externalUrl) : backTicks(model.name), ); } @@ -32,6 +32,6 @@ export function referenceType( return reflection.join(''); } return model.externalUrl - ? `[${backTicks(model.name + ' ↗️')}]( ${model.externalUrl} )` + ? link(backTicks(model.name), model.externalUrl) : backTicks(model.name); } diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap index cf501c5a6..364ead821 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/objects-and-params.spec.ts.snap @@ -228,13 +228,13 @@ Comments for BasicInterface exports[`Objects And Params should compile function returning a promise: (Output File Strategy "members") (Option Group "1") 1`] = ` "# Function: functionReturningAPromise() -> **functionReturningAPromise**(): [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\\{\`"prop"\`: \`string\`; \\}\\> +> **functionReturningAPromise**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{\`"prop"\`: \`string\`; \\}\\> Comments for function ## Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\\{\`"prop"\`: \`string\`; \\}\\> +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{\`"prop"\`: \`string\`; \\}\\> Return comments @@ -257,7 +257,7 @@ Comments for function ## Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\\{ +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\\{ \`"prop"\`: \`string\`; \\}\\> @@ -500,7 +500,7 @@ bar: number; exports[`Objects And Params should compile literal type: (Output File Strategy "members") (Option Group "1") 1`] = ` "# Type alias: LiteralType -> **LiteralType**: \\{\`"x"\`: \`string\`;\`"y"\`: \\{\`"x"\`: \`string\`;\`"y"\`: \`boolean\` \\| \`string\`;\`"z"\`: (\`x\`: \`string\`) => \`string\`; \\};\`"z"\`: (\`x\`: \`string\`) => \`string\`;get set \`"accessorA"\`: [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\>;get set \`"accessorB"\`: \`string\`;\`"someFunction"\`: [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`any\`\\>; \\} +> **LiteralType**: \\{\`"x"\`: \`string\`;\`"y"\`: \\{\`"x"\`: \`string\`;\`"y"\`: \`boolean\` \\| \`string\`;\`"z"\`: (\`x\`: \`string\`) => \`string\`; \\};\`"z"\`: (\`x\`: \`string\`) => \`string\`;get set \`"accessorA"\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>;get set \`"accessorB"\`: \`string\`;\`"someFunction"\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\>; \\} Comments for LiteralType @@ -558,21 +558,21 @@ comment for y.z ### accessorA -> \`get\` **accessorA**(): [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\> +> \`get\` **accessorA**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> Comments for accessorA getter -> \`set\` **accessorA**(\`x\`: [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\>): \`void\` +> \`set\` **accessorA**(\`x\`: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\>): \`void\` Comments for accessorA setter #### Parameters -• **x**: [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\> +• **x**: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> #### Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\> +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> ### accessorB @@ -598,7 +598,7 @@ Comments for someFunction #### Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`any\`\\> +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\> " `; @@ -712,11 +712,11 @@ Comments for accessorA setter | Parameter | Type | | :------ | :------ | -| \`x\` | [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\> | +| \`x\` | [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> | #### Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\> +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> ### accessorB @@ -750,7 +750,7 @@ Comments for someFunction #### Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`any\`\\> +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\> " `; diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap index 4fd7355ca..a7221b75a 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.function.spec.ts.snap @@ -67,13 +67,13 @@ Comments for function exports[`Function Reflection should compile function returning a promise: (Output File Strategy "members") (Option Group "1") 1`] = ` "# Function: functionReturningAPromise() -> **functionReturningAPromise**(): [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`object\`\\> +> **functionReturningAPromise**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`object\`\\> Comments for function ## Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`object\`\\> +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`object\`\\> Return comments @@ -98,7 +98,7 @@ Comments for function ## Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`object\`\\> +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`object\`\\> Return comments diff --git a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.type-alias.spec.ts.snap b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.type-alias.spec.ts.snap index ec9eba7a2..301c709be 100644 --- a/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.type-alias.spec.ts.snap +++ b/packages/typedoc-plugin-markdown/test/specs/__snapshots__/reflection.type-alias.spec.ts.snap @@ -69,7 +69,7 @@ Comments for ConditionalType exports[`Type Alias Reflection should compile external link symbol type: (Output File Strategy "members") (Option Group "1") 1`] = ` "# Type alias: TypeWithExternalSymbolLinkMapping -> **TypeWithExternalSymbolLinkMapping**: [\`Application ↗️\`]( https://typedoc.org/api/classes/Application.html ) +> **TypeWithExternalSymbolLinkMapping**: [\`Application\`](https://typedoc.org/api/classes/Application.html) Comments for TypeWithExternalSymbolLinkMapping @@ -155,7 +155,7 @@ comment for y.z ### accessorA -> \`get\` **accessorA**(): [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\> +> \`get\` **accessorA**(): [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> Comments for accessorA getter @@ -165,11 +165,11 @@ Comments for accessorA setter #### Parameters -• **x**: [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\> +• **x**: [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> #### Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\> +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> ### accessorB @@ -195,7 +195,7 @@ Comments for someFunction #### Returns -[\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`any\`\\> +[\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\> ## Source @@ -222,11 +222,11 @@ Comments for LiteralType | \`y.y\` | \`boolean\` \\| \`string\` | comment for y.y | | \`y.z\` | (\`x\`: \`string\`) => \`string\` | comment for y.z | | \`z\` | (\`x\`: \`string\`) => \`string\` | - | -| \`get accessorA\` | [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`string\`\\> | Comments for accessorA getter | +| \`get accessorA\` | [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`string\`\\> | Comments for accessorA getter | | \`set accessorA\` | \`void\` | Comments for accessorA setter | | \`get accessorB\` | \`string\` | - | | \`set accessorB\` | \`void\` | - | -| \`someFunction\` | [\`Promise ↗️\`]( https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise )\\<\`any\`\\> | Comments for someFunction | +| \`someFunction\` | [\`Promise\`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise)\\<\`any\`\\> | Comments for someFunction | ## Source