Skip to content

Commit 6c3d7ad

Browse files
cheesengbvenners
andcommitted
Fix duplicate member entries in Scaladoc generation
Resolves an issue where Scaladoc was generating duplicate entries for the same members when combining results from multiple parser instances. The fix implements deduplication by creating a stable composite key from the member's location, full name, and kind. When duplicates are found, the entry with documentation is preferred, falling back to the first entry if none have docs. This ensures clean, non-redundant API documentation output. Co-authored-by: Bill Venners <bill@artima.com>
1 parent ff7e01c commit 6c3d7ad

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

scaladoc/src/dotty/tools/scaladoc/tasty/TastyParser.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,12 @@ object ScaladocTastyInspector:
169169
val withNewMembers = p1.withNewMembers(p2.members)
170170
if withNewMembers.docs.isEmpty then withNewMembers.withDocs(p2.docs) else withNewMembers
171171
)
172-
basePck.withMembers((basePck.members ++ rest).sortBy(_.name))
172+
// Deduplicate members coming from different parser instances by a stable key:
173+
// (location, member fullName, kind name).
174+
val combined = basePck.members ++ rest
175+
val keyed = combined.groupBy(m => (m.dri.location, m.fullName, m.kind.name))
176+
val uniqueMembers = keyed.values.map(g => g.find(_.docs.nonEmpty).getOrElse(g.head)).toList.sortBy(_.name)
177+
basePck.withMembers(uniqueMembers)
173178
}.toList -> inspector.rootDoc
174179

175180
end ScaladocTastyInspector

0 commit comments

Comments
 (0)