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

[typespec-vs] Fix missing doc on hover in vs #6012

Closed
Closed
Changes from 1 commit
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
b0ac596
Merge pull request #1 from microsoft/main
mzhongl524 Nov 22, 2024
3fcbe52
Merge branch 'microsoft:main' into main
mzhongl524 Nov 25, 2024
c109816
Merge branch 'microsoft:main' into main
mzhongl524 Dec 6, 2024
23f0108
Merge branch 'microsoft:main' into main
mzhongl524 Dec 12, 2024
6f04f65
Merge branch 'microsoft:main' into main
mzhongl524 Dec 23, 2024
688ca03
Merge branch 'microsoft:main' into main
mzhongl524 Dec 24, 2024
de3725e
Merge branch 'microsoft:main' into main
mzhongl524 Dec 30, 2024
8130ffb
Merge branch 'microsoft:main' into main
mzhongl524 Jan 3, 2025
beb6433
Merge branch 'microsoft:main' into main
mzhongl524 Jan 15, 2025
8a501f2
Merge branch 'microsoft:main' into main
mzhongl524 Jan 15, 2025
6e1ab2d
Merge branch 'microsoft:main' into main
mzhongl524 Jan 23, 2025
a35052f
Merge branch 'microsoft:main' into main
mzhongl524 Jan 24, 2025
be57c13
Merge branch 'microsoft:main' into main
mzhongl524 Feb 5, 2025
3a9dc7a
Merge branch 'microsoft:main' into main
mzhongl524 Feb 10, 2025
ad7dff7
Merge branch 'microsoft:main' into main
mzhongl524 Feb 10, 2025
f8e8f2f
Merge branch 'microsoft:main' into main
mzhongl524 Feb 12, 2025
619ccbb
Make the hover prompts in vs and vscode consistent
mzhongl524 Feb 14, 2025
4200f2c
adjust the test
mzhongl524 Feb 14, 2025
0833d0a
Create fix-missing-doc-on-hover-in-vs-2025-1-14-2-56-0.md
mzhongl524 Feb 14, 2025
dd496fe
adjust the test
mzhongl524 Feb 14, 2025
38656bb
Merge branch 'fix-missing-doc-on-hover-in-vs' of https://github.com/m…
mzhongl524 Feb 14, 2025
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
Prev Previous commit
Next Next commit
Make the hover prompts in vs and vscode consistent
  • Loading branch information
mzhongl524 committed Feb 14, 2025
commit 619ccbbc831edc62533e18037fa206401b5112b3
25 changes: 19 additions & 6 deletions packages/compiler/src/server/type-details.ts
Original file line number Diff line number Diff line change
@@ -43,10 +43,19 @@ export function getSymbolDetails(
) {
continue;
}
lines.push(
//prettier-ignore
`_@${tag.tagName.sv}_${"paramName" in tag ? ` \`${tag.paramName.sv}\`` : ""} —\n${getDocContent(tag.content)}`,
);

const descMsg = getDocContent(tag.content);
if (descMsg.startsWith("```")) {
lines.push(
//prettier-ignore
fence(`@${tag.tagName.sv}${"paramName" in tag ? `${tag.paramName.sv}` : ""} —`)+`\n${descMsg}`,
);
} else {
lines.push(
//prettier-ignore
fence(`@${tag.tagName.sv}${"paramName" in tag ? ` ${tag.paramName.sv}` : ""} — ${descMsg}`),
);
}
}
}
}
@@ -59,7 +68,7 @@ function getSymbolDocumentation(program: Program, symbol: Sym) {
for (const node of [...symbol.declarations, ...(symbol.node ? [symbol.node] : [])]) {
// Add /** ... */ developer docs
for (const d of node.docs ?? []) {
docs.push(getDocContent(d.content));
docs.push(fence(getDocContent(d.content)));
}
}

@@ -75,7 +84,7 @@ function getSymbolDocumentation(program: Program, symbol: Sym) {
const apiDocs = getDocData(program, type);
// The doc comment is already included above we don't want to duplicate. Only include if it was specificed via `@doc`
if (apiDocs && apiDocs.source === "decorator") {
docs.push(apiDocs.value);
docs.push(fence(apiDocs.value));
}
}

@@ -121,3 +130,7 @@ function getDocContent(content: readonly DocContent[]) {
}
return docs.join("");
}

function fence(content: string) {
return content.startsWith("```") ? content : `\`\`\`\n${content}\n\`\`\``;
}
12 changes: 7 additions & 5 deletions packages/compiler/test/server/get-hover.test.ts
Original file line number Diff line number Diff line change
@@ -50,7 +50,8 @@ describe("compiler: server: on hover", () => {
deepStrictEqual(hover, {
contents: {
kind: MarkupKind.Markdown,
value: "(model property)\n```typespec\nMyModel.name: string\n```\n\nname of the model",
value:
"(model property)\n```typespec\nMyModel.name: string\n```\n\n```\nname of the model\n```",
},
});
});
@@ -152,7 +153,7 @@ describe("compiler: server: on hover", () => {
"```typespec\n" +
"dec single(context: unknown)\n" +
"```\n\n" +
"description of single decorator",
"```\ndescription of single decorator\n```",
},
});
});
@@ -221,7 +222,7 @@ describe("compiler: server: on hover", () => {
"MyLogArg.msg: string\n" +
"```\n" +
"\n" +
"my log message",
"```\nmy log message\n```",
},
});
});
@@ -253,7 +254,7 @@ describe("compiler: server: on hover", () => {
"MyLogContext<T>.item: Record<Element>\n" +
"```\n" +
"\n" +
"items of context",
"```\nitems of context\n```",
},
});
});
@@ -615,7 +616,8 @@ describe("compiler: server: on hover", () => {
deepStrictEqual(hover, {
contents: {
kind: MarkupKind.Markdown,
value: "(model property)\n```typespec\nMyModel.name: string\n```\n\nname of the model",
value:
"(model property)\n```typespec\nMyModel.name: string\n```\n\n```\nname of the model\n```",
},
});
});
Loading
Oops, something went wrong.