Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(55737): JSDoc {@link} support all 4 types of links #56244

Merged
merged 1 commit into from
Nov 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/services/utilities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2977,7 +2977,8 @@ export function buildLinkParts(link: JSDocLink | JSDocLinkCode | JSDocLinkPlain,
if (text) parts.push(linkTextPart(text));
}
else {
parts.push(linkTextPart(name + (suffix ? "" : " ") + text));
const separator = suffix === 0 || (link.text.charCodeAt(suffix) === CharacterCodes.bar && name.charCodeAt(name.length - 1) !== CharacterCodes.space) ? " " : "";
parts.push(linkTextPart(name + separator + text));
}
}
parts.push(linkPart("}"));
Expand Down
121 changes: 121 additions & 0 deletions tests/baselines/reference/quickInfoLink11.baseline
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
// === QuickInfo ===
=== /tests/cases/fourslash/quickInfoLink11.ts ===
// /**
// * {@link https://vscode.dev}
// * [link text]{https://vscode.dev}
// * {@link https://vscode.dev|link text}
// * {@link https://vscode.dev link text}
// */
// function f() {}
//
// f();
// ^
// | ----------------------------------------------------------------------
// | function f(): void
// | {@link https://vscode.dev}
// | [link text]{https://vscode.dev}
// | {@link https://vscode.dev link text}
// | {@link https://vscode.dev link text}
// | ----------------------------------------------------------------------

[
{
"marker": {
"fileName": "/tests/cases/fourslash/quickInfoLink11.ts",
"position": 170,
"name": ""
},
"item": {
"kind": "function",
"kindModifiers": "",
"textSpan": {
"start": 170,
"length": 1
},
"displayParts": [
{
"text": "function",
"kind": "keyword"
},
{
"text": " ",
"kind": "space"
},
{
"text": "f",
"kind": "functionName"
},
{
"text": "(",
"kind": "punctuation"
},
{
"text": ")",
"kind": "punctuation"
},
{
"text": ":",
"kind": "punctuation"
},
{
"text": " ",
"kind": "space"
},
{
"text": "void",
"kind": "keyword"
}
],
"documentation": [
{
"text": "",
"kind": "text"
},
{
"text": "{@link ",
"kind": "link"
},
{
"text": "https://vscode.dev",
"kind": "linkText"
},
{
"text": "}",
"kind": "link"
},
{
"text": "\n[link text]{https://vscode.dev}\n",
"kind": "text"
},
{
"text": "{@link ",
"kind": "link"
},
{
"text": "https://vscode.dev link text",
"kind": "linkText"
},
{
"text": "}",
"kind": "link"
},
{
"text": "\n",
"kind": "text"
},
{
"text": "{@link ",
"kind": "link"
},
{
"text": "https://vscode.dev link text",
"kind": "linkText"
},
{
"text": "}",
"kind": "link"
}
]
}
}
]
13 changes: 13 additions & 0 deletions tests/cases/fourslash/quickInfoLink11.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
///<reference path="fourslash.ts" />

/////**
//// * {@link https://vscode.dev}
//// * [link text]{https://vscode.dev}
//// * {@link https://vscode.dev|link text}
//// * {@link https://vscode.dev link text}
//// */
////function f() {}
////
/////**/f();

verify.baselineQuickInfo();
Loading