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

Fix duplicate docs in hover or completion details #2976

Merged
merged 3 commits into from
Mar 1, 2024
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
8 changes: 8 additions & 0 deletions .chronus/changes/fix-dup-doc-2024-2-1-20-28-15.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
# Change versionKind to one of: internal, fix, dependencies, feature, deprecation, breaking
changeKind: fix
packages:
- "@typespec/compiler"
---

[IDE] Fix type documentation shown twice when hovering symbols or in completion details.
2 changes: 1 addition & 1 deletion packages/compiler/src/lib/decorators.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ export interface DocData {

/**
* How was the doc set.
* - `@doc` means the `@doc` decorator was used
* - `decorator` means the `@doc` decorator was used
* - `comment` means it was set from a `/** comment * /`
*/
source: "decorator" | "comment";
Expand Down
4 changes: 2 additions & 2 deletions packages/compiler/src/server/type-details.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,8 @@ function getSymbolDocumentation(program: Program, symbol: Sym) {
// Add @doc(...) API docs
const type = symbol.type ?? program.checker.getTypeForNode(symbol.declarations[0]);
const apiDocs = getDocData(program, type);
// The doc comment is already included above we don't want to duplicate
if (apiDocs && apiDocs.source === "comment") {
// 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);
}

Expand Down
Loading