Skip to content

Commit

Permalink
Fix dup doc (#2976)
Browse files Browse the repository at this point in the history
  • Loading branch information
timotheeguerin authored Mar 1, 2024
1 parent cc1774f commit 01ba99b
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
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

0 comments on commit 01ba99b

Please sign in to comment.