Skip to content

Commit 1ed636e

Browse files
committed
Scala3doc: avoid documenting sources of stdlib patches
1 parent af9da94 commit 1ed636e

File tree

1 file changed

+14
-10
lines changed

1 file changed

+14
-10
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,17 +33,21 @@ case class DokkaTastyInspector(
3333
private val topLevels = Seq.newBuilder[Documentable]
3434

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

45-
config.staticSiteContext.foreach(_.memberLinkResolver = driFor)
46-
topLevels ++= parser.parseRootTree(root.asInstanceOf[parser.qctx.reflect.Tree])
49+
config.staticSiteContext.foreach(_.memberLinkResolver = driFor)
50+
topLevels ++= parser.parseRootTree(root.asInstanceOf[parser.qctx.reflect.Tree])
4751

4852
def result(): List[DPackage] =
4953
topLevels.clear()

0 commit comments

Comments
 (0)