Skip to content

Commit 3fa8fb9

Browse files
committed
Scala3doc: avoid documenting sources of stdlib patches
1 parent e06a381 commit 3fa8fb9

File tree

1 file changed

+15
-10
lines changed

1 file changed

+15
-10
lines changed

scala3doc/src/dotty/dokka/tasty/TastyParser.scala

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,17 +30,22 @@ case class DokkaTastyInspector(parser: Parser)(using ctx: DocContext) extends Do
3030
private val topLevels = Seq.newBuilder[Documentable]
3131

3232
def processCompilationUnit(using q: Quotes)(root: q.reflect.Tree): Unit =
33-
val parser = new TastyParser(q, this)
34-
35-
def driFor(link: String): Option[DRI] =
36-
val symOps = new SymOps[q.type](q)
37-
import symOps._
38-
Try(QueryParser(link).readQuery()).toOption.flatMap(q =>
39-
MemberLookup.lookupOpt(q, None).map{ case (sym, _) => sym.dri}
40-
)
33+
// NOTE we avoid documenting definitions in the magical stdLibPatches directory;
34+
// the symbols there are "patched" through dark Dotty magic onto other stdlib
35+
// definitions, so if we documented their origin, we'd get defs with duplicate DRIs
36+
if !root.symbol.show.startsWith("scala.runtime.stdLibPatches") then
37+
val parser = new TastyParser(q, this)
38+
39+
def driFor(link: String): Option[DRI] =
40+
val symOps = new SymOps[q.type](q)
41+
import symOps._
42+
Try(QueryParser(link).readQuery()).toOption.flatMap(q =>
43+
MemberLookup.lookupOpt(q, None).map{ case (sym, _) => sym.dri}
44+
)
4145

42-
ctx.staticSiteContext.foreach(_.memberLinkResolver = driFor)
43-
topLevels ++= parser.parseRootTree(root.asInstanceOf[parser.qctx.reflect.Tree])
46+
ctx.staticSiteContext.foreach(_.memberLinkResolver = driFor)
47+
topLevels ++= parser.parseRootTree(root.asInstanceOf[parser.qctx.reflect.Tree])
48+
end processCompilationUnit
4449

4550
def result(): List[DPackage] =
4651
topLevels.clear()

0 commit comments

Comments
 (0)